Skip to content

Project Architecture Guidelines

Corvin Koegler edited this page Jun 11, 2024 · 1 revision

Current Architecture Diagramm

Project Architecture Guidelines

General Principles

  • Follow Existing Patterns: Adhere to the architectural patterns and principles found in established Squeak applications such as the System Browser and the MOTU app. This includes structuring your code in a way that is familiar to other Squeak developers.
  • Avoid Long Inheritance Chains: Keep inheritance hierarchies shallow. Deep inheritance chains can lead to fragile and hard-to-maintain code. Favor composition over inheritance where possible.
  • Law of Demeter: Adhere to the Law of Demeter (also known as the principle of least knowledge). Objects should only talk to their immediate friends and not to strangers. This reduces dependencies and increases modularity.
  • Clear Dependencies: Ensure that dependencies are explicit and well-documented. Avoid unexpected dependencies that can lead to tight coupling and make the codebase harder to maintain.

Specific Architectural Patterns

  • Events and Announcements: Use Squeak’s announcements framework for decoupled communication between objects. This promotes a flexible and modular architecture.

Example Applications

  • System Browser: The System Browser in Squeak is a powerful example of a well-structured application. It follows the MVC pattern, uses announcements for decoupled communication, and organizes code into meaningful packages.
  • MOTU App: The MOTU app demonstrates good practices in terms of modular design and clear separation of concerns. It uses service classes to manage complex operations and follows consistent naming conventions.

Additional Guidelines

  • Single Responsibility Principle: Ensure each class and method has a single responsibility or purpose. This makes the code easier to understand and maintain.
  • Open/Closed Principle: Classes should be open for extension but closed for modification. This means you should be able to add new functionality without changing existing code.
  • Dependency Injection: Use dependency injection to manage dependencies. This makes the code more flexible and easier to test.
  • Event-Driven Architecture: Where appropriate, use an event-driven architecture to promote decoupling and improve the scalability of your application.
  • Layered Architecture: Consider organizing your code into layers (e.g., presentation, application, domain, infrastructure) to promote separation of concerns and improve maintainability.