PDA

View Full Version : OOP



Dentafrice,
06-09-2007, 11:38 PM
I am starting to work alot with OOP (Object oriented programming).

I am not sure exactly what to make to extend my knowledge of PHP.

If you have any ideas of things you may want tell me.

I still don't know THAT much about OOP but I am hoping to learn.

Caleb.

Lambda
07-09-2007, 12:23 AM
Are you hoping to learn OOP theory? If so PHP is not the language to do it in, its OOP support sucks. If you're only wanting to learn OOP in practice you should at the very least study its (dis)advantages.

Sometimes choosing a paradigm over another can be a good design choice, or not.

Dentafrice,
07-09-2007, 01:00 AM
No, I am wanting to continue my knowledge of PHP with OOP.

C# i have heard is a good language for what you said

Lambda
07-09-2007, 01:25 AM
No, I am wanting to continue my knowledge of PHP with OOP.

C# i have heard is a good language for what you said

If PHP's OOP support is as terrible as everyone says it is, there may not be a point to writing that way.

C# isn't bad for OOP. I wouldn't use it to learn theory, though.

Dentafrice,
07-09-2007, 02:00 AM
Tbh, I have only been working with the basics.

I like it, I find it way easier and cuts down loads on work.

Tomm
07-09-2007, 07:01 AM
OOP in PHP is great.. what the hell are you talking about? PHP4 has OOP support, but you really need to use PHP5 to get full OOP support.

Also just using classes does not make your project OO. Your classes should be designed in such a way that it can do its stuff transparently to the script using it, you should learn about polymorphism. The main advantage to using OO is that your objects should become independent of your project (As long as you use loose coupling).

Example of polymorphism (Language independant):

You want to read a file containing some sort of data but that data could be in more than one file type. Lets say we want to be able to parse XML and some other format (.myconfig for this example). The program creates a new "reader" object and give it the file (XML or .myconfig), then the reader object, using polymorphism, makes a desision on if the file is XML or .myconfig and returns the appropriate class (XMLReader and ConfigReader). Both classes have the same functions and as far as the program is concerned it just loaded a reader class. This is an example of polymorphism. Not only does this make you script loosely coupled you can easily add other readers for different file types without extensive modification.

Lambda
07-09-2007, 12:10 PM
OOP in PHP is great, yet it was included as an afterthought? I'm sorry, you may think it's great, but considering you're coding in PHP I'm not going to take your word over the thousands of others who study computer science and languages and call PHP meager.

Your game is web development, mine is computer science and programming.

Tomm
07-09-2007, 03:19 PM
Jesus, you are really starting to annoy me. If PHP is meager why is it used by companys such as Yahoo over coding a custom C++ system? PHP was included as an afterthought in PHP4 but in PHP5 one of its main elements was OOP. The OOP in PHP4 was okay but the OOP support in PHP5 is a vast improvement. Sure it may no compare to OOP languages such as Java where there is total focus on OOP, but then again PHP is not a pure OO language.

Plus PHP is a web-language, its not support to be used for creating desktop applications so its not going to have all the power of C# or C++ is it? PHP is, as far as I am concerned, the best web programming language (That is designed to execute on web servers for the purpose of serving webpages with dynamic content). For the following reasons:

Opensource, so its free and has a large community that will help you.
Cross-Platform/Web Server, unlike ASP or ASP.net that will only run on IIS servers running Windows Server 2003 (Exception of ASP that has a 3rd party module for Apache)
Large extension repository
PHP is becoming used more and more by enterprise organizations because of the power of the language and the fact it's opensource and free.Plus my "game" is not web development, sure I do web development but I also do development for desktop applications and I also "do" computer science.

Lets take ASP.Net as a competitor. Why would I pick PHP over ASP.Net (Note: I have worked with ASP.Net before)? Well to start with, I would be limiting the server to a Windows platform. PHP (In my mind) is easier than ASP.Net and gets the job done faster. Lets say I wanted to setup a big website that would span multiple servers, I would have to buy licenses for each server - cost allot of money.

