1.2. Basic Principles and Concepts
Modularity and Abstraction
Modularity
Modularity is the degree to which a system's components may be separated and recombined. It involves dividing a system into smaller, independent parts that can be developed, tested and maintained separately.
Benefits of modularity:
Easier to understand and manage complex systems
Facilitates parallel development by different teams
Allows for easier updates and maintenance
Promotes reusability of components
Abstraction
Abstraction is the process of hiding the complex reality while exposing only the necessary parts. It helps in reducing complexity and allows you to focus on a general concept rather than specific implementations.
Levels of abstraction in system design:
Physical level: How data is actually stored
Logical level: What data is stored and relationships between data
View level: How the data is presented to end-users
Coupling and Cohesion
Coupling
Coupling refers to the degree of interdependence between software modules. Low coupling is desirable because it reduces the impact of changes in one module on others.
Types of coupling (from tight to loose):
Content coupling
Common coupling
Control coupling
Stamp coupling
Data coupling
Message coupling
Cohesion
Cohesion refers to the degree to which the elements inside a module belong together. High cohesion is desirable as it indicates that the module is focused on doing one thing well.
Types of cohesion (from low to high):
Coincidental cohesion
Logical cohesion
Temporal cohesion
Procedural cohesion
Communicational cohesion
Sequential cohesion
Functional cohesion
SOLID Principles in System Design
SOLID is an acronym for five design principles intended to make software designs more understandable, flexible, and maintainable.
Single Responsibility Principle (SRP)
A class should have only one reason to change
Promotes high cohesion
Open-Closed Principle (OCP)
Software entities should be open for extension but closed for modification
Encourages the use of interfaces and abstract classes
Liskov Substitution Principle (LSP)
Objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program
Ensures that inheritance is used correctly
Interface Segregation Principle (ISP)
Many client-specific interfaces are better than one general-purpose interface
Prevents classes from implementing unnecessary methods
Dependency Inversion Principle (DIP)
High-level modules should not depend on low-level modules. Both should depend on abstractions
Abstractions should not depend on details. Details should depend on abstractions
Promotes loose coupling
Applying these principles helps create systems that are more modular, flexible, and easier to maintain and extend over time.
Last updated