473,836 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object Oriented PHP

I am new to PHP, just one day new. But I am otherwise a seasoned
programmer on many other languages like C, VB 6, C#, VB.NET, Win32
platform and have some tiny bit experience in MFC, C++, Python.

All the tutorials I read so far about PHP contain procedural examples.
I haven't yet come accross a tutorial on the object oriented PHP. Could
someone point me to one?

Jun 17 '06
73 4522

"Tim Van Wassenhove" <ti***@users.so urceforge.net> wrote in message
news:e7******** **@ikaria.belne t.be...
On 2006-06-25, David Haynes <da***********@ sympatico.ca> wrote:
PHP5 has weak polymorphism but not true polymorphism in the sense that
it is used in OOP.


So how would you define polymorphism? And what exactly are the
differences between 'weak' and 'true' polymorphism?

If i look at
http://en.wikipedia.org/wiki/Polymor...ter_science%29

"The concept of polymorphism applies to data types in addition to
functions. A function that can evaluate to and be applied to values of
different types is known as a polymorphic function.


Exactly! Same interface, different implementation.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Jun 25 '06 #31

"David Haynes" <da***********@ sympatico.ca> wrote in message
news:pR******** **********@fe43 .usenetserver.c om...
Tony Marston wrote:
"David Haynes" <da***********@ sympatico.ca> wrote in message
news:Tv******** ***********@fe2 6.usenetserver. com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
> Actually, things like private declarations are very important. They
> are unimportant only to those who don't understand OO programming - or
> those who are sloppy in their implementations .
You don't *need* private declarations. Code will work just as well
without them.

What the heck! Let's just throw away multiply and divide. We don't
*need* them. We can just use add and subtract.

Heck! Why do we need subtract? We can just add negative values.

Hey! Assembler works well without private declarations. Let's just pitch
PHP all together.

The point is that constructs are added to language to assist in the
functionality and maintainability of programs written in that language.
The introduction of private and protected adds to the maintainability
both through its inherent protection capabilities and its clarity of
intent for the maintainer.

Now if PHP could just get polymorphism...
OOP with PHP already has polymorphism. You obviously don't know what
polymorphism means.

Tony:

PHP5 has weak polymorphism but not true polymorphism in the sense that it
is used in OOP.

You cannot, for instance, have multiple constructors for an object where
the number of the arguments to the constructor are variable. Yes, you may
supply default values to 'optional' arguments but consider this example:

