Hi,
I have a factory method in a class "Country" which returns the appropriate object "Taxtable" depending on the year.
Another class is the Company, and the company can be in one country, therefore the Country object can be instantiated by the Company class.
In my code I instantiate the Country class like this, getting it from the company object which is always available (a singleton):
Country = Company.GetCountry()
Taxtable = Country.GetTaxtable(2011)
Now to make it easier to access, does it make sense to create another method in Company which returns the taxtable directly, so I don't need to go through the step to get the country first?
Taxtable = Company.GetTaxtable(2011)
And the Company class GetTaxtable method uses then the factory method in Country to return the taxtable to the caller.
Does this make sense, or does it break any rules of OOD?
I have a factory method in a class "Country" which returns the appropriate object "Taxtable" depending on the year.
Another class is the Company, and the company can be in one country, therefore the Country object can be instantiated by the Company class.
In my code I instantiate the Country class like this, getting it from the company object which is always available (a singleton):
Country = Company.GetCountry()
Taxtable = Country.GetTaxtable(2011)
Now to make it easier to access, does it make sense to create another method in Company which returns the taxtable directly, so I don't need to go through the step to get the country first?
Taxtable = Company.GetTaxtable(2011)
And the Company class GetTaxtable method uses then the factory method in Country to return the taxtable to the caller.
Does this make sense, or does it break any rules of OOD?