TP Flashcards
(21 cards)
The 4 components that does a bulk of the app’s work
- UI
- Logic
- Model
- Storage
What does the UI component do?
The UI component enables users to interact with the application by presenting information visually, capturing user input, and facilitating navigation and feedback within the software.
What does the Logic component do?
The command executor is a component that interprets and executes user commands, managing the interaction between the user interface and the application’s logic to perform desired actions based on user input.
What does the Model component do?
The Model component is responsible for storing and managing the application’s data in memory, enabling other components to access and manipulate this data during the application’s operation.
What does the Storage component do?
The Storage component is responsible for reading data from and writing data to the hard disk, ensuring that the application’s data persists between sessions.
Where is the functionality for each component defined?
Each of the main 4 components defines its API in an interface with the same name as the component. The functionality is in a concrete {ComponentName}Manager class which follows the corresponding API interface.
All UI components inherit from which abstract class?
UiPart
Which class does the UI component use to execute user commands with?
Logic
Which class does the UI component listen for changes to so that the UI can be updated with the modified data?
Model
Which class does the UI component keep a reference to?
Logic, in order to execute commands
Does the UI component depend on some classes in the Model component?
Yes, as it displays Person object residing in the Model
How does the Logic component work?
- When Logic is called upon to execute a command, it is passed to an AddressBookParser object which in turn creates a parser that matches the command and uses it to parse the command.
- This results in a Command object (more precisely, an object of one of its subclasses ie. DeleteCommand) which is executed by LogicManager.
- The command can communicate with the Model when it is executed (eg. to delete a person). This can take several steps
- The result of the command execution is encapsulated as a CommandResult object which is returned back from Logic
How does parsing work?
When called to parse a user command, the AddressBookParser class creates an XYZCommandParser which uses classes like CliSyntax etc to parse the user command and create a XYZCommand object, which the AddressBookParser returns as a Command object
What does the Model component store?
- The address book data ie. all Person objects (which are contained in a UniquePersonList object)
- The currently ‘selected’ Person objects (eg. results of a search query) as a separate filtered list which is exposed to outsiders as an unmodifiable ObservableList<Person> that can be 'observed' eg. the UI can be bound to this list so that the UI automatically updates when the data in the list changes.</Person>
- UserPref that represents the user’s preferences. This is exposed to the outside as a “ReadOnlyUserPref” object
Does the Model depend on any of the 3 components?
No, as the Model represents data entities of the domain, they should make sense on their own without depending on other components)
How is Tag stored?
There is a Tag list in AddressBook, which contains Tags, which Person references. This allows AddressBook to only require one Tag object per unique tag, instead of each Person needing their own Tag object.
What 2 things does the Storage component deal with?
- Address Book data
- User Preference data
How does Storage deal with AB data and UP data?
It converts them into JSON and stores them on the hard disk. When the app runs, it retrieves the saved JSON data and converts it back to objects that the program can use ie. AddressBook and UserPreference
What does the Storage component inherit from?
Inherits from both AddressBookStorage and UserPrefStorage, which means it can be treated as either one.
What does the Storage component depend on?
Depends on some classes in the Model component (because the Storage component’s job is to save/retrieve objects that belong to the Model)