-
Notifications
You must be signed in to change notification settings - Fork 10
Architecture
Robert C Martin talks about three concentric layers in software: domain model, use cases and user interface. The innermost layer is domain model. The middle layer is use cases; use cases depend on domain model and domain model does not know anything about use cases. Similarly, user interface is the outer most layer. Use interface knows about uses cases and not the other way round. So, when we port software across different views, we only need to change the user interface.
Above diagram illustrates the use case layer as a service layer. Both are synonyms.
To map these concepts to Autolabcli, we have the following.
- data source layer ---> missing
- model ---> missing
- service / use cases ---> lib/model
- user interface ---> lib/controller + lib/view
We have written use cases without having a coherent domain model. So if we look closely, we will find repetitive functionality among different use cases. So creating a coherent domain model will remove repetitive code from lib/model
.
Clear answers to our questions on architectural layering will come from reading the book: Eric Evans, Domain Driven Design.
If we carefully, observe init.js, eval.js, exit.js and prefs.js, we see the following patterns.
- In each controller, there is only one input module and one output module.
- All input modules export objects with only
getInput()
function. This function takes different messages in each controller. - All output modules export objects with only
sendOutput()
function. This function takes different messages in each controller.
Thus, we can think of view interface as a package (two modules) with the following interfaces.
//cli/input.js
getInput()
//cli/output.js
sendOutput()
Ideally though, we should have one view interface which has both input and output sections.
Class View {
getInput()
sendOutput()
}
Each of the views can implement the View interface and a controller can receive its' view object via constructor.
- Martin Fowler, anaemic domain models
- Service layer illustration
- Craig Larman's GRASP pattern
We can also use Inversion of Control frameworks like electrolyte or scatter or intravenous. But, IoC is not a favorite pattern among JS community, especially since JS is a dynamic language.
- Autolabcli v1.0.0 Docs
- Submission Workflow
- Architecture
- Refactoring Advice
- Feature Development
- Autolabcli Tests
- Events Doc
- Sequence Diagrams
- Testing in Javascript
- Libraries
- Debug Techniques
- Arrow Functions
- Autolabcli v0.1.1 Docs
- References