CDL Section 3 - Designing SW Flashcards
What helps to make modular code good?
- Well-maintained code is just as important as the product or service that this code delivers
- A clear communication path between different components.
What are Microservices?
What’s an example of the how they communicate?
Applications are often split into a suite of multiple smaller, independently running components or services, all complementing each other to reach a common goal.
The code/app can be broken into blocks of reusable chunks that perform a single/related task ver well.
These applications communicate with lightweight mechanisms such as a REST API.
What is a Function (as it relates to Microservices)? How do you make them work?
Functions are blocks of reusable code chunks that perform a single, or related task. They are “invoked” when triggered i.e “invoking a function” = calling on a function to execute.
They are the first line in organizing and achieving a certain level of modularity.
- Modules bring flexibility because one model can be changed entirely without affecting others.
- Allows one module to be developed with little knowledge of the implementation in another module.
What are code Modules?
A set of Functions that are grouped together into a single file, allowing them to all be called/invoked at once.
Modules can invoke specific Functions from other Modules if needed.
True/False: When importing Module(s) to your application code, should the import itself make any changes or execute any actions automatically?
FALSE - it should not.
What is Object Oriented Programming/OOP?
OOP is a method of programming, or programming language, that introduces Objects.
REVIEW:
Significant Terms in OOP
→ Objects - basically records, or instances, of code, that allow you to carry data with them and execute defined actions on them
○ represents a blueprint of what an object looks like, and how it behaves is defined within a class.
○ An object = a collection of functions and data
○ Function = block or reusable code chunk.
→ Class - a formal description of an object that you want to create; contains parameters for holding data and Methods that will enable interaction with the object and execution of defined actions
○ Classes can also inherit data from other classes
→ Class is a blueprint or template to create Objects ○ you can create class hierarchies in which the child class inherits the parent default behavior and can also enhance its role with its own implementations
→ Method is a function that describes the behavior of an object
TRUE/FALSE: Modules made code easier to understand?
TRUE
They lower the overwhelming feeling when you delve into the code for improvements or feature additions.
They should encapsulate parts of functionality of a system and constrain how these parts interact among each other.
Are Modules mainly static or dynamic in nature?
Static.
A change in one part of the application code should not break or affect other parts if designed correctly.
Modules must have well-defined interfaces that do not change.
What is a Module Interface?
The interface to a module is an abstraction of the module’s functions. The interface defines the features of the module and how to use them.
What are Acyclic v Cyclic Dependencies, as it relates to Modules and Classes?
Acyclic - ensures that when you split your monolithic application into multiple modules, these modules—and the classes accompanying them—have dependencies in ONE direction only.
Cyclic - means dependencies in both directions i.e any change in Module A would lead to a change in Module B, but then the changes in Module B could cause unexpected behavior in Module A.
REVIEW:
Modules, classes, and functions are tools that should reduce complexity of your application and increase reusability.
What is a:
Module?
Class?
Allow us to logically group our data and functions in a way that’s easy to reuse and also build upon if needed; a blueprint for creating Instances and/or Objects.
Function?
What is the difference between Loose and Tight coupling of components in an app i.e Modules, classes, functions, etc?
Loose coupling is about reducing dependencies of a module, class, or function that uses different modules, classes, or functions directly; easier to maintain and reuse.
Tight Coupling is the opposite where all the objects are dependent on one another; more rigid.
- Reducing the dependencies between components of a system results in reducing the risk that changes of one component will require you to change any other component *
What is Cohesion? (in relation to classes/functions/modules)
What makes for strong cohesion? Do you want this?
It interprets classes, modules, and functions and defines if all of them aim for the same goal.
Modules that contain strongly related classes and functions can be considered to have strong or high cohesion.
YES - the goal is to make Cohesion as strong as possible. This means that logically separated code blocks have a very clearly defined purpose.
What is the ideal combination of Coupling and Cohesion?
LOOSE Coupling with STRONG Cohesion