On Jul 21, 1:37 pm, brian void <brian.voi...@gmail.com> wrote:
> Hi I'm new to programming and have some questions about classes.
You can learn OO concept using Java, but it may not be the
best option.
The problem is that Java makes it very hard on OO beginners by
providing two keywords to define an OO class: 'class' and
'interface' (similar -but not identical- to a C++ pure abstract
class).
With Java 'class', you only have single inheritance. With Java
'interface', you have multiple inheritance.
You can decide to live with it and model your OO hierarchy by
both extending concrete classes (and abstract classes) and
interfaces in your codebase.
But to me (and quite some others) this is a huge mistake: you'd
really be mixing two different things and mix up implementation
details with your OO model. Implementation details do not exist
at the OO-Analysis/OO-Design level.
First, I like to have a pure mapping from my OOD to my
Java interfaces. Then the translation OOD -> OOP is often
not possible using single inheritance.
Most people don't realize this, but it's because they hardly
do OO at all.
On the small codebase I'm working on at the moment
(6 digits LOC) every single class is 'final' and there
is not a single instance of the 'abstract' keyword. And
multiple inheritance is used everywhere. And we're doing
persistence using an OO DB
Anyway, you'll have people arguing that having the ability
to extend a concrete class is a good thing (even tough
James Gosling himself said he regretted "not having gone
pure interface") but...
You'll have way less people arguing that this is not
completely and utterly misleading for OO beginners.
So IMHO Java could have been both simpler and cleaner
by removing the 'abstract' keyword and by preventing
to 'extend' (Java) classes but I'm one of those few
that like the mathematical definition of the word
'elegant'.
(see my respond to markspace for yet another way to
do it, without ever extending any concrete class).