Re: Best Coding Practice



On Aug 24, 2:43 pm, "Steve" <no....@xxxxxxxxxxx> 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. =)

.



Relevant Pages

  • Re: Best Coding Practice
    ... |> inheritors (product, free product, service). ... | concrete child classes isn't necessary and would, in my opinion never ... | I don't think anybody was saying OOP was a bad solution in this ... | array, it will would nicely (which is what I was getting at in my ...
    (comp.lang.php)
  • Re: Planet (Island) of Fire -- LIBTR/LBTR
    ... There is a natural law, ... "There may not be an 'I' in team, but there is an 'I' in Libertarian ... "Honesty Makes An Opinion Important, ... -- Thomas Paine, The Age Of Reason. ...
    (rec.arts.drwho)
  • Re: Todays Quote
    ... opinion, and I keep saying over and over that no one knows why Baha'u'llah ... there is no reason to address your opinions. ... mostly those of arbitration and ceremony. ... The Baha'i Faith has an administrative ...
    (talk.religion.bahai)
  • Re: Egalitarian Orthodoxy
    ... Marc Adler wrote: ... placed in an inferior position and the only possible reason they are ... opinion itself to be watered down. ... refuse to count my wife as part of the minyan, ...
    (soc.culture.jewish.moderated)
  • Re: Sue turning against Reed --
    ... you and I are allowed to have our own opinion. ... The pro-SRA side is the side that actually represents change. ... the Government ... Now that the Government actually has a GOOD REASON to go after the heroes, ...
    (rec.arts.comics.marvel.universe)