class Foo {
function __construct($on e, $two="two", $three="three") {

I cannot instantiate this object as new Foo($one, $three) since there is
no typing on the arguments and, therefore, no signature for a 'one, three'
contructor. Nor could I define multiple __constructor() methods to allow
for the new Foo($one, $three) case.


Polymorphism means "same interface, different implementation" . It has
nothing to do with overloading.
This type of action is common in other OOP languages such as Java and C++.
Just because those languages have to employ a certain mechanism to achieve a
certain result does not mean that EVERY language has to employ the same
mechanism to achieve the same result. Different languages work differently,
so you should expect different languages to achieve similar results with
different techniques. If everything was the same there would be no need for
different languages, would there?
To add to the confusion from an OOP programmer's viewpoint, in order to
invoke the 'default' value for $three, I *must* supply a value for $two.
That is, new Foo($one, , $three) is syntactically illegal and there is
AFAIK no way to specify that we want $two to take its default value while
supplying a value for $three.

So, maybe its not me who is unclear on the concept of polymorphism...


I repeat, overloading has nothing to do with polymorphism.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Jun 25 '06 #32
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:l7******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:4K***** *************** **********@comc ast.com...
David Haynes wrote:
>Jerry Stuckle wrote:
>

< snip >

I really don't know how hard it would be to add - but I would like to see
it added. One thing I don't like all that much is the untyped variables.
It makes things "easy" - but leads to some sloppy programming.

It also means you can't overload functions - at least not with the same
number of parms. Typing the constructor arguments is a good start. But
expanding that to other functions without breaking existing code might be
more difficult.
You don't need function overloading in PHP. Why? First you need to look
at why other languages need it:
(a) To accept arguments of different types.
(b) To make some arguments optional.

With PHP you can accept an argument of any type and then cast it to the
one you want, so item (a) is irrelevant.

With PHP you can define a default value for an argument if it is not
supplied, so item (b) is irrelevant.


Sure. I would love to be able to have a function which does different
things based on the type of parameter passed. It would save a lot of work
trying to sort out parameters and potentially having to change existing
code when adding new parameter types.

But we already know you don't understand or appreciate real OO
programming , Tony. So quite frankly, I don't give a damn what you think.

Just because my understanding and implementation of OOP is different from
yours does not make you right and me wrong.


Other than the fact your understanding and implementation is different from
every expert in the field.

You *think* you understand OO. But you have no idea what *real* OO is about.
Otherwise you wouldn't be making some of your comments.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 25 '06 #33
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

No, Tony, you really don't know what polymorphism is, do you?

The simplest definition of polymorphism is "same interface, different
implementation" . This means that different objects can share the same
interface but which do different things. What do you think it means?


I rest my case.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 25 '06 #34

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:cY******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
<snip>
Just because my understanding and implementation of OOP is different from
yours does not make you right and me wrong.

Other than the fact your understanding and implementation is different
from every expert in the field.


What you mean is that people who think like you are the so-called *experts*
while those who choose to think differently are *idiots*. What an arrogant
pratt you are to think that YOUR brand of OO is the only true brand.
You *think* you understand OO. But you have no idea what *real* OO is
about. Otherwise you wouldn't be making some of your comments.


OO is about encapsulation, polymorphism and inheritance. Nothing more,
nothing less. What you choose to call *real* OO I call *bastardised* OO
because some people of low intelligence are trying to make it more difficult
than it really is.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Jun 25 '06 #35

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:ms******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

No, Tony, you really don't know what polymorphism is, do you?

The simplest definition of polymorphism is "same interface, different
implementation" . This means that different objects can share the same
interface but which do different things. What do you think it means?


I rest my case.


Without answering the question, I notice. Is it too difficult for you? I
take my definition from http://c2.com/cgi/wiki?PolyMorphism and
http://en.wikipedia.org/wiki/Polymor...mputer_science) Where did you
get yours? The toilet?

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Jun 25 '06 #36
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:cY******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

<snip>
Just because my understanding and implementation of OOP is different from
yours does not make you right and me wrong.

Other than the fact your understanding and implementation is different
from every expert in the field.

What you mean is that people who think like you are the so-called *experts*
while those who choose to think differently are *idiots*. What an arrogant
pratt you are to think that YOUR brand of OO is the only true brand.


My understanding comes from people like Grady Booch, James Rumbaugh and Ivar
Jacobson - and is in complete agreement with these people. But of course, they
disagree with you, so you'll call them idiots, also.
You *think* you understand OO. But you have no idea what *real* OO is
about. Otherwise you wouldn't be making some of your comments.

OO is about encapsulation, polymorphism and inheritance. Nothing more,
nothing less. What you choose to call *real* OO I call *bastardised* OO
because some people of low intelligence are trying to make it more difficult
than it really is.


Also message passing - which you seem to conveniently forget. And YOU are the
one "bastardizi ng" OO. Your sloppy approach to programming is just what *real*
OO is designed to eliminate. And it makes the coding much more maintainable,
expandable and modifiable.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 25 '06 #37
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:ms******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

No, Tony, you really don't know what polymorphism is, do you?
The simplest definition of polymorphism is "same interface, different
implementati on". This means that different objects can share the same
interface but which do different things. What do you think it means?


I rest my case.

Without answering the question, I notice. Is it too difficult for you? I
take my definition from http://c2.com/cgi/wiki?PolyMorphism and
http://en.wikipedia.org/wiki/Polymor...mputer_science) Where did you
get yours? The toilet?


No need to answer your question. You're "definition " speaks for itself.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 25 '06 #38

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:ce******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:ms******** *************** *******@comcast .com...
Tony Marston wrote:

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

>No, Tony, you really don't know what polymorphism is, do you?
The simplest definition of polymorphism is "same interface, different
implementat ion". This means that different objects can share the same
interface but which do different things. What do you think it means?
I rest my case.

Without answering the question, I notice. Is it too difficult for you? I
take my definition from http://c2.com/cgi/wiki?PolyMorphism and
http://en.wikipedia.org/wiki/Polymor...mputer_science) Where did
you get yours? The toilet?


No need to answer your question. You're "definition " speaks for itself.


You mean that the definition I use is correct while yours is a pile a poo?

My definition is shared by experts. Your definition is shared by people who
think they're experts.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Jun 25 '06 #39

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:ce******** *************** *******@comcast .com...
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:cY******** *************** *******@comcast .com...
Tony Marston wrote:

"Jerry Stuckle" <js*******@attg lobal.net> wrote in message

<snip>
Just because my understanding and implementation of OOP is different
from yours does not make you right and me wrong.
Other than the fact your understanding and implementation is different
from every expert in the field.

What you mean is that people who think like you are the so-called
*experts* while those who choose to think differently are *idiots*. What
an arrogant pratt you are to think that YOUR brand of OO is the only true
brand.


My understanding comes from people like Grady Booch, James Rumbaugh and
Ivar Jacobson - and is in complete agreement with these people. But of
course, they disagree with you, so you'll call them idiots, also.
You *think* you understand OO. But you have no idea what *real* OO is
about. Otherwise you wouldn't be making some of your comments.

OO is about encapsulation, polymorphism and inheritance. Nothing more,
nothing less. What you choose to call *real* OO I call *bastardised* OO
because some people of low intelligence are trying to make it more
difficult than it really is.


Also message passing - which you seem to conveniently forget.


OO is about encapsulation, polymorphism and inheritance. Message passing is
incidental.
And YOU are the one "bastardizi ng" OO. Your sloppy approach to
programming is just what *real* OO is designed to eliminate. And it makes
the coding much more maintainable, expandable and modifiable.


Not the way some people use OO. They deliberately make it more complicated
than it need be, while I keep it as simple as possible.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

Jun 25 '06 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1665
by: Benjamin C. Pierce | last post by:
The Twelth International Workshop on Foundations of Object-Oriented Languges (FOOL 12) Saturday 15 January 2005 Long Beach, California, USA Following POPL 05 The search for sound principles for object-oriented languages has given rise to much work on the theory of programming languages during the past two decades, leading to a better understanding of the key
5
2930
by: Martin | last post by:
When was inheritance intruduced into object oriented programming? More generally, does anyone know or have any sources on when the different features were introduced into object oriented programming?
34
7122
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
65
4304
by: Roger Smythe | last post by:
A means for the progressive decomposition a problem space into increasingly simpler component parts such that these component parts represent higher levels of conceptual abstraction, and are completely independent of each other except for their well-defined interfaces. This was an attempt to explain the gist of OOP to programmers accustomed to the structured programming paradigm. I tried to explain OOP in terms of ideals that can be...
14
2942
by: Rookie | last post by:
Is C an object oriented programming language?
100
5321
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
8
1805
by: cppig1995 | last post by:
C++ is not only object-oriented language. I think the description of this group have to be changed. :-) Have fun! ---- cppig1995 (cppig1995@gmail.com) Daejeon Metropolitan City, Republic of Korea 11 years old in Western age.
47
5973
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web site at http://ldeniau.web.cern.ch/ldeniau/html/oopc/oopc.html. The approach is very instructive. I know that I could do much of this stuff with e.g. C++, but the intellectual challenge of implementing these concepts with pure ANSI C is relevant to...
46
3042
by: ajba74 | last post by:
Hi fellows, I am reading some books to learn the C programming language, and sometimes I have the feeling that when somebody becomes a C expert, he must learn a more modern and object-oriented language. When I read things like "... C++ is an evolution of C ..." or "... C is a subset of C++ ..." I tend to believe that I will have to learn C+ + sooner or later. It sounds like C++ is the future and C is the past (and will be no longer...
3
1551
by: notnorwegian | last post by:
i have some confusion over this. sure a class is basically a classification, like for example an animal or flower. and an object/instance of that class is then for example a cat. an object is an instance of a class. that i know, i also know how to program with classes etc. i am just confused about the term object-oriented.
0
9811
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10822
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10532
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10577
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.