Plus whom are these thousands of others who call PHP meager that you refer to?

PHP currently has over 20,000,000 (Yes, 20 million) sites currently using it, so I guess that they all must be doing something wrong?

Also do a google search for PHP script then try another language such as ASP.Net or ColdFusion (Have a guess what you might think you'll find).

Got my point?

Thanks,

Tom


OOP in PHP is great, yet it was included as an afterthought? I'm sorry, you may think it's great, but considering you're coding in PHP I'm not going to take your word over the thousands of others who study computer science and languages and call PHP meager.

Your game is web development, mine is computer science and programming.

Dentafrice,
07-09-2007, 03:21 PM
Wow Tom, owned xD +REP

Lambda
07-09-2007, 03:59 PM
Jesus, you are really starting to annoy me. If PHP is meager why is it used by companys such as Yahoo over coding a custom C++ system? PHP was included as an afterthought in PHP4 but in PHP5 one of its main elements was OOP. The OOP in PHP4 was okay but the OOP support in PHP5 is a vast improvement. Sure it may no compare to OOP languages such as Java where there is total focus on OOP, but then again PHP is not a pure OO language.

Plus PHP is a web-language, its not support to be used for creating desktop applications so its not going to have all the power of C# or C++ is it? PHP is, as far as I am concerned, the best web programming language (That is designed to execute on web servers for the purpose of serving webpages with dynamic content). For the following reasons:
Opensource, so its free and has a large community that will help you.
Cross-Platform/Web Server, unlike ASP or ASP.net that will only run on IIS servers running Windows Server 2003 (Exception of ASP that has a 3rd party module for Apache)
Large extension repository
PHP is becoming used more and more by enterprise organizations because of the power of the language and the fact it's opensource and free.Plus my "game" is not web development, sure I do web development but I also do development for desktop applications and I also "do" computer science.

Lets take ASP.Net as a competitor. Why would I pick PHP over ASP.Net (Note: I have worked with ASP.Net before)? Well to start with, I would be limiting the server to a Windows platform. PHP (In my mind) is easier than ASP.Net and gets the job done faster. Lets say I wanted to setup a big website that would span multiple servers, I would have to buy licenses for each server - cost allot of money.

Plus whom are these thousands of others who call PHP meager that you refer to?

PHP currently has over 20,000,000 (Yes, 20 million) sites currently using it, so I guess that they all must be doing something wrong?

Also do a google search for PHP script then try another language such as ASP.Net or ColdFusion (Have a guess what you might think you'll find).

Got my point?

Thanks,

Tom

Ever so pointless, I didn't deny any of that. PHP is one of the best rounded solutions to web development, which I have not denied, although I prefer other languages to PHP for a backend. I have not argued against anything you have mentioned; what you have neglected to mention and what I have argued against is PHP's value from the perspective of semantics and design. As it stands PHP is not as well designed as many solutions that fill the same niche and other.

I apologize for any misunderstandings here, because that is evidently what has happened. I am not criticizing PHP in real practice, just in the study of theory, where your points have no merit.

Eccentric
07-09-2007, 04:26 PM
OOP is very easy to learn once you learn some bits its basically all the same BUT! its a little harder to learn than basic php tbh. :P but i gave in coz of lack of time i had its very intrestin.

Dentafrice,
07-09-2007, 04:29 PM
It is :) I love using classes now, makes things md5("6000000000000000000"); times easier

Eccentric
07-09-2007, 04:31 PM
Yes. :) gl

Lambda
07-09-2007, 04:47 PM
http://www.geocities.com/tablizer/oopbad.htm
http://www.devx.com/opinion/Article/26776/0

You can find some good books on tech review sites. A Smalltalk book is nice way to learn, or a book on paradigms and design patterns.

Tomm
08-09-2007, 07:54 AM
If you are intrested in OOP with PHP then I recommend the book:

"PHP5 Objects, Patterns, and Practice" by Matt Zandstra (Apress publishing).

Dentafrice,
08-09-2007, 12:24 PM
I will look for it at the bookstore next time I am there :0

Want to hide these adverts? Register an account for free!