GRASP
General Responsibility Assignment Software Patterns (or Principles), abbreviated GRASP, is a set of nine fundamental principles in object design and responsibility assignment: 6 first published by Craig Larman in his 1997 book Applying UML and Patterns
Information Expert
related Pattern or Principle:
Low Coupling High Cohesion
Creator
related Pattern or Principle:
Low Coupling Factory patterns
Controller
related Pattern or Principle:
Command, Facade, Layers, Pure Fabrication
Indirection
Low Coupling
High Cohesion
Polymorphism
Protected Variations
Pure Fabrication
related Patterns and Principles:
Low Coupling High Cohesion
...
SOLID
Software engineer and instructor Robert C. Martin introduced the basic principles of SOLID design in his 2000 paper Design Principles and Design Patterns about software rot
The SOLID acronym was coined around 2004 by Michael Feathers
Single-responsibility principle
states that there should never be more than one reason for a class to change. In other words, every class should have only one responsibility.
Importance
Maintainability when classes have a single, well-defined responsibility, they're easier to understand and modify
Testability it's easier to write unit tests for classes with a single focus
Flexibility changes to one responsibility don't affect unrelated parts of the system
Open–closed
principle states that software entities should be open for extension, but closed for modification
Importance
Extensibility new features can be added without modifying existing code
Stability reduces the risk of introducing bugs when making changes
Flexibility adapts to changing requirements more easily
Liskov substitution principle
states that functions that use pointers or references to base classes must be able to use pointers or references of derived classes without knowing it
Importance
Polymorphism enables the use of polymorphic behavior, making code more flexible and reusable
Reliability ensures that subclasses adhere to the contract defined by the superclass
Predictability guarantees that replacing a superclass object with a subclass object won't break the program
Interface segregation principle
states that clients should not be forced to depend upon interface methods that they do not use
Importance
Decoupling reduces dependencies between classes, making the code more modular and maintainable
Flexibility allows for more targeted implementations of interfaces
Avoids unnecessary dependencies clients don't have to depend on methods they don't use
Dependency inversion principle
states that one should depend upon abstractions, not concretes
Importance
Loose coupling reduces dependencies between modules, making the code more flexible and easier to test
Flexibility enables changes to implementations without affecting clients
Maintainability makes code easier to understand and modify
...
CUPID
Composable
plays well with others through a small surface area, minimal dependencies, and clear intentions
Unix philosophy
focuses on doing one single thing exceptionally well with a simple, consistent model
Predictable
behaves exactly as expected by being deterministic, transparent, and free of hidden side effects
Idiomatic
feels natural to use within the chosen programming language, ecosystem, and team conventions
Domain-based
models the solution structure and vocabulary directly after the real-world problem domain
GRASP
General Responsibility Assignment Software Patterns (or Principles), abbreviated
GRASP, is a set ofnine fundamental principles in object design and responsibility assignment: 6 first publishedby Craig Larmanin his1997bookApplying UML and PatternsInformation Expert
related Pattern or Principle:
Low CouplingHigh CohesionCreator
related Pattern or Principle:
Low CouplingFactory patternsController
related Pattern or Principle:
Command,Facade,Layers,Pure FabricationIndirection
Low Coupling
High Cohesion
Polymorphism
Protected Variations
Pure Fabrication
related Patterns and Principles:
Low CouplingHigh Cohesion...
SOLID
Software engineer and instructor
Robert C. Martinintroduced the basic principles ofSOLID designin his2000paperDesign Principles and Design Patternsabout software rotThe SOLID acronym was coined around 2004 by Michael Feathers
Single-responsibility principle
states that there should never be more than one reason for a class to change. In other words, every class should have only one responsibility.
Importance
Maintainabilitywhen classes have a single, well-defined responsibility, they're easier to understand and modifyTestabilityit's easier to write unit tests for classes with a single focusFlexibilitychanges to one responsibility don't affect unrelated parts of the systemOpen–closed
principle states that software entities should be open for extension, but closed for modification
Importance
Extensibilitynew features can be added without modifying existing codeStabilityreduces the risk of introducing bugs when making changesFlexibilityadapts to changing requirements more easilyLiskov substitution principle
states that functions that use pointers or references to base classes must be able to use pointers or references of derived classes without knowing it
Importance
Polymorphismenables the use of polymorphic behavior, making code more flexible and reusableReliabilityensures that subclasses adhere to the contract defined by the superclassPredictabilityguarantees that replacing a superclass object with a subclass object won't break the programInterface segregation principle
states that clients should not be forced to depend upon interface methods that they do not use
Importance
Decouplingreduces dependencies between classes, making the code more modular and maintainableFlexibilityallows for more targeted implementations of interfacesAvoids unnecessary dependenciesclients don't have to depend on methods they don't useDependency inversion principle
states that one should depend upon abstractions, not concretes
Importance
Loose couplingreduces dependencies between modules, making the code more flexible and easier to testFlexibilityenables changes to implementations without affecting clientsMaintainabilitymakes code easier to understand and modify...
CUPID
Composable
plays well with others through a small surface area, minimal dependencies, and clear intentions
Unix philosophy
focuses on doing one single thing exceptionally well with a simple, consistent model
Predictable
behaves exactly as expected by being deterministic, transparent, and free of hidden side effects
Idiomatic
feels natural to use within the chosen programming language, ecosystem, and team conventions
Domain-based
models the solution structure and vocabulary directly after the real-world problem domain