I Object – Part 1

i-objectI object to Object Oriented Programming(OOP).  When I started out, I learned BASIC.  It is amazing how a little command like GOTO can turn a couple hundred lines of code into nearly impossible to debug spaghetti.  This was procedural code.  It starts at the top and runs down to the bottom.  GOTO allowed you to jump from one area of code to another which is convenient but creates quite a jumble.  Some follow ups to BASIC eliminated the GOTO.  They required loops or functions to create these optional side paths.  This was less convenient but, in the end, created more coherent structure.

OOP required a change in thinking.  Treat parts of the code as if they were members of classes of real world objects with their own methods and properties.  For example, the object dog could have the method of bark() and the property of breed.  I can’t tell you how many times I have made the dog bark, the cat meow, and the cow moo (The object-oriented equivalent of echoing “Hello World!” to the screen).  I still have trouble wrapping my head around it.  At least at this point, I get why its important.  It makes your code more readable and understandable.  It creates scope ie avoids variables getting accidentally reused and screwed up and allows tasks to be easily broken down into parts when working in groups.   It allows code to be reused and built upon using inheritance.  With inheritance you can build up or down from a class as needs arise.  If I have a class of Car, I could create a more general class of Vehicle or a more specific class of Convertibles.

Although working with OOP is bit more involved and runs slightly more slowly, I think that the next time I work with PHP, I will try to use it.

About Robert

Robert is a novice web site developer. A lack of professional training has not prevented him from creating some very nice websites for small businesses who would otherwise have gone without a web presence.

Subscribe

Subscribe to our e-mail newsletter to receive updates.

No comments yet.

Leave a Reply