Lec12


Lec7
Design goals
- Robustness
- Flexibility
- Extensibility
- Reusability
- Efficiency
- Scalability
- Security
- Maintainability
- Testability
- Modularity
- Interoperability
- Usability
- Portability
Design principles
- Low representational gap
- Low coupling
- High cohesion
Design patterns
- Strategy pattern
- Template method pattern
- Composite pattern
- Decorator pattern
- Observer pattern
- Builder pattern
- Fluent API pattern
- Iterator pattern
- Module pattern
- Model-View-Controller (MVC) pattern
- Facade pattern
- Adapter pattern
- Proxy pattern
- Producer-Consumer pattern
Anti-patterns
- Bloaters (Long Methods, Large Classes)
- Misuse of Inheritance
- Conditional Complexity (Using 'instanceof' or 'switch' instead of Polymorphism)
- Parallel Inheritance Hierarchies
- Shotgun Surgery (Any Change Requires Lots of Edits)
- Speculative Generality (Excessive, Unused Hierarchies)
- Misplaced Responsibilities (Operations Posing as Classes)
- Data Classes (Lack of Encapsulation)
- Feature Envy (Heavy Usage of One Class' Data from Another)
- Law of Demeter Violation (Long Chains of Calls)
- Middle Man (A Class That Only Delegates Work)
Design heuristics
- Controller (decoupled UI and domain logic)
- Information expert
- Creator (promotes low coupling and high cohesion, B aggregates A objects, B contains A objects, B records instances of A objects, B closely uses A objects, or B has the initializing data for creating A objects (the more the better))
- Law of Demeter (principle of least knowledge)
Lec8
1. Dynamic Dispatch: At compile time determine which class to look in and method signature to be executed. At run time, determine dynamic class (the actual class not interface) of the receiver and which method to invoke
2. Final Keyword: final class prevents extending the class, final method prevents overriding the method, final field prevents reassignment after initialization
3. Behavioral Subtyping: same or stronger invariants than super class, same or weaker preconditions for all methods than super class, same or stronger postconditions for all methods in super class.
a) Square is not a behavioral subtype of rectangle