An Introduction to Object-Oriented Programming (1 of 5)

This is the first of five articles on object oriented-programming.

An Introduction to Object-Oriented Programming will give a brief overview of why there is such a thing as object-oriented programming. Conceptualizing Systems will help us to better picture a system in terms of objects and how the relate to each other. Planning an Application will teach us the importance of planning and what we should do to plan. Creating Objects explains how the objects in our application are born, and how they should be structured. Making Objects Reusable covers some more advanced topics and allows us to reuse what we’ve already created in good ways. My hope is that these Monday morning articles will help others through the transition from procedural programming to object-oriented programming.

Why Does Object-Oriented Programming Exist?

Back in the olden-days, way back when dinosaurs were young and our parents roamed the earth, there was programming. Yes, hard to believe it was invented by that time. Back then, things were simpler. Maybe people had to walk uphill both ways to school then, but programs were smaller, less complex. Programming languages executed line by line. They had “go-to” statements that let them go to another line for execution, and that was nice, but they didn’t need a whole lot anyway.

Industrialization came along however. Change was happening. Programs became more complex. It was hard to wrap the mind around a complex program and write it line by line. Procedural programming was born. Procedures or functions allowed a programmer to more easily conceptualize a system. It allowed them to reuse code. It was easier to program.

Object-oriented programming (OOP) came about the same way. When programs became larger and consequently more complex, it became very difficult to wrap one’s mind around them. Object-oriented programming made programming a system easier. It made life simpler again.

Function, Function, Who’s Got the Function?

Many times procedural programming is referred to as “spaghetti code.” Why is it called spaghetti code? Because there are functions being called throughout the system and we can’t know where they are coming from. If we follow the flow of a procedural program, we can find ourselves looping in and out of functions and throughout scripts very much like a bowl of spaghetti. There is not (inherently) much structure. There is not much organization. Object-oriented programming becomes more like building blocks we can build with instead of spaghetti. It provides organization and we can know exactly where a given function is. This also makes it easier to know where a bug is coming from.

What Does Object-Oriented Programming Allow Us To Do?

Object-oriented programming allows us to reuse code. It gives us a “package” of related functions and their related variables that we can pass around or reuse in other systems. These functions and variables that are all related are called methods and properties in an object. Object-oriented programming can also enable the use of complicated code by everyone. It not only ports the methods and properties together, but also allows us to use them without figuring out how they work internally.

When Should We Use Object-Oriented Programming?

Object-oriented programming was conceived to allow us to create larger projects more simply. Thus, it is very helpful in our larger projects that we do. I can also be nice in smaller projects, especially once we get the hang of it. Small projects are easily done in procedural programming though, and even once we learn how to program object-oriented we may still find ourselves using procedural at times.

Is it ok to mix objects with our procedural code? Of course! Many feel that if they are going to program object-oriented that they need to jump into the deep end and just start swimming. That is just not true. It would be much better to start using objects bit by bit, more and more, than to just not use them at all because we feel that it is too much for us. Also, for small scripts it may just be easier to do them procedurally.

So What Is Object-Oriented Programming?

Object-oriented programming is a way to think. To conceptualize a system or a program. It is not the classes, syntax, encapsulation, or other big words that we will learn about in following articles. The true purpose of OOP is the empowering it gives us to see our programs in a new light, a higher view, a clearer picture. It is hard to go back once you’ve had a taste.

16 Responses to “An Introduction to Object-Oriented Programming (1 of 5)”

  1. Nathan R. Garza Says:

    That was an exelent intro to object oriented programing!

  2. Andrew Says:

    Like a moth to a brite light I feel drawn to OOP as a result of this eloquent and very pursuasive introduction.

  3. joshbuhler.com » Intro to OOP Says:

    […] Part 1: An Introduction to OOP […]

  4. Jac Wright » An Introduction to Object-Oriented Programming (1 of 5) Says:

    […] An Introduction to Object-Oriented Programming (1 of 5) June 13th, 2005— Jacob Wright […]

  5. Jac Wright » Thinking Object-Oriented (2 of 5) Says:

    […] An Introduction to Object-Oriented Programming […]

  6. Jac Wright » Planning Systems (3 of 5) Says:

    […] An Introduction to Object-Oriented Programming […]

  7. Gary Matthew Rogers » Blog Archive » Object-Oriented Programming Says:

    […] Jacob Wright: Object-Oriented Programming […]

  8. Rekik Telayneh Says:

    Well, as computer science student it is represented breiflly and easly undestandable

  9. Utah PHP Users Group » Blog Archive » Creating objects (4 of 5) Says:

    […] In the previous three object oriented programming articles written for jacwright.com, we introduced object oriented programming, spoke of thinking about a system object oriented, and discussed the importance of planning, even if only in one’s head. The next two articles, Creating Objects and Reusing Objects, delve into the meatier subject of writing objects. We will be discussing how to implement the plans we’ve made and the systems we’ve conceptualized. Without these principles, object oriented programming can become a mess instead of a blessing. Encapsulate, Encapsulate, Dance to the Music (lyrics) […]

  10. John Holmen Says:

    Re: “[With functions] There is not (inherently) much structure. There is not much organization.”

    Reply: Perhaps you were just a bad procedural programmer. There are systematic ways to organize and “index” functions and modules. OO classes can be a sea of messy blobs and string also. You are painting with a hype brush, I feel.

  11. Flovi Thomas Says:

    I found the introduction very helpful. It is simple, lucid and has given me a fairly good image as to what OOP is all about.

  12. Shane Molinari Says:

    I can appreciate your knowledge-share and look forward to learning about OOP.

  13. Rimar John Elim Says:

    well i have learn more about Object Oriented Programming….

    thanks for this site….

    :)

  14. My Fantasy History/Tech Lesson | teachbygoofyaccent Says:

    […] object-oriented thinking has become integral to basic education. XCode is a mix of raw language and object-based programming that assesses and reinforces these […]

  15. Is this proper of using class to use divs Says:

    […] i found this link whhc may help An Introduction to Object-Oriented Programming (1 of 5) | Jacob Wright […]

  16. mg Says:

    m preparing a report on c++ and from last 5 hours m finding best for ma report .now dis article is really edifying.
    nyc work jacob.