|
Posted by ELINTPimp on 08/24/07 19:02
On Aug 24, 2:43 pm, "Steve" <no....@example.com> wrote:
> | That being the case, I have some more specific inquires into the
> | group's and ElINT's opinion on OOP. It's possible I'm not fully
> | understanding the way you describe it, ELINT, so if I'm reiterating
> | what you've already said, I apologize in advance. The approach I might
> | take, is as follows:
> | My Product class which is a member of the Order class, of which I
> | mentioned in my OP, would be my parent class. My reasoning for this is
> | because the Product class is already used in so many other scripts, I
> | wouldn't feel entirely comfortable suddenly making it a child class of
> | some other super class.
>
> i *completely* disagree...you are not programming for your *comfort*. you
> program to get it correctly. you should have an *item* class implemented by
> product which will further be extended and used by the free product class.
> additionally - and the main reason you should *not* make the base class
> 'order' - your company could begin selling *services* and as far as billing
> goes, would be so similar in structure as 'product', you'd want to reuse the
> base that way. finally, since an 'order' consists of line 'items', you can
> use the 'item' interface to process the order (shipping, billing, inventory,
> etc.) without having to look at any other specific differences between the
> inheritors (product, free product, service).
>
> again, do it right so the code base is *sound*...don't avoid doing something
> because it is *uncomfortable*. the only reason to keep from refactoring
> completely is because of costs.
>
> but that's just my 0.02 usd
I think after analyzing his actual situation rather than what he was
actually trying to do in the first place, Jerry is on the right
track. For this particular situation, creating a superclass and
concrete child classes isn't necessary and would, in my opinion never
really be needed. His product class holds individual products
(despite the name, which makes it seem like it should be a parent
class for concrete product type classes).
I don't think anybody was saying OOP was a bad solution in this
situation, since they were still talking about using a array within an
class. If he uses the product class as an object-wrapper around the
array, it will would nicely (which is what I was getting at in my
pseudo-code.
The solution that both you and I offered up prior to Jerry re-
emphasizing the problem is a sound way to program, keeping your code
clean and ready for polymorphism. Only problem is that our solution
wasn't relevant to this situation. =)
Navigation:
[Reply to this message]
|