Re: sholud getters/ setters be inside interfaces?
Elhanan wrote:
i'm creating a domain model of an underwriting brief, the model must
regualr data (like nam,e age, sum etc..)
it's has been decided that the data collection will be developed in
anohter module by somone else, and he wanted only interfaces of all my
class so he wouldn't have to work with my actuall implemenations,
originally i wanted to use abstract classes with getters and setters,
with one implemenatin class they would use, (and maybe create with
factory)
i wanted that some of these classes may have interfaces defined to
them, interfaces that would specify behaviour concering attaching child
objects, and the abstract classes will implement them.
but they said it was not consistent, that they wanted to work only with
interfaces (even with value objects, like an object with only getters
and setters), and that they didn't want to work part of the time with
interfaces and part of the time with concret classes.
What happens when management dictates the development process.
Formally accessors and mutators represent attributes - they are a cover for
what would otherwise be public members. They go in a different box in a UML
class diagram from the behavioral methods.
That said, one could still define an interface for each value object class,
but that tells an interesting lie. The interface says, "Make as many
implementations of me as you want." The lie is that you really want one,
final class for most any entity. From a development standpoint it makes much
more sense to create value objects as concrete, final classes. Putting
accessors and mutators in an interface is formally equivalent to defining
members in interfaces, for which interfaces are not intended.
However, someone in your organization got it up their rear end that "designing
to interfaces" is a Good Thing, and they are going to shoehorn every aspect of
the job into that buzzword irrespective of sense or sensibility.
The problem is that it makes for a less clean design, unless you throw away
the interfaces before production.
Good luck.
- Lew