evaluating design complexity Flashcards
What are modules?
Modules refer to program units containing classes and the methods within them. (like a package)
A system is a combination of various modules.
What metrics are often used to evaluate design complexity? What are the differences between them?
Coupling focuses on complexity between a module and other modules.
Cohesion focuses on complexity within a module and represents the clarity of the responsibilities of a module.
What are metrics to evaluate the coupling of a module?
- degree: the number of connections between the module and others. A module should connect to others through a few parameters or narrow interfaces.
- ease: connections should be easy to make without needing to understand the implementations of other modules for coupling purposes.
- flexibility: Other modules should be easily replaceable for something better in the future.
What are signs of a tightly coupled bad design?
- a module connects to other modules through a great number of parameters or interfaces
- corresponding modules to a module are difficult to find
- module can only be connected to specific other modules and cannot be interchanged
Give examples of tight and loose coupling.
– tight coupling: a module is too reliant on other modules
– loose coupling: a module finds it easy to connect to other modules through well-defined interfaces
Give examples of high and low cohesion.
– high cohesion:
– low cohesion:
1. a module encapsulate more than one purpose or responsibility
2. if an encapsulation has to be broken to understand a method
3. if the module has an unclear purpose
Give examples of how complexity can be distributed between the modules or within the modules designing complex systems
- If each module is simplified to achieve high cohesion, they may need to depend more on other modules, thus increasing coupling.
- If connections between modules are simplified to achieve low coupling, each module may need to take on more responsibilities and thus lowering cohesion.
What are four design principles?
AEDG
1. Abstraction
2. Encapsulation
3. Decomposition
4. Generalization
What is abstraction?
Abstraction occurs as each concept in the problem space is separated with its own relevant attributes and behaviors.
It suggests that a concept in the problem domain should be simplified down to its essentials within some context.
What is encapsulation?
Encapsulation occurs as the attributes and behaviors are gathered together into their own section of code called a class.
Access to the class from the rest of the system and its implementation are separated, so the details of implementation can change while the view through an interface can stay the same.
What is decomposition?
Decomposition occurs as a whole class can be separated into multiple classes.
What is generalization?
Generalization occurs as commonalities are recognized into a superclass.
What do four access modifiers in Java do? (public, protected, default, private)
- public: everywhere in the program
- protected: subclasses and within package
- default: within package
- private: within class
What is a namespace
A namespace is a package that classes can be organized and represented by.
What is override?
Override occurs when a subclass can provide its own implementation for an inherited superclass’s method.