Question: I am trying to use the Singleton Pattern on repository classes, to make sure only one instance of each class is created. I have one
I am trying to use the Singleton Pattern on repository classes, to make sure only one instance of each class is created. I have one question and I will use the 'Item' Class on my UML as the example. Should I move the attributes and methods from my 'Item' class ( like itemNumber, getItemNumber(), setItemNumber() ) to my repository class? Since the repository class is the one creating the instance, I am thinking it would need to have those attributes and methods to create the Item, and then I would remove them from the 'Item' class. Any help or feedback is much appreciated!
Here is my UML:


ItemRepositery -item : Item -Item() +getltem(): Item +update() +insert() +fetch() \begin{tabular}{|l|l|l|} \multicolumn{1}{c|}{ Borrower } \\ -firstName: String \\ -lastName: String \\ -address: String \\ -city: String \\ - postalCede: String \\ -province: String \\ -number: int \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
