Refactoring Holons Zome Module Structure #193
evomimic
started this conversation in
Design Discussions
Replies: 1 comment
-
After working through this re-factoring, some general guidelines have emerged that can be used as a guide to both the current layering and the placement of new modules in the appropriate layer. General Heuristic for Struct Placement in MAP's LayeredThese guidelines help maintain modularity, avoid circular dependencies, and ensure clean separation of concerns. 1. Define Traits in API Layers
2. Place Structs/Enums in API Layers if:
3. Encapsulate Structs/Enums Behind Traits if:
4. Keep Concrete Implementations in Implementation Modules
5. Prefer Narrow Interfaces
6. Use Re-exports Judiciously
7. Ensure Uni-directional Dependency Flow
Example ApplicationShared Objects Layer
Reference Layer
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Explorations conducted as part of Issue #188 have led to a number of key insights and conclusions regarding how to restructure the MAP Holons Zome modules.
Summary of Key Architectural Findings
1. Separation of Concerns
HolonSpaceManager
,HolonCache
,Nursery
) and provides internal APIs for accessing and manipulating this state.shared_objects_layer::api
provides internal APIs for shared state management.reference_layer::api
offers external-facing traits likeHolonReadable
andHolonWritable
.2. HolonReference as a Central Abstraction
HolonReference
, along with its variants (StagedReference
,SmartReference
), mediates all access to holons in the shared objects layer.3. Consolidation of Implementation Logic
reference_layer::implementation
andshared_objects_layer::implementation
simplifies the architecture by:4. HolonsContext and Context Behavior
HolonsContext
is a pivotal structure for managing shared state during a request. Moving its definition to the shared_objects_layer::implementation aligns with its role in managing shared state.HolonsContextBehavior
trait inshared_objects_layer::api
achieves:HolonsContext
internals, exposing only the necessary methods for upper layers.reference_layer
from the concreteHolonsContext
implementation, preserving modularity and flexibility.5. Managing Relationships
RelationshipMap
andHolonCollection
structures, moved to the shared objects layer, now operate seamlessly withHolonReference
.HolonSpaceManager
.6. Stateless Server Design
HolonsContext
on each request in thedance_layer
.HolonsContextBehavior
to abstract shared state interactions, making the context easily reconstructible.7. Testing and Extensibility
HolonsContextBehavior
enables:HolonsContext
without breaking the reference layer.8. Simplification of Layer Responsibilities
HolonReadable
andHolonWritable
).dance_layer
orquery_layer
.Key Architectural Principles Reinforced
Holon
,HolonReference
, etc.) remains fully encapsulated in the shared objects layer, preventing direct access from upper layers.HolonsContextBehavior
decouples the reference layer from specific implementations, enabling future refactoring or extension.Challenges Addressed
HolonsContextBehavior
plays a pivotal role in breaking dependency cycles.HolonReference
and its traits encourages developers to follow the intended access patterns without requiring significant boilerplate or complexity.Final Thoughts
This conversation has clarified the architecture significantly, resulting in:
Beta Was this translation helpful? Give feedback.
All reactions