Professional Documents
Culture Documents
01-PowerPoint Partitioning and Layering Fundamentals
01-PowerPoint Partitioning and Layering Fundamentals
Fundamental Concepts
Difference between a type and an object Complex type Composition Interface
Type
class Employee { string name; void Pay() . }
Simple Type Complex Type
Data
Behavior
Object
Object Composition
class Auto { Engine engine; Wheel[4] wheels; void Drive() {}; }
Write your applications so that the dependencies of one type on another are eliminated or minimized.
Interfaces
Interfaces describe behavior, not implementation
interface IEngine { void Start(); void Stop(); } interface IWheel { void Turn(); }
Interface Composition
class Auto { IEngine engine; IWheel[4] wheels; void Drive() {} }
Coupling
Preserve Essential Coupling
Essential Semantics
Electrical Analogy
Wall socket interface removes the inessential coupling due to the physical shape of plugs and appliances An interface cannot remove the essential behavioral coupling of voltage and amperage of standard current
Interfaces
Avoid Inheriting Implementation Restrict Inessential Coupling Make Interfaces Easy to Modify
Design Patterns
Minimize Dependencies in Implementation Use Design Patterns Electrical Analogy Design to work with 110 or 220 volts? Use Transformer Pattern Flexibility even with Essential Coupling
Summary
Reduce coupling and dependencies of complex types Use Interface Based Design Use Composition rather than Implementation Inheritance Write unit tests to validate behavior