This article talks about various types of software programming styles. In the field of programming, there are lots of ways to skin a cat, or in this case to create a program that works well. Over the years, different concepts have been used and I will discuss the benefits and drawbacks of two such techniques.
The first technique is called procedural programming. In this programming style, functions are written in sequence and called withing other parts of the program, so that a change in programming to one function can affect any code that calls it. Most functions are used multiple times in a program. Anytime the function changes, each place in the code must also be changed. It is written in a top down style
The second technique is called object orientated programming or OOP. This is a type of programming through which developers define not just the data type of a data structure, but also the kinds of operations (functions) that could be utilized to the particular data structure within the structure.
Both of these 2 programming techniques has its advantages and its disadvantages.
#1. In traditional programming, functions are typically stored in something called a function library. A function library is a file of commonly used functions.
The design technique employed in traditional programming is known as Top Down Design. This is where you begin with a problem (procedure) and after that methodically break the problem down into sub problems (sub procedures). This is called functional decomposition, which usually carries on right up until a sub problem is simple enough to be resolved by the corresponding sub procedure. The issues with this kind of computer programming, is the fact that software upkeep can be challenging and time consuming. When modifications are made to the primary procedure (top), those modifications can cascade to the sub procedures of primary, and the sub-sub procedures and so on, where the change may impact all procedures in the pyramid. Whenever a program calls a function it will reference it in this function library. If you change a function, by adding a required parameter for example, then all the code referencing that function will also need to be changed. This can be quite cumbersome if the function is called 1000's of times. In OOP, Code and data are merged into one standard item, an object. An object is an abstraction of a set of real-world item. The object would contain all information and functionality for that item, ideally, information about a particular item should reside in only one place in a system. The information within an object is encapsulated from the rest of the system. If a change is made in the object, it doesn't mean that it also has to be changed throughout the program. It may not have to be changed. However, in Object Orientated programming if an object is changed significantly enough then there is no way around the notion if probably changing the way it is called from the rest of the program and thus breaking the rest of the program as well. One thing to keep in mind is how many times do you plan on using the object.
#2: Traditional programming uses functions and these functions do a specific task. In Object Orientated programming languages include features such as "class", "instance", "inheritance", and "polymorphism" that increase the power and flexibility of an object. So you can build off of one object and create a more advanced version of that object. Inheritance is often a approach to reuse program code of existing objects, in order to establish a subtype coming from a current object, or both, based upon programming language support. In traditional inheritance where objects are defined by classes, classes can inherit characteristics and behavior from existing classes called base classes. The resulting classes are recognized as derived classes, subclasses or child classes. The connections of classes through inheritance provide an increase to a hierarchy. Now this is a very powerful feature over the use of traditional programming that it allows you to do this. OOP is a very powerful tool used in Microsoft's .NET programming languages like VB.NET and #C. It allows you to take something that Microsoft gives you builds upon it.
#3. Programmers talk about re-using code. You can also re-use code through the use of traditional programming as well as OOP. Sometimes reusing functions that do a specific task is more easily done with regular functions than it is when creating an object. If you are going to modify a major function, it may be more advantageous to create a similar function with a slightly different name. That way you know any reference to the function will remain intact. In OOP, everything is an object and must be programmed that way. If you want to do a series of things you will need to create an object for them. Sometimes building a sub-class off a class can become lengthy in coding and it calls you to add a lot of extra code to provide an additional task. For example, if you create a website form to display a list of products, you can end up building a base form, a form for the display results and a database query form to load the items. This 3 different place you need to code to do one thing. This can cause a little more research when looking to make changes to the form down the road. In this case, how many times is the form going to be used? If only one time in one part of the program or website, then is it really necessary to create an Object?
As I mentioned at the start of this article, there are many ways to program and although Object Orientated Programming is widely use, you still have to do what is efficient and cost effective time wise.