Closed charlesgohck closed 6 years ago
A simple (may not be the best) approach is to replicate how the Command objects are given access to the Model. i.e. allow Commands to access Storage the same way they currently get access to Model
But should we access storage from logic, though? Is that better if we only need model to deal with storage directly?
But should we access storage from logic, though? Is that better if we only need model to deal with storage directly?
Those are two approaches, both widely used. Model ---> Storage
approach is also called the 'Active Record' approach in which the domain entities (i.e. the Model
) know how to persist themselves. The other approach takes the view that domain entities should not even know they are being persisted; a third party (in this case, Logic
) manages the job of reading/writing data.
You can take either approach as there is no clear winner. Both have pros and cons.
I had a method to set storage to the one from MainApp. So if I’m not wrong the passing of storage info is MainApp —> Logic —> Command.
Closing this issue. The solution is to declare a setter to set what you need in whichever object you need it.
Was wondering if someone can point me in the right direction. I'm trying to access the storage component via BackupCommand.java which extends Command. However I am only able to access the model and not the storage.
This is my implementation of Backup. https://github.com/CS2103AUG2017-W09-B2/main/pull/42/files