Re: Object Oriented PHP vs Java
From: Bruno Desthuilliers (bdesth.quelquechose_at_free.quelquepart.fr)
Date: 01/22/04
- Next message: Bruno Desthuilliers: "Re: Object Oriented PHP vs Java"
- Previous message: Tony Marston: "Re: Object Oriented PHP vs Java"
- In reply to: Agelmar: "Re: Object Oriented PHP vs Java"
- Next in thread: ChronoFish: "Re: Object Oriented PHP vs Java"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Jan 2004 12:45:27 +0100
Agelmar wrote:
> Bruno Desthuilliers wrote:
>
>>Savut wrote:
>>
>>>"Jerry" <weinstei@nova.edu> wrote in message
>>>news:69fca47c.0401211031.539ef63f@posting.google.com...
>>>
>>>
>>>>What are the advantages and disadvantages of using Object Oriented
>>>>PHP vs Java?
>>>
>>> >> PHP is not fully OO, even the PHP5... but Java is OO
>>>
>>As there is *no* commonly accepted definition of OO, I just dont
>>understand how you can claim such a thing.
>>
>>BTW, Smalltalkers could tell you why Java is not OO !-)
>
>
> Actually, there is a commonly accepted definition...
> OO implies:
> polymorphism, encapsulation, and inheritance.
Not so commonly accepted...
inheritence have two meanings :
- type/interface inheritence, which is about subtyping
- implementation inheritence, which is about code reuse
The first one doesn't make sens in a dynamically-typed language nor in
statically-typed-with-type-inference language (like OCaml). So it is
only useful for 'rigidly-typed' languages like Java and C++ - which BTW
are not 'pure' OOPLs (if this has any meaning) since they have
'non-object' types.
The second one is handy for code-reuse but can - and in many cases would
better - be replaced by composition/delegation.
Encapsulation largely predates OO and is of common use in procedural
(never wrote an ADT in C ?) and functional languages (ever heard of
closures ?).
Polymorphism is also independant of OO, and exists in procedural and/or
functional languages too.
So much for your 'commonly accepted definition', which doesnt define
anything IMHO : I just can't see how anyone could connect this with the
concept of objects that did not ever mentionned.
But dont take it wrong, I agree that these 3 concepts are commonly used
in OO and do have a meaning in a somewhat wider perspective.
What strikes me is that you missed the 2 real key points : objects, and
message passing with dynamic dispatch. OO is mostly and primarily about
things that we call 'objects' that have state and send messages to each
others. How some particular object react to a message depends on its
particular behavior and state.
And now this brings back the notions of encapsulation (each object carry
it's own state) and polymorphism (two different object can accept the
same message, each one reacting in it's own way).
The concept of 'type' could then be defined by the LSP : two objects
that accepts the same messages are of the same type. And the notion of
class could be defined in an almost mathematic way : a class is the set
of objects that a/ are of the same type and b/ have the same behavior
(which usually implies having the same internal structure when it comes
to implementation).
Note that inheritance has no particular meaning wrt this definition, and
so is only a code reuse facility in a dynamically typed language and a
'necessary evil' (no flame please) to support dynamic dispatch of
messages (ie polymorphism) in rigidly-typed languages.
<disclaimer>
Please note also that I would never pretend this definition being the
One And Only Revealed Truth(tm) about OO !-)
<disclaimer/>
My 2 cents...
Bruno
- Next message: Bruno Desthuilliers: "Re: Object Oriented PHP vs Java"
- Previous message: Tony Marston: "Re: Object Oriented PHP vs Java"
- In reply to: Agelmar: "Re: Object Oriented PHP vs Java"
- Next in thread: ChronoFish: "Re: Object Oriented PHP vs Java"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|