brunorplima / divino-dog-menu-app

Automated menu and order app for Divino Dog
divino-dog-menu-app.vercel.app
0 stars 0 forks source link

25 encapsulate logic within models #26

Closed brunorplima closed 2 years ago

brunorplima commented 2 years ago

Resolves #25

Currently, there is some logic needed for creating a model instance that relies on the developer to remember to implement it when creating that instance. This is not a good practice. We want to encapsulate this logic within the model so we don't need to use them outside of the model, thus avoiding repeating code. The image below is an example of how we can instantiate a model: image In this example, we can see that we need to set the id using the utility generateID() function. We'll need to do that everytime we create an instance of a model, which is not good. Likewise, for the OrderModel we need to always implement codeNumber initialization outside of the model. This PR intends to change this design to a more reliable one in which the logic for creating these fields will be encapsulated within the model. Only the necessary data (the one can't be created within the model) will be required to be entered to create an instance. This is what we achieved with this PR: image image

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
divino-dog-menu-app ✅ Ready (Inspect) Visit Preview Apr 30, 2022 at 9:19AM (UTC)