User Tools

Site Tools


wiki:2018design_models

Basic Programming Approaches

There are different ways of approaching a script or program, depending on the task: Is it simple or complex? Is it general or specific? Is it configurable or set in stone?

  • Top down
  • Bottom up
  • Advanced

Top down

Write a script/program in the order of events that you would make on the command line. Perfect for easy, simple tasks. Can make use of loops and flow control structures. This method is harder to expand to bigger problems without a total rewrite.

Bottom up

Write a script/program by breaking the problem down into smaller functions, and then applying them when necessary. More configurable, and suitable for complex tasks. In addition to loops and flow control structures, this method uses methods and functions.

This is an absurd example for such a simple script. It makes sense, though, for larger scripts that need to reuse functions.

Advanced

For advanced applications the tasks are divided into separable pieces. often residing in their own file. This makes commonly-used functions readily available for reuse by different scripts/programs, but cleanly organized so that unnecessary code does not interfere with the programmer's task at hand. Examples include modules, like those that you'll learn about in the section on python. Another example is object-oriented programming, which employs higher-concept design.

Final note

Many tasks start out as the simplest scripts made by pasting commands in from your command line history. But these grow as elaborations on a theme as you reuse and expand the original task. Advanced methods are not taught in this class, but you might encounter scripts that use them.

A more functional revcomp

wiki/2018design_models.txt · Last modified: 2018/08/03 12:02 by david