I am currently working on a Angular application and exploring different design and methodologies to incorporate in my application. The goal is to follow and stick to the SOLID principles and on the same line I investigated MVP (Model-View-Presenter) pattern and as the pattern suggests, business logic and presentation logic must be handled differently. To be more precise, a smart component must interact with the outside world and can be dependent on services while it's child components have to remain dumb and rely on the parent component for the data. It also suggests to delegate user interactivity logic to a dedicated class called presenter which interacts with the presentational component(dumb). With the help of container and presenter we could achieve MVP pattern.
We could achieve the same design pattern using a directive as well in Angular. For instance, I have a component with a couple of buttons and when user clicks on a button the click event could be captured in a custom directive rather than using the component's code behind file.
So there's this question which is bothering me to take a call regarding the implementation.. Is it a good approach to use directives to separate the user interactivity logic or should I follow the MVP pattern ?
Aucun commentaire:
Enregistrer un commentaire