How genki-tx/unitysimplecleanarchitectureplane works
Project Type and Purpose
• This is a Unity application exemplifying the Simple Clean Architecture design pattern.
• The project is educational, showcasing a decoupled architecture that separates business logic (Entity and Usecase) from presentation (Presenter and View), using dependency injection (Service Locator pattern) and reactive programming (using C# EventHandler).
File Structure
• The top-level “Assets” folder contains subdirectories for Scenes, Prefabs, and Scripts.
• The DI mechanism is featured in files such as CounterDI.cs and PresenterDI.cs, which manage the creation and wiring of component dependencies.
• The directory separation clearly indicates an architectural enforcement, where each component type resides in its dedicated folder.
README Insights
• The README details each component’s responsibilities and rules (for example, what each can or cannot depend on or inherit from).
• It explains the use of a Service Locator design (in CounterDI.cs and PresenterDI.cs) to resolve dependencies, ensuring low coupling among components.
a. Main Components:
• Entity: Business data structures (e.g., Count.cs).
• Gateway: Data access interface (e.g., ICountDBGateway.cs, CountDB.cs).
• Usecase: Business logic layer that performs actions (e.g., CounterUsecase.cs, ICounterUsecase.cs).
• Presenter: Interfaces between the usecase and view (e.g., CountPresenter.cs, ICountPresenter.cs, PresenterDI.cs).
• View: Unity-specific UI components (e.g., CountButtonView.cs, CountTextView.cs, TotalNumberTextView.cs).
• Additionally, include the Dependency Injection components (CounterDI.cs and PresenterDI.cs) that orchestrate the initializations.
b. Relationships and Interactions:
• From View to Presenter: Views call methods on the Presenter's interface.
• From Presenter to Usecase: Presenters invoke business logic via the Usecase interface.
• From Usecase to Gateway (if needed): Usecases access data through Gateway interfaces.
• Entities should be represented as the core business models accessed and acted upon by the Usecase.
• DI system (Service Locator) which creates instances and wires all the above components. Represent these with a centralized “DI Container” node that provides the component connections.
c. Architectural Patterns and Design Principles:
• Loose coupling enforced by having each layer depend only on its listed allowed dependencies.
• That UIView components inherit from Unity’s MonoBehaviour while the core logic (Entity, Usecase, and Gateway) do not.
d. Technologies and Libraries:
• That this project is contained within the Unity GameEngine.
• Mention that only standard C# libraries for EventHandler-based reactive programming are used.
• That no external frameworks or 3rd party DI libraries are used in this simplified example.
Final Advice
• Avoid over-generalization—be as specific as possible using the project’s file structure and component names.