Re: Lahman, how ya doing?
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Sun, 08 May 2005 19:49:17 GMT
Responding to Hansen...
class EventElement { private: Object* recipient; int event_id; int tick_count; public: EventElement (Object* r, int e, int t) {recipient = r; event_id = e; tick_count = t;}; int getTickCount() {return tick_count;}; }
Let me ask you, why is this a class? I usually think of classes as something with member functions that do things with the data. I would have used a struct as a passive holder of data.
Objects abstract problem space entities in terms of knowledge and behavior. There is nothing in that definition requiring /both/ knowledge and behavior; they have equal stature but that doesn't require equal representation. So there is nothing to prevent pure data holders. In fact, most of the library classes one sees for the computing space are pure data holders (String, Array, Stack, etc., etc.). They have no behaviors that are relevant to the problem in hand; all the methods operate solely on the class' data in an manner that is defined outside the specific problem context.
There are other reasons for using classes rather than structs. Most entities that are important enough to abstract from the problem space will have relationships with other objects. The infrastructure for implementing, instantiating, and navigating the relationships has to live somewhere even though it is orthogonal to individual class semantics.
Also, the instance needs to be created, deleted, and manipulated. Why should that be done with different mechanisms for structs vs. objects? Perhaps most important of all: what happens if requirements change and one needs to imbue the instance with behavior? That should be entirely transparent to any clients of the instance. It won't be if you have to convert a struct to a class.
************* There is nothing wrong with me that could not be cured by a capful of Drano.
H. S. Lahman hsl@xxxxxxxxxxxxxxxxx Pathfinder Solutions -- Put MDA to Work http://www.pathfindermda.com blog: http://pathfinderpeople.blogs.com/hslahman (888)OOA-PATH
.
- References:
- Re: Lahman, how ya doing?
- From: H. S. Lahman
- Re: Lahman, how ya doing?
- From: Gregory L. Hansen
- Re: Lahman, how ya doing?
- From: H. S. Lahman
- Re: Lahman, how ya doing?
- From: Gregory L. Hansen
- Re: Lahman, how ya doing?
- Prev by Date: Re: Lahman, how ya doing?
- Next by Date: Re: What EMF actually does?
- Previous by thread: Re: Lahman, how ya doing?
- Next by thread: Re: XP and Estimation
- Index(es):
Relevant Pages
|