I have a number of different organisations, each of which is an instance of the Organisation
class. This contains getters and setters for instance variables, the setters contain validation where appropriate. It also has a few other odds and ends - overwritten toString(), equals()
and hashCode()
for example.
I have OrganisationView extends JFrame
which accepts an Organisation and displays it in the GUI, and includes listeners for the various functions.
I understand from this question how this should all fit together and work with OrganisationController
. What I'm not clear on is how many, if any, instances of OrganisationController
I need. Is it one per organisation, and storing the organisation it refers to as an instance variable? Because it seems easier just to declare OrganisationController
as static
and call its methods directly from OrganisationView
giving OrganisationView
a method something like:
private boolean deleteButtonPressed(){
return OrganisationController.deleteOrganisation(this.organisationDisplayed)
}
(and perhaps some other business logic, but that's by the by)
OrganisationView
, by the way, is called each time that particular display is needed, and is passed the organisation to show.
My question is: If it is better to have a separate instance of OrganisationController
for each Organisation
then why? It seems like an unnecessary amount of objects differing only in one instance variable. Or are static controllers acceptable?