This repository is made in the context of a Software Architecture Course by Dr. Lilia Sfaxi
This is our lab report. It was made by:
- Raed Addala @RaedAddala
- Mohamed Aziz Ben Ghorbel @AziizBg
- Zied Maghraoui @ZiedMaghraoui
- Mohamed Zouaghi @zouaghista
Following the SRP, we refactored the classes found in ./SRP/src/exercise into ./SRP/src/exercise_refactored.
We split CarManager class into CarManager and CarRepository where the later will handle CRUD operations to the Database (in-memory database).
Here is the old classes diagram UML:
Here is the new classes diagram UML:
- Following the OCP, we refactored the classes found in
./OCP/src/exerciseinto./OCP/src/solution. - We added an abstract class
Slotand two concrete classesTimeSlotandSpaceSlotthat inherit fromSlot. - We removed the checks for the type of the slot in the
ResourceAllocatorclass and used the abstract classSlotinstead. - We also added a new method
findFreeSlotto theResourceAllocatorclass that will return the first free slot it finds in the list of slots using theisFreemethod of theSlotclass. Here is the old classes diagram UML:
Here is the new classes diagram UML:
Following the LSP, we refactored the classes found in ./LSP/src/exercise into ./LSP/src/exercise_refactored.
Instead of having ElectronicDuck inherit from Duck, we extracted the quacking and swimming behavior into the IDuck interface, we also created a DuckFactory class which will handle duck initialization.
Here is the old classes diagram UML:
Here is the new classes diagram UML:
We split the Door interface into IDoor,ITimed and ISensing to prevent classes from implementing methods that they do not have a use for.
This also improves the reusability and semantics of the interfaces: a door doesn't need to be timed nor sensing. As for the implementing classes it falls to them to implement all the needed interfaces without unnecessary method overrides.
- Following the DIP, we refactored the classes found in
./DIP/src/../exerciseinto./DIP/src/../solution. - We introduced two interfaces:
IReaderfor reading input from various sources (e.g., files, network).IWriterfor writing encoded output to different destinations (e.g., files, databases).
- We implemented
IReaderandIWriterwith the following concrete classes:FileReaderModule(reads from files).NetworkReaderModule(fetches data from a URL).FileWriterModule(writes encoded data to a file).DatabaseWriterModule(stores encoded data in a database).
- The
EncodingModulewas modified to depend on the abstractionsIReaderandIWriter, making it independent of specific data sources and storage mechanisms. - We removed direct dependencies on concrete classes like
BufferedReader,FileReader, andMyDatabase - This change makes the code more extensible, testable, and maintainable.



