- Introduction of Abstract Class: Added an abstract class between the model interface and concrete implementation class, moving methods from "ModelImplementation" to this abstract class without any code change. This approach enables code reuse by "FlexibleModelImplementation".
- Decision Against Inheritance: Inheritance was avoided due to the potential undesirable effects changes in the parent class could have on child classes, especially if a parent class has multiple child classes in scenarios involving more than one type of portfolio.
- Adoption of Command Design Pattern: The controller has been updated to the Command Design Pattern, making the code easier to maintain as new functionality and features are added.
- Switch Case Removal: The previous design's rapidly expanding switch case has been replaced, making the design more future-proof. The logic from the switch case has been moved to individual command classes.
- New Feature Interface: The general controller now implements a feature interface, accommodating both GUI-based and text-based views. This interface simplifies adding new views by implementing the feature interface.
- APIInterface
WebAPI
: Handles web API calls to the ALPHA VANTAGE API.
- FileInterface
FileAbstract
: Contains method definitions common to file interface implementations, such as create, write, delete, or clear a file.CSVFile
: Manages files in CSV format.
- ModelInterface
ModelAbstract
: Contains method definitions common to model interface implementations, facilitating operations like portfolio and share object creation and interaction with the File Interface.ModelImplementation
: Supports functionalities developed in the last assignment.FlexibleModelImplementation
: Supports functionalities needed by flexible portfolios, such as creating portfolios and buying & selling stocks.
Portfolio
: Represents a portfolio with a unique ID, creation date, and associated share objects.Share
: Represents a share with purchase date, company symbol/ticker, purchase price, and number of stocks bought.Periodicity
: An enum class defining possible filters for performance graphs.
- View
ViewImpl
: A view implementation that displays messages based on controller method calls, with no visibility of controller or model implementation.
- GUI View: Interface for GUI views.
- Various classes for different view functionalities and tabs.
ViewValidator
: A generalized validation file for views.
- Controller
ControllerImpl
: Implements controller interface, handling input from an InputStream object and output to a PrintStream object, interacting with the model based on user input.
- Features
GeneralController
: Designed for implementing GUI View, dynamically assigns action listeners in the view based on features from the interface.
The UML diagram shows a sophisticated use of design patterns that shape the architecture of the system:
- Utilizes a Template Method pattern through
ModelAbstract
, which defines the skeleton of the operations, leaving the details to be implemented by its subclasses. - Implements a Strategy pattern via
FileInterface
andFileAbstract
, allowing different file operation strategies to be used interchangeably.
- The Command pattern is employed through the
StockPortfolioCommand
interface, with various commands encapsulating the actions.
- A Bridge pattern is used by the
View
interface, decoupling the view's abstraction from its implementation. - The
ViewValidator
class represents a Facade pattern, providing a simplified interface for complex view validation logic.
- GUI components such as
HomeScreen
and various panel classes correspond to different screens or components in the GUI, organized to facilitate user interaction.
- Enumerations like
PortfolioType
andPeriodicity
standardize types and constants, ensuring consistency across the model.