Author Archives: yellowedge

Programming Paradigms

Programming Paradigms

Four different programming Paradigms

  • Imperative Paradigm
  • Functional Paradigm
  • Logical Paradigm
  • Object Oriented Programming Paradigm

 

Imperative Paradigm: This is a traditional approach to the programming process; often termed the ’first do this then do that’ approach, it defines the programming process as a sequence of instructions (also called commands) that solve the problem faced at hand. A typical program is broken into a series of sub routines each solving the problem at hand and the data is passed from one routine to another until the final routine returns the desired output. The Imperative Paradigm is considered a straightforward abstraction of how the Von Neumann Computer works because of this straight forward nature it often resembles machine languages. As of matter of fact, machine languages are considered imperative in nature and FORTRAN was the first Non-machine imperative programming language. Others include, Basic, COBOL (Allborg University, 2010; Laird 2009).

Functional Paradigm: This paradigm is in many ways similar to the imperative Paradigm as it also involves breaking down the program into a series of sub routines that receive inputted data, process it and return output which may serve as input for the next routine. The major difference being that such sub routines are usually pre-defined functions that are simply called when needed. It is often termed the ‘Evaluate an expression and use the resulting value for something’ approach to programming. Some common functional programming languages include LISP and Scheme.  (Allborg University, 2010; Brookshear, Smith and Brylow, 2012 p. 245)

Logic Paradigm: This paradigm is more often used as part of another paradigm than being the sole paradigm in play. It is considered the ‘Answer a question via search for a solution’ approach because it involved processing each step of the program by analyzing a given set of rules commonly called clauses. This makes the program execution like systematic search through facts based on the given rules, and the direction of the processing is determined by the results of such analysis. (Brookshear, Smith and Brylow, 2012 p. 245;  Allborg University, 2010)

Object Oriented Paradigm: This is often considered the ’Objects approach’ due the fact that it involves simulation of an actual real world phenomena in the form of objects, the activities they perform (represented as methods of the object class), the classification of the group they belong to (class) and their interactions with other objects. Using this approach, a big software project in broken down and viewed as a collection of objects which interact with each other through their methods to solve a given problem. OOP is the most prominent programming language in use today. Some languages that promote this paradigm are Java, C and C#. (Brookshear, Smith and Brylow, 2012 p. 245)

 

References

Glenn Brookshear, David T. Smith and Dennis Brylow (2012) p. 245 – 247 Computer Science: An Overview 11th Edition Addison-Wesley ISBN 978-0-13-256903-3

Alex Laird (2009) The Four Major Programming Paradigms [Online Paper] 4th March Available at: http://alexlaird.name/content/uploads/2009/05/topicpaper17-thefourmajorprogrammingparadigms.pdf (Accessed on: 26th November 2012)

Allborg University www.aau.dk (2010) Overview of the four main programming paradigms [Lecture Notes Online]. 7th July Available at: http://people.cs.aau.dk/~normark/prog3-03/html/notes/paradigms_themes-paradigm-overview-section.html (Accessed on: 26th November 2012)

Ida M. Flynn Bookrags.com (n.d) Generations, Languages [Online]. Available at: http://www.bookrags.com/research/generations-languages-csci-01/ (Accessed on: 26th November 2012)

Robert Sedgewick and Kevin Wayne (2006) INTRODUCTION to programming in Java .[Online]. 13th  Nov. Available at: http://introcs.cs.princeton.edu/java/11precedence/ (Accessed on: 26th November 2012)

Object Oriented Programming

Object Oriented Programming

Computer Programming is in some ways like art, there is often more than one way to accomplish a task, more than one type of program to solve a problem, and more than one programing paradigm to choose from. As computer programming becomes more popular, new programming languages are being adopted and new paradigms have also evolved to govern the implementation of such languages.  Object Oriented Programming (OOP), is currently one of the widely accepted and practiced programming paradigms in use today.

A major advantage of OOP is that it is viewed in some quarters as a closer representation of how humans think than structural programming paradigm.  As humans, our life is a series of interactions; we interact with other humans, animals, objects like books or even machines.  We each have characteristics that help define who we are and such characteristics are either unique to us or similar with others who perhaps can be classified as members of the same group as us. We also perform activities during our interactions with other objects, and such interactions usually produce results which in some cases might even become a base for further interactions.  The OOP paradigm embraces this view in programming, it allows the developer create classes which define the characteristics of an object and the different activities (called methods) the objects in a class can perform during interactions with other objects. (Brookshear, Smith and Brylow, 2012, p. 247, p. 276 – 282)

This approach allows a developer to break down large and often complex software projects into smaller units called modules.  This modular nature of OOP encourages the reuse of existing codes to represent new objects, and it also allows the modification of such codes to properly reflect the differences between the new objects and the previously existing ones.  This is due to the inheritance features in OOP that allow a developer not only define a super class (or parent class) with its properties, but also create sub classes (called child classes) that inherit some of the properties of the parent class and could have some additional properties or methods of their own as well as lack some properties that are naturally within the parent class (Cashman, Shelly, & Vermaat, 2004, p. 405).

Another interesting feature in OOP is that it encourages encapsulation; this allows a developer separate an objects’ implementation from its behavior and restricts access to the objects’ its internal data. This minimizes interdependencies between the modules and also helps in the creation of graphical user interfaces for the software project.  It goes without saying that this approach to programming allows for easier maintenance of software as new additions or updates can be made without necessarily affecting the code the code in the super class or altering previous modules.

Personally, I think Object oriented programming actually reflects our natural way of thinking as humans, although I should also point out that this does not make it is easily understandable, especially to a developer who previously used structural programming languages and paradigm.  Personally, it took me a while before I could properly understand how to use OOP concepts effectively in my projects. I also feel sometimes structural programming is a better approach for projects that are not so complex.

References

  1. Glenn Brookshear, David T. Smith and Dennis Brylow (2012) pp. 247, pp. 276 – 282 Computer Science: An Overview 11th Edition Addison-Wesley ISBN 978-0-13-256903-3

Cashman, T.J., Shelly, G.B, & Vermaat, M. E. (2004). p. 405 Discovering Computers: Fundamentals editions. Boston: Course Technology