Software Architecture in Practice
Read this section to learn about the main elements, patterns, quality attributes, and principles of software architecture, including encapsulation, polymorphism, and dependencies. Pay attention to design patterns and their importance in software design.
5. SOLID Principles
1. Single responsibility principle - a class should only have one reason to change
2. Open-closed principle - classes should be open for extension but closed for modification
3. Liskov substution principle - objects should be replaceable by instances of their subtypes without altering the program
4. Interface segregation principle - no client should be forced to depend on methods, it doesn't use
5. Dependency inversion principle - modules should be dependent on abstractions and not details
Class Responsibilities
Sample responsibilities that a class can have
- Persistence - the process of saving data
- Validation - the process of validation data
- Error handling - handling errors gracefully or surfacing them
- Logging - runtime context of the application
- Class instantiation - creational design patterns
- Formatting - displaying relevant data
- Parsing - extracting information from data
- Mapping - translating data from one definition to another