Software

Main Program and Subroutine

Main program and subroutine is a style that is fundamentally focused on functions. When presented with a system to model, you break up the overall functionality of the system into a main program and subroutines.

In the diagram, we can see how subroutines are connected by procedure calls, and may even have nested calls:

MainProgramAndSubroutines.png

The structure of the resulting code is not flat, it’s hierarchical, hence it can be modeled as a directed graph. The subroutines, as declared in the code are structured as a big call tree. As OO languages, procedural programming supports abstract data types, but inheritance is not explicitly supported. It’s not easy to make one abstraction type an extension of another type. Here, the main consideration is the behavior of functions and how data moves through them. As a result, this approach is suitable for computation-focused systems.

Continue reading “Main Program and Subroutine”
Software

Abstract Data Types and Object-Oriented (basics)

Each programming paradigm has its own set of constructs and their use will shape the system you create.

The main OO concepts:

  1. Abstraction – simplify a concept by ignoring unimportant details.
  2. Encapsulation – allows to bundle data and functions into a self-contained object, so the other objects can interact with it through an exposed interface.
  3. Decomposition – allows you to break up a whole problem into smaller, distinct parts.
  4. Generalization – allows you to factor out conceptual commonalities.

Object-oriented refers to a system composed of objects. where each object is an instance of a class (the type of each object is its class). Objects may interact with each other through the use of their methods. The OO paradigm allows for inheritance among abstract data types (one abstract type can be declared an extension of another type).