OO Concepts   «Prev  Next»
Lesson 5Benefits of traditional, structured programming
ObjectiveUses and Benefits of Traditional, Structured Programming.

Uses and Benefits of Traditional, Structured Programming

One way to tell whether structured programming is a good way to approach a problem is to ask yourself whether a flow chart can easily be used to document the problem. If the answer is yes, then the flow of control is probably deterministic enough that structured programming fits the problem. On the other hand, if the answer is no, then you probably need a more sophisticated, object-oriented approach.
Flow charts have fallen out of favor among programmers over the last decade or two, in large part because the programs people began writing no longer fit the deterministic, structured programming, flow chart mentality. New styles of diagrams have been invented to handle the more free-wheeling programs developers are coding today; these object and class diagrams are discussed in upcoming modules.
A few people may object that the programs simply grew too large to be organized into flow charts; although that's true, it is also the case that structured programming is insufficiently powerful to handle large programming projects. The numbers are fuzzy, but generally any program beyond about 50,000 lines of code will be extremely difficult to develop and maintain using purely top-down design and structured programming. Solid object-oriented design raises the limit to around a million lines of code. Indeed, abstract data types are an object-like means of raising the bar on the size of programs that can be written in a purely procedural language.

Role of logic in Object-Oriented Design

Logic plays a crucial role in object-oriented design (OOD), a paradigm for software development that emphasizes the use of objects and classes to create modular, reusable, and maintainable software. In this context, logic refers to the principles and methodologies used to implement the functionality of a system in a coherent and efficient manner. The integration of logic in OOD is multifaceted and includes the following aspects:
  1. Encapsulation and Abstraction: Logic is vital in defining the behavior of objects and their interactions. Through encapsulation, logic is embedded within objects, hiding the internal state and only exposing the necessary interfaces. This encapsulation ensures that the internal logic of an object is not accessible to other objects, promoting a clear separation of concerns. Abstraction allows developers to define common logical patterns at a high level, facilitating the creation of generalized solutions that can be applied to specific instances.
  2. Inheritance and Polymorphism: Logic plays a significant role in implementing inheritance and polymorphism. Inheritance allows new objects to adopt the logic of existing objects, enabling code reuse and logical consistency. Polymorphism, on the other hand, enables objects to be treated as instances of their parent class, but with the ability to implement specific logical behaviors. This aspect of logic allows for flexible and dynamic software design.
  3. Class Design and Modeling: Logical reasoning is essential in class design, where the relationships between different objects and classes are defined. Logical consistency in class hierarchies and associations ensures that the system's architecture is sound and that objects interact in predictable and intended ways.
  4. Design Patterns and Principles: Logic is foundational in applying design patterns, which are proven solutions to common design problems. These patterns embody logical strategies that have been refined over time, providing a template for solving specific issues in object-oriented design. Adhering to solid design principles like Single Responsibility, Open/Closed, and Liskov Substitution also requires a logical approach to ensure that the system remains robust, scalable, and maintainable.
  5. Problem-solving and Decision Making: In OOD, logic is employed in problem-solving and decision-making processes. Logical analysis is used to break down complex problems into manageable components, determine the relationships between these components, and devise strategies for their implementation.
  6. Algorithm Design: The creation of algorithms, which are sets of logical steps to perform a task, is an integral part of OOD. These algorithms define how objects will process data and interact with each other, influencing the overall functionality and performance of the system.

In conclusion, logic is a fundamental aspect of object-oriented design, underpinning the creation of structured, efficient, and reliable software systems. It guides the development process from conceptualization to implementation, ensuring that the resulting software is not only functionally robust but also adheres to the principles of good design and architecture.

SEMrush Sports Car
Past a million lines of code, even object-oriented design begins to break down. The largest single programs in existence that I am aware of border on 10 million lines of code and are extremely difficult to debug and maintain. New techniques are needed that allow truly huge programs to be both built and maintained. This is not to say, of course, that these techniques can't also be used for more complicated programs such as games, word processors, operating systems, and spreadsheets. In fact, they have been used for these things for many years, sometimes with great success, sometimes with spectacular failure. If you investigate the successes, you'll often notice that developers adopted object-oriented principles like data encapsulation even though the language they were coding in did not explicitly support it.
But it is my contention that procedural programming is not the best approach to take for these problems, that OOP more closely matches the way these programs are designed and used, and thus enhances programmer productivity.

Traditional or Structured Programming

Traditional, structured, programming has worked well for millions of programs and billions of lines of code. There is no reason to throw it out completely. In particular, it's worked extremely well for number crunching and data processing programs that run once and produce an answer.
Two characteristics tend to define problems that can be addressed well in a purely structured fashion:
  1. The data to be manipulated closely matches the built-in data types of the language, typically numbers and strings.
  2. The program follows a well-defined flow of control to produce a single result based on some input.

Computer programs with these characteristics include many scientific, engineering, and text processing applications and many of the "textbook examples" from traditional computer science courses. Not surprisingly, these are exactly the sorts of programs that the first people to invent programming languages wanted to solve.

Most modern programming languages are structured this way: the things in the program are objects, and most of the code in the program consists of methods that use the data stored in those objects. A traditionally structured program usually has control over what happens when, but an event-driven program must be able to respond to input at unpredictable moments.
Structured programming can be defined as a software application programming technique that follows a top down design approach with block oriented structures. This style of programming is characterized by the programmers tendency to divide his program source code into logically structured blocks which would normally consist of conditional statements, loops and logic blocks. This style of programming has the implementation of the source code being processed in the order in which bits of the code have been typed in