SOLID Principles

The Fractal Framework is built upon the SOLID principles of object-oriented design, which provide guidelines for writing clean, maintainable, and extensible code.

The five SOLID principles are:

  • Single Responsibility Principle (SRP)
  • Open/Closed Principle (OCP)
  • Liskov Substitution Principle (LSP)
  • Interface Segregation Principle (ISP)
  • Dependency Inversion Principle (DIP).

In the Fractal Framework, SRP is achieved by ensuring that each class has only one reason to change. This is accomplished by separating concerns and delegating responsibilities to other classes.

The OCP is achieved by designing modules that are open for extension but closed for modification, allowing new functionality to be added without modifying existing code to maintain backwards compatibility.

LSP is achieved by ensuring that derived classes can be used in place of their base classes without altering the correctness of the program.

ISP is achieved by separating interfaces into smaller and more specific ones, allowing clients to use only the methods they need.

Finally, DIP is achieved by depending on abstractions rather than concretions, allowing for more flexibility and easier maintenance.

LSP together with DIP is implemented with Hexagonal Architecture where the abstractions (interfaces) and business rules are defined in the core (domain) and the concretions are implemented on the edges of the application as adapters to the core. At runtime, adapters can be picked by dependency injection through environment variables. Since business logic is maintained in the core and not in the adapters, this complies with LSP.

By adhering to these SOLID principles, the Fractal Framework promotes good coding practices and ensures that software applications built on the framework are maintainable, flexible, and robust.