Techniques for good Design Flashcards
What are basic symptoms of Degenerative design?
Fragility - Changes lead to unforeseen errors
Rigidity - changes often bring with them lots of additional changes
Low reusablity - parts are not or cannot be reused
What are techniques for good design? (SOLID…)
- Single Responsiblity Principle
- Open-Closed Principle
- Liskov’s substitution principle
- Interface seggregation principle
- Dependency Inversion
- Low Coupling
- High cohesion
- Resolvation of cyclic dependencies
Describe the Single Responsibility Principle (SRP)
- classes should only have one reason to change
- functional unit should only be responsible for a single aspect of a system’s requierement
- an apsect of a requierement is a trait/property of requierements which can change seperately from other aspects
Describe the open-closed principle
Sofware Modules should be
- open for extension (through polymorphism/inheritance)
- closed for modification (given logic remains reliable and unchanged)
Describe Liskov’s Substitution principle
A basic class should always be replaceable by its derived classes (subclasses)
Subclasses should behave in a expected and similiar way as the parent class.
Describe the Interface Seggregation Principle (ISP)
Extensive and complex interfaces should be subdevided, based on
- semantic context
- area of responsibility
- user groups
Describe the Dependency Inversion Principle
- Dependencies should always be to abstract descriptions instead of concrete implementations
- making the implementations interchangeable without necessary changes to the using class
- no direct dependencies, instead only dependencies to abstractions
Describe the loose coupling principle
- coupling refers to the relationship between building blocks and how strong the resulting dependency is
- loose coupling aims to reduce the complexity of structures
- the looser the coupling the easier an individual building block is to understand
- and the easier it is to modify
Name a few types of coupling
- Call: when a class uses directly another class my calling a method of that class
- Generation: when a building block generates another building block
- Data: when classes communicate via global data structures or method parameters
- Execution location: hardware-based coupling, when building blocks have to run on same VM
- Time: when chronological sequence of building block call impacts end results
- Inheritance: subclass is coupled to parent class, level of coupling dependen on amount of inherited attributes
Describe the high cohesion principle
- cohesion describes how parts of a building block deal with the same theme
- a cohesive class solves a single problem
- influences how easily building blocks can be modified
- low cohesion leads to one change needing additional changes in different building blocks or classes
- classes should not be grouped by packages but instead by systems and subsystems