I came across a problem where I'm supposed to build a report for a company. The user first creates the company, then adds the employees and then generates reports based on employee data.
To solve this problem, I've created a singleton class for the company and all modifications (addition, removal and report generation for employs) is done using the single object created.
Now, suppose I've to extend this problem and create multiples companies and maintain multiple reports for all companies individually (no persistance, its a practice code to use OOPs efficiently).
The best solution I can come up with is, to create a hashmap of in the calling layer of the code.
For that I have to make necessary changes in the "Company" class of my code. (Constructor will accept name of company)
Everything else will be handled in the calling layer.
Is there any other efficient way to do this? Any OOPs principles that can be used efficiently or any design pattern that should be followed in such scenarios?
I'm relatively new to Object oriented programming and hence, I dont know the best way to go ahead
Aucun commentaire:
Enregistrer un commentaire