|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
Why Object oriented and why not
For some reason unknown to me, Every instructor at CS school seems to be an advocate of OO, in reality, there is no proof Object oriented programming is better or worse than procedural programming, Some of the best developers in the world prefer procedural over Object oriented, a nice example of those are the people who work on the Linux kernel, They use C (And not C++), and C does not support object oriented programming. The motive behind this is that these developers want to get every bit of power from the processor, the overhead in OO makes it not so suitable for Kernel Development knowing that they already do there own modular code organisation, but the Overhead is quite neglegible for almost every other area of programming. Some of the best above simply means that another elete group of programmers do prefer Object oriented, so there is no clear cut answer here. There is nothing you can do in an Object Oriented way that you can not do in a procedural program, the benefit is not to expand what you can do, since anything that you can do in Object Oriented can be done without it. So, if the guys that do there taxes in hexadecimal do not use it, why should i ? Well, unfortunatly, there is No Way to find out if Object Oriented is for you unless you learn a bit about it, i surely use it when i expect a program (Or PHP script) to grow very big, but when i write a simple script to migrate some DB tables to another, i don't. Now, let me tell you how Object Oriented works, with a real life anaolgy Let's say you have a garage full of things, some for the car and some computer parts, and some more stuff, you bring boxes and put all related things together, The boxes here are the objects, every box has a label. And you put the guidlines on how every kind of box is organised (The guidelines for a type of box is a class), Then let us say you give everyone in your home some responsibility over a box type, so when the car breaks down you call Samantha to bring you the stuff from that box (Since she knows how the box is organized), and when your need an old computer's hard drive, you call Jessica, she is the one that manages the computer parts box. Now, when you want to instruct Johnny to fix your computer when you are away, you don't need to tell him how to look for the part, you tell him to ask Jessica for the computer part, and you can go on with instructing him without having to teach both Johnny and Jessica how to get the parts from that box. More to that, when you decide on changing how things are organized in the computer parts box, only Jessica needs to know how things are re-organized, No one else needs to know. Please don't try to apply the analogy right away, this is the big picture of Object Orientation, it will not be evident right away, if you must know, Box organisation is called a CLASS, boxes are objects, and people in this analogy are methods of a class and client coders. You may ask, can i not do this with Functions, sounds like i can have a function responsible for every Box, and we get same results Well, Yes, but OO will give you more tools to do it, and it will be easier, especially when we have many computer boxes, all sharing the same organisation guidelines, But each having some more rules of its own. Ready to go into 3? NEXT: 03: Object Oriented Building Blocks
|
|||||||||||||||||||||||||
| XFREETUTORIALS.COM | ||||||||||||||||||||||||||