How pomozovalexander/astondreamteamproject works
Main Components
• Application Entry Points: The primary classes (App.java and LocalTestApp.java) that bootstrap the application. They handle the central loop of reading user input and orchestrating operations.
• Domain Models: The custom classes (Book, Car, RootVegetable) which represent the entities being sorted.
• Service Layer: Service classes (e.g., BookService, CarService, RootVegetableService) housed under the service package to manage business logic. The ServiceFactory plays a crucial role in assembling and providing the right service based on context.
• Strategy Modules: A set of interfaces and concrete implementations in the strategy package. These include:
• DataInputStrategy: Determines how input is gathered (CLI, file, or random).
• SortingStrategy: Houses the ShellSort implementation for generic arrays.
• OutputStrategy: For processing output, likely involving writing results to a file (as required by the additional task).
• SearchStrategy: Implements generic binary search functionality.
• ExitStrategy: Controls exiting the main application loop.
• Utility Modules: Organized in sub-packages:
• CLI utilities (e.g., BookArrayCLIBuilder, CarArrayCLIBuilder, etc.) for building command-line interfaces.
• File loader utilities to load data from JSON files.
• Finder utilities to perform binary search for each domain model.
• Generator utilities that randomly generate domain objects.
• Comparators and Sorting utilities (the sorter package) that provide various Comparator implementations to help with custom sorting on multiple fields.
• Resources: The input and results directories (inside src/main/resources) that store sample data and output files.
Relationships and Interactions
• Each Service uses a combination of Strategy implementations. For example, based on the user’s choice, the service selects an appropriate DataInputStrategy and SortingStrategy.
• The CLI utilities (in utils/cli) are used by the Application Layer for user interactions.
• File loader, generator, and finder utilities provide supporting functions and are invoked by both services and strategies.
• The comparators (under utils/sorter) are “plugged in” to the SortingStrategy (ShellSorter) as parameters to enable custom ordering.
• The binary search (a part of SearchStrategy) takes sorted collections (the result of ShellSort) and performs search operations.
Architectural Patterns and Design Principles
• Strategy Pattern: Every key operation (input, output, sorting, searching, exit) is encapsulated in its own strategy interface and concrete implementation.
• Generics: Sorting and search utilities are designed to work with any type of custom objects.
• Separation of Concerns: Clearly distinct layers for data models, business logic (services), strategies (algorithms/operations), and utilities.
• Reusability: Modular utilities (CLI builders, file loaders, comparators) are designed to serve different parts of the system without tight coupling.