Road to OOP and Software Architecture: History of Abstraction

Before structured programming

If a program has no structure and is chaotic as the below figure shows, the following quality characteristics will be getting worse:

  • Maintainability (Analyzability; Changeability; Stability; Testability)
  • Portability

This is called commonly, “a status like spaghetti”.

Structured Programming

Such a program can be replaced into a nested program (the below figure shows), according to Structured program theorem.

Nesting is satisfied with the following conditions:

  • A nesting has an entry and an exit;
  • The content of the nesting can be localized and hidden;
  • A nesting may include another nesting, entirely;
  • It include no go-to statements, which are code to jump another arbitrary code.

Structured program theorem derives that any program can be transformed into a nesting program.

Notice that the content of the nesting can be localized and hidden. It may be reused at another place. In this case, such a content will be named and referred at some places. This is an origin of a function or procedure. A function can localize and hide its code and variables (See the below figure). Hiding code and variables from others is also known as capsulizing.

Structured programming is such a concept.

Why should it be localized and capsulized? (or, why shouldn’t a global variable be used?)

A global variable can be accessed from anywhere freely. In contrast, localizing and capsulizing include a concept to hide code and variables from others. They seem more inconvenient than using global variables, because we can’t access code and variables freely. Why should it be localized and capsulized (or why shouldn’t a global variable be used), even though?

Suppose the code and variables in a nesting, function or such structure aren’t hidden from others. Then, any code that is out of it can modify them, thoughtlessly. It causes unpleasant and unintentional results, such as inconsistent problems.

One approach to avoid it is to manage data flow of them, strictly. However, it is more quite difficult if the program is getting larger. It makes such a program uncontrollable and unmanageable.

Thus, they should be hidden, adequately.

A programming language has been expanded, in part for this reason.

Important Principles of Modules: Coupling and Cohesion

A module is a part whose functions are separated and independent from others, and that is interchangeable. There are two important principles of modules:

  • Coupling is a degree of a relationship between modules. Coupling should be less.
  • Cohesion is a degree of a relationship among contents in a module. Cohesion should be more.

Suppose there is an unstructured code and variables as the below figure.

Modular programming designs modules along to the following principles:

  • Put code and variables are related deeply each other into a module together;
  • Separate code and variables that aren’t related so deeply each other into independent modules.

Then, the unstructured code and variables are structured as the below figure.

Abstract Data Type

The principles of Abstract data type are as follows:

  • Make each module more cohesion by (1) putting variables (data) and code for the variables (operations for the data) into the module together; and (2) forcing the code (operation) in the module to be restricted to operating only the variables (data).
  • Make modules less coupling by prohibiting a module from (1) accessing inside of another module and (2) sharing the variables (data) in another module. That is, inside of a module is hidden from another module.

This is called capsulizing. It improves consistency as the above-mentioned reason.

Object-oriented programming (OOP)

An object is an abstract data type and has an entity, which is identified and distinct from another.

Object-oriented programming (OOP) is a paradigm that has its origins of objects and their interactions.

Examples of object-oriented programming languages are Simula (1960s), Smalltalk(1970s), C++(1980s) and Java (1990s).

Abstraction

Abstraction is the process of considering something independently of its associations, attributes, or concrete accompaniments.

For example, modularization is an abstraction because it makes code and variables in a module be separated from those in another module, with considering them independently of their attributes and concrete accompaniments.

Why is abstraction important?

You may think abstraction makes a design complicated because it restricts free ideation or programming. Why is abstraction important?

It has its origin of human recognition. Unfortunately, a human cannot recognize a complicated system because he or she has only too a few chunks of his or her short-term memories to understand. Thus, abstraction is a useful tool for a human.

Software Architecture

Software has been growing rapidly in the aspect of scale. More modules in software are required, more programmers are involved in the development of it. It requires law and order of it, that is, abstraction.

Software architecture is an abstraction of interconnection among modules. There are more than 100 definitions of it (See http://www.sei.cmu.edu/architecture/definitions.html ).

Architectural Styles or Patterns

An architectural style or pattern defines a type of each module and relationships among all of them.

An example of architectural styles is the layered architecture. It is one of the most basic architectures.

The Layered Architecture

In the layered architecture,

  • Define a package that is consist of modules that are related deeply each other;
  • Layer packages;
  • Keep relationships that an upper layer invokes a lower layer (and break them off in case of the converse)

It makes the structure of relationships between layers simple.

Examples of it are the OSI reference model and TCP/IP.

The below figure shows a concept diagram of the layered architecture.

Conclusion

  • Software should be structured because unstructured software causes less maintainability and portability;
  • Structured programming gives law and order to a control flow;
  • Localizing and capsulizing are important in order to make software consistent.
  • Coupling and Cohesion are important degrees when determining structure of software to be constructed;
  • OOP structures not only program but also data;
  • Abstraction makes software simple;
  • Software architecture structures each module and relationships among all of them;
  • One of the most basic architecture styles is the layered architecture.

Call me ZACKY. I'm a researcher of Elixir. My works are including Pelemay https://github.com/zeam-vm/pelemay/, (its old name is Hastega) .

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store