T
thechaosengine
Hi everyone,
I've been having some discussions with collegues of mine as to what
constitutes an OO design. I don't have a very strong view but was wondering
what everyone else thinks. The two opposing view fell like this:
View 1
In order to be making OO software you should be instantiating lots of
objects and using static methods as little as possible. The people in this
camp believe that if you use static methods, even if those methods are named
after an "object" eg User, then you are essentially programming
procedurally.
For these people, you are only doing the OO thing when objects are getting
instantiated. They arent against static methods per'se, but avoid using them
where possible.
View 2
The notion that you have to instantiate an object in order to be working in
an object oriented manner is bollocks. A lot of the time, especially when it
comes to data access and testing business ruls it just isnt necessary to
instantiate an object. For example, to update a user's address, you could
instantiate an object with the new data and save it from there, or you could
call a static UpdateAddress method.
This camp isnt against instantiating objects. They do it when its useful to
deal with a collection of "things", like a group of users, or permissions or
projects etc, however they find that the opportunity for creating objects is
limited and often exagerated to the detriment of efficiency and perhaps
execution performance.
I'm somewhere in the middle of these two opinions but I've begun to notice
that a lot of the time, business layer classes, even though named after real
world entities, often consist of nothing more than groups of static methods
and little else. Often these classes don't even incorporate constructors.
What do you lot think?
Thanks all
TCE
I've been having some discussions with collegues of mine as to what
constitutes an OO design. I don't have a very strong view but was wondering
what everyone else thinks. The two opposing view fell like this:
View 1
In order to be making OO software you should be instantiating lots of
objects and using static methods as little as possible. The people in this
camp believe that if you use static methods, even if those methods are named
after an "object" eg User, then you are essentially programming
procedurally.
For these people, you are only doing the OO thing when objects are getting
instantiated. They arent against static methods per'se, but avoid using them
where possible.
View 2
The notion that you have to instantiate an object in order to be working in
an object oriented manner is bollocks. A lot of the time, especially when it
comes to data access and testing business ruls it just isnt necessary to
instantiate an object. For example, to update a user's address, you could
instantiate an object with the new data and save it from there, or you could
call a static UpdateAddress method.
This camp isnt against instantiating objects. They do it when its useful to
deal with a collection of "things", like a group of users, or permissions or
projects etc, however they find that the opportunity for creating objects is
limited and often exagerated to the detriment of efficiency and perhaps
execution performance.
I'm somewhere in the middle of these two opinions but I've begun to notice
that a lot of the time, business layer classes, even though named after real
world entities, often consist of nothing more than groups of static methods
and little else. Often these classes don't even incorporate constructors.
What do you lot think?
Thanks all
TCE