HTML Blox

Providing the building blox of the web.

  • HTML Blox Home
  • Blog
    • Design
    • Flash
    • General
    • HTML
    • Javascript
    • PHP
    • Programming
    • Web Servers
  • Forums
  • Where to Start?
  • Lessons
    • CSS
    • Design
    • HTML
    • Javascript
    • Programming
  • References
    • HTML
  • Resources
  • About
  • Contact
  • Go Green!

Programming Lessons

  1. Lesson 1: The Basics
  2. Lesson 2: A Brief History of Computers
  3. Lesson 3: The Workings of Computers
  4. Lesson 4: A Brief History of Programming
  5. Lesson 5: High-Level vs. Low-Level
  6. Lesson 6: Compiled vs. Interpreted
  7. Lesson 7: Variables
  8. Lesson 8.1: Arithmetic and Operators - Decimal
  9. Lesson 8.2: Arithmetic and Operators - Integer and Boolean
  10. Lesson 9.1: Conditional Statements - The Basics
  11. Lesson 9.2: Conditional Statements - Branching Conditionals
  12. Lesson 10.1: Loops - The Basics
  13. Lesson 10.2: Types of Loop
  14. Lesson 11: Functions
  15. Lesson 12: Strings
  16. Lesson 13: Procedural vs. Object-Oriented

Programming Reference

  1. No reference yet.

Links

  • W3C HTML 4.01 Strict Compliant
  • W3C CSS 2.1 Compliant
  • Web Standards Group Member
  • Follow us on Twitter
  • Number Overflow - Free Advanced Scripts and Tutorials
  • Azure Ronin Web Design - Professional Web Design and Development
  • XML Sitemap
  • U Comment, I Follow

Feeds

  • RSS 2.0 Feed
  • RDF/RSS 1.0 Feed
  • RSS 0.9 Feed
  • Atom Feed

Lesson 13: Procedural vs. Object-Oriented

del.icio.us Digg Blinklist reddit

In our previous lesson we discussed some of the common built-in functionality for Strings. In this lesson we are going to discuss the differences between Imperative, Procedural, and Object-Oriented programming.

What is Imperative Programming?

Imperative programming is the type of programming you do when you essentially just have a list of commands that work from the top down to the bottom, and then the program is complete. This means that it doesn’t have any functions or the like.

This type of programming is very simplistic, which makes it very difficult, time-consuming, and inefficient to do complex programs. This type of programming is often done in languages which have higher level functions only for very simple programs (most of the examples we’ve done are imperative).

There are no real programming “languages” which are strictly imperative without being procedural as well.

What is Procedural Programming?

Procedural programming is the type of programming you do when you make use of procedures (yet another synonym for functions, processes, and subroutines). This type of programming is higher-level than imperative and allows you to accomplish more complex programs. However, even procedural programming isn’t very effective when it comes to very large programs.

FORTRAN and C are two popular procedural programming languages.

What is Object-Oriented Programming (OOP)?

Object-oriented programming is the type of programming in which you make use of objects. Objects are essentially meant to be representative of a potentially physical object. Objects contain their own data and methods (another synonym for functions).

Object-oriented programming allows for the rapid development of larger scale programs. Instead of having to have all the commands in one location, you can break the code down into separate objects. This allows for much more manageable and readable code, which in turn allows for more efficient programming.

C++, Java, and PHP are popular object-oriented programming languages. You could consider Javascript to be an OOP language as well, though it doesn’t make use of the typical “class” as others do.

Which is Best?

Most computer programmers would immediately shout out “Object-oriented programming” when asked this question. However, a better answer is “It depends.”

As each language type progresses and becomes higher-level than the previous, there is also an inevitable addition of complexity as well as resource overhead (how much computer power the program needs to run).

Due to this addition of complexity and overhead, it is important to work with what is best. For example, the programs that power digital watches have to be very efficient because they run on very few resources. These would simply be too bogged down to work if it was done in an OO approach.

Likewise, say I wanted to test some input/output for a certain equation I’m considering using in a game. I could add a couple classes and functions to my game to force it to display this for me graphically, even though I’m going to just take it out a few minutes later. What is easier (and I often do), is just create a quick new program which just does this work for me in as simple terms as possible, and just outputs the results in text. I could do this in 5 minutes, whereas with the OO method it could take me an hour.

Now, I’m not saying OOP isn’t great. Quite the contrary, I love object-oriented programming and nearly everything substantial that I do is done in this manner. However, it’s important to realize that you shouldn’t needlessly over-complicate a very simple program.

OOP programs are best done for programs that meet one or more of these criteria:
- Are fairly large (more than a couple hundred lines of code) and will be run on general computers.
- Are fairly complex (more than just output simple data).
- Will be maintained and added to over a period of time.

There are other criteria and sometimes it’s a toss up. Most of the programs I do are OOP, but only if they warrant the extra complexity.


In this lesson we described and compared imperative, procedural, and object-oriented programming. In our previous lessons we have essentially covered all of the main points of procedural programming. In our next lesson we will begin to dive into object-oriented programming with the introduction of objects and classes.

This entry was posted on Saturday, November 14th, 2009 at 5:05 pm and is filed under Programming Lessons. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Please Login or Register or fill out the following to leave a reply:

If you haven't posted an approved comment before, your comment will not show up until approved.

  • HTML Blox Home
  • Blog
  • Design Blog
  • Flash Blog
  • General Blog
  • HTML Blog
  • Javascript Blog
  • PHP Blog
  • Programming Blog
  • Web Servers Blog
  • Forums
  • Where to Start?
  • Lessons
  • CSS Lessons
  • Design Lessons
  • HTML Lessons
  • Javascript Lessons
  • Programming Lessons
  • References
  • HTMLReferences
  • About
  • Resources
  • Contact
  • Go Green!
  • Sitemap

Copyright © 2008 HTML Blox

Unless otherwise noted, all images created and copyright HTML Blox.

Operated by Azure Ronin Web Design