This blog is targeted at beginning / novice programmers for the Visual Basic (VB) language.

Saturday, March 24, 2007

What is Object-Oriented Programming (OOP) and why do you need it?

Object-Oriented Programming (OOP) is a concept used for programming. It is like a different way to look at things. The basic principle of OOP is that everything is either an object, a property to the object, or a method of the object. Before we can get into why you need OOP, you need to know a few other things first.

OOP originally was designed to provide an answer to a "software development crisis" in the 1960s. The problem was as the software was beginning to become more and more complex there was no methods around to ensure the quality was maintained. Introduce Object-Oriented programming concept. The concept is that every program contains "objects" and these "objects" would have properties and/or methods. (Notice the use of "and/or"; some objects can have both, or just one or the other). Objects would also be able to 'inherit', 'polymorph', and 'encapsulate' to and from other objects.

Visual Basic was originally based on the "BASIC" language. "BASIC" is a linear language; meaning that the line of code read only moved downwards (forwards). What made Visual Basic so popular in the beginning, and set it aside from its competitors, was it had an easy method to create forms and place controls on the forms; namely the programmer would drag-and-drop the controls and provide a few lines of code to make a working program. This is great as long as the program was simple and did not require mass lines of coding. As the programmer's needs had evolved so had Visual Basic; such as the introduction of Modules, COM and many other features. (Interestingly enough, with the advancements of Visual Basic you could create a complete application without having to type one line of code. Don't expect a lot out of performance out of the application though!)

The one thing Visual Basic had lacked was the OOP concepts and abilities, because of the non-existent support of OOP, many businesses looking for enterprise solutions (as well as the developers creating them) had moved onto other languages that supported OOP concepts, regardless of the caveats of not having a simplistic drag-and-drop development environment. Most companies had determined that the ability to create code that was easier to manage, and more importantly could harness the full power of their servers with multiple CPUs, large RAM, and many other features would be worth leaving behind the ease of Rapid Application Development (RAD) that VB had offered.

Visual Basic 5 was the first 'introduction' of OOP concepts, targeted to draw in developers who had left the VB scene; however, this was hardly the worth of any enterprise solution developer's time to invest in. Visual Basic 5 had just merely scratched the surface of supporting OOP and this had still left its user base in a tough position when trying to develop an enterprise-level application. Visual Basic 6 was a better effort; however, the advancements still did not warrant an serious consideration of time that would need to be invested to switch languages, as well as the investment costs in re-training all employees (rather it be an internal developer for an enterprise or a private software consultant).

Microsoft had finally decided that they had to make a serious effort to be competitive in the enterprise software development market. Their first major step in this effort was a huge improvement; it was the introduction of .NET! The reason this was a huge improvement was because the .NET architecture is based on OOP concepts. A prime example of this is that the entire .NET architecture is a collection of classes. Classes are the foundation of OOP! (.NET will be further explored in a future blog)

You can see examples of it just from looking at a website that offers dynamic information (such as New York Times, Microsoft, Google, Yahoo, etc). Most dynamic websites use OOP principles; this benefits the web visitor, as well as the web hosting company. The visitor gets to have an interactive experience, up-to-date information, and/or instant access to information. The web hosting company gets to offer more features, require less bandwidth and CPU power, and can instantly change information with minimizing the amount of time (if any) the website is down.

Now that we know what OOP is and we also know how Microsoft had made a full dive into the OOP world, it is worth discussing why you need to know and understand OOP. The first thing I can say is that if you use Visual Basic .NET (2003 or 2005), or any other ".NET Language" (i.e. C#, J#, etc) then you are already using OOP! Another reason that you should know and use OOP is that this is the way, like it or not, the software industry is moving towards.

You will find in your endeavors that you don't need to know and understand every little thing about OOP. You will also find that the more you learn about it, the easier it will get to create your applications. Another prime reason you should learn OOP concepts is that the more you know will result in the more power your applications will be, the safer your coding will be, the easier it will be to scale your application, and most importantly the more reliable your application will be!

Please take a few minutes and read-up on the concepts of OOP and how to use them. If you are unsure of where to begin then there are two resources I would recommend. Wikipedia and Google. In both cases do a search for "Object-Oriented Programming"; if you want more in-depth information than head out to your local bookstore that carries programming reference materials and pick up a book on the subject; you will find many titles available, and you will see just how vast the subject is and quickly realize the importance to learn this.

OOP will be the cornerstone of all of your programming needs and answers.

No comments: