Object-Oriented Principles Flashcards
SOLID Principles?
Single-Responsibility Principle Open Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle
Single-Responsibility Principle?
A class should have one, and only one reason to change
SoC principle that focuses on managing change by assigning cohesive responsibilities.
Open-Closed Principle
You should be able to extend the behaviour of a module without modifying it
A module is closed for modification but open to be extended.
How is Open-Closed Principle achieved?
Loose coupling
Abstraction
Polymorphism
Liskov Substitution Principle?
Subclasses should be substitutable for their base classes
Dictates the correct implementation of the IS-A relationship
Interface Segregation Principle?
Many client specific interfaces are better than one general purpose interface
Critical principle to follow in the design of interfaces who are much more focused than the classes that implement them
Dependency Inversion Principle?
Depend upon Abstractions. Do not depend upon concretions
Definition of use of abstraction to ensure loose coupling.
Enables dependency injections and associated frameworks
S O L I D
High Cohesiveness Code Reuse Code Reuse SoC Loose Coupling
4 Essential elements in Design Pattern?
Pattern Name
Problem
Solution
Consequencies
What did GoF do?
GoF established a paradigm for cataloguing and reuse of design solutions
Pattern Catagorization?
Architecture Patterns
Design Patterns
Idioms
Architectural Patterns?
Expresses fundamental structural organizartion of software systems; predefined subsystems and their responsibilities and relationships
* Large Scale Patterns
Design Patterns?
Medium Scale Patterns
Idioms?
Programming language specific pattern that describes how to implement particular aspects of components, relationships or functionality
Pattern Classification By Purpose list
Creational Patterns
Structural Patterns
Behavioural Patterns
Creational Patterns?
Address the instantiation process as a separate concern
Make system independent
Emphasize object composition vs class inheritance to decrease coupling
Structural Patterns?
Ways to compose classes and objects to from larger structure to realize new functionality that can be easily extended
Behavioural Patterns?
Representing algorithms and assignment of responsibilities between objects and focus on patterns of communication between objects
Pattern Classification by Scope?
Class Patterns
Object Patterns
Class Patterns?
Focus on relationships between classes and subclasses.
Inheritance relationships are defined at compile-time
Focus on code reuse
Object Patterns?
Focus relationships between objects, specifically composition and aggregation.
Relationships are dynamic
Focus on code reuse through flexibility
Roles in Abstract Factory Pattern?
Abstract Factory
Concrete Factory
Abstract Product
Concrete Product
Consequencies of Abstract Factory?
Isolates the client from specific concrete classes making clients dependent only on interfaces
Roles in Factory Method Pattern?
Creator
ConcreteCreator
Product
ConcreteProduct