Now Reading
In Reward of High Down Programming

In Reward of High Down Programming

2023-04-10 03:40:44

Nowadays, top-down modular programming is pushed apart by object-oriented programming relating to educating how you can program. However there’s a place for each methodologies to co-exist and top-down programming solves the ever-present downside of how you can start.


Programming Is Arduous



* Just lately revised

How do you clear up an issue?

For a programmer this is identical query as “how do you create a program?”.

If you happen to can construct an algorithm to do one thing then you’ve an answer to an issue. Programming is just not solely the method of fixing issues it additionally presents quite a lot of necessary instruments that assist you to clear up issues. Over time programmers have checked out what they do and have abstracted quite a lot of rules and what was once known as “top-down modular design” is maybe an important.

Sadly with the introduction of object-oriented concepts, top-down has turn into much less clearly an necessary precept. and this can be a enormous disgrace.

Let’s first check out the fundamental concept.

Suppose I ask you to jot down a chess program. If you’d like this in a wider context I’m asking you to unravel the issue of chess.

All issues have applications as their answer all applications clear up some downside.

So how do you start your answer?


That is the “clean sheet of paper” problem. The primary phrase is at all times probably the most tough, and so it’s with programming. However not in the event you take top-down modular programming as your philosophy and strategy. All it’s a must to do on this case is name the process/perform/subroutine that performs chess:


Drawback solved!

In fact it is a cheat in that no such PlayChess process exists in the intervening time, but when it did the issue would actually be solved.

This easy, virtually foolish, step will get you over the clean web page issue and will get you began. It transfers your consideration to the duty of implementing the PlayChess() process, which is not so powerful so long as you retain the identical strategy in operation:

do to finish of sport{

Simple – job executed and downside solved.

Nicely, no. It’s clear we’ve not really received an answer however we’ve received nearer to 1. The purpose is that we’re once more utilizing procedures that do not exist, however this in itself is not incorrect and it does transfer us in the direction of the answer a layer at a time.

So we proceed to implement the procedures that we assume exist at the next degree. In some unspecified time in the future we attain a degree of specification the place it’s potential to jot down some code that really does one thing. In case you are acquainted with the jargon of bushes, we attain a terminal node within the process hierarchy.

That is the entire precept of top-down modular programming.

It’s also often called step-wise refinement and divide and conquer.

There are issues with this strategy – after all there are.

The obvious is that you might finally attain a process that you don’t have any concept how you can implement. No less than this focuses your thoughts on why you’ll be able to’t, in the intervening time, clear up the issue. 

One other potential downside is that with no world design in place your modular decomposition could be inefficient, or may not work in any respect. That is the kind of downside that refactoring may also help with and no less than you now have one thing to refactor.

There are deeper issues that top-down design does not clear up, however who mentioned it was the answer to every little thing. Specifically it implies a hierarchical stream of data down and up the process dependency hierarchy with none information as to how you can set up the information. Curiously, that is the place objects are available helpful as a means of organizing the information.

It’s also mentioned that the hierarchical design makes it tough to take care of, as a result of a change has to propagate, however that is most likely not correct. In a properly designed system, layers within the hierarchy are remoted and solely talk by way of their parameters. Adjustments ought to honor the procedural boundaries, however this is a perfect and in apply procedural hierarchies get uncontrolled similar to inheritance hierarchies.

In fact top-down does not offer you a strategy to discover fully new algorithms. I doubt that you might bump into the quicksort algorithm, for instance, by merely assuming that there exists a form process as a part of a top-down implementation. That is simply one other manifestation of the truth that top-down is not a panacea, only a helpful strategy to producing giant programs and making progress on fixing issues.

To date so good.

High-down modular programming was the methodology of  alternative till about 1980. What occurred then is that object-oriented design grew to become the dominant strategy just because objects had been, and are, highly effective.

The dominant taste of object-oriented programming was, and is, class-based. strongly-typed, objects. You outline a category and derive an object from it. The lessons kind a hierarchy, by the use of inheritance, and that is the kind hierarchy that’s used to implement compiler time checking of what you’ll be able to and can’t do.

This appears to be one thing just like the top-down design because it strikes from the overall – the bottom class – to the extra particular – the derived class. That is kind of true in that you just may design a automobile class after which derive a automobile, bus and motorbike class from it, nevertheless it fails on so many counts. It’s far more sophisticated than the top-down precept as utilized to developing procedures. The truth is, it’s so fragile that many programmers suppose that inheritance is a mistake and ought to be averted if potential.

Inheritance is not an easy software of the top-down precept as a result of it is not an instance of delegation. Whenever you write playchess() as a process name you might be assuming that it’ll do the job and it does that job by delegating the duty to additional procedures. Whenever you create a automobile class you are not delegating something. Whenever you derive a automobile class from a automobile class this once more is not delegation however specialization. It is all very completely different from the way in which procedures are utilized in top-down procedural programming.

Now we come to query.

Does top-down modular design nonetheless exist in an object oriented world?

You possibly can argue that it does as a result of it nonetheless applies to the design of strategies. So that you may clear up the chess enjoying downside by defining a Chess object which had a play technique which moved piece objects across the board object. The play technique is actually our unique playchess() process and you’ll apply top-down strategies to interrupt it down by delegation into different technique calls.

Nonetheless, you’ll be able to already see that the article strategy imposes a totally completely different subdivision on the issue. Object-oriented design is not top-down, even when it pretends to be. The decomposition offered by objects is a mannequin of the actual world, which is in spite of everything the place the thought originated – i.e. within the Simula language and the apply of making simulations.

It’s often mentioned that top-down modular programming actually solely applies to procedural programming and as soon as you progress to things it is not helpful. You possibly can even go additional and declare that the massive downside with top-down is that it ignores the information fully, whereas decomposing the issue into objects places the procedures the place they belong, i.e. with the information they work with.

As we speak the thought of top-down modular design is not taught as a lot because it was once and the principle cause appears to be the issue of creating it slot in with the object-oriented strategy and that is regrettable. In any case you continue to have to jot down procedural code inside an object-oriented world and top-down nonetheless works properly.

See Also


Programming Is Arduous



* Just lately revised

Additional Studying

Commando Jump Game For The Micro:bit In Touch Develop

Commando Jump Game For The Micro:bit In Python

Commando Jump Game For The Micro:bit In JavaScript

Teach Concepts Not Just Code

Does Math Help Programming Or Programming Help Math?

Deep Teaching

How Jazz Ruined Programming

The Real Reason To Learn To Program – The Power

Teach Code In School – Before It’s Too Late!

To learn about new articles on I Programmer, join our weekly newsletter, subscribe to the RSS feed and observe us on Twitter, Facebook or Linkedin.






or e mail your remark to:


Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top