|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
What is Object Oriented, What are the advantages of Object Oriented programming, and why should i use it ? If you have never used a CLASS/Object, and don't know what inheritance means, Yet, you write perfectly functional code in PHP, you are programming in what is normally called Procedural Programming, Procedural programming is when you organise your code into functions, or even simply have it inline as a set of do this, loop there, if this then do that etc... Object Oriented programming is another way to organise your code (inside Classes), Your will still write functions (Inside classes), you will still use variables, but you will put them inside bigger blocks called classes. To give you a better idea of the difference, goleft() is a good name for a function (procedural), car on the other hand is a good name for a Class, a method (function) within the class car would be named goleft(). Object oriented code, and procedural code can co-exist, and it is not always bad to mix especially when you are altering old code to make it gradually Object Oriented Code In my oppinion, the most important thing you can acheive with OO is getting rid of duplication, Duplicate code means maintenance hell, when you update one area of your code, you will have to update all relevant areas. Inside classes, Functions get a new name (Methods), And variables get a new name as well (Properties) Functions = Methods So, it is not (Let us throw all the PHP we know in the bin and start from scratch), it is more like Let us reorganise our code, and start writing more organised code. NEXT: 02 - Why Object oriented and why not
|
|||||||||||||||||||||||||
| XFREETUTORIALS.COM | ||||||||||||||||||||||||||