1 / 30

KISS Programming

KISS Programming. What’s so great about computers?. They are fast (so they can accomplish much in a short time… spell check a thesis) They don’t make mistakes (speaking about the computers themselves and not the software that runs them) They do only what they are told to do.

warwick
Télécharger la présentation

KISS Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. KISS Programming

  2. What’s so great about computers? • They are fast (so they can accomplish much in a short time… spell check a thesis) • They don’t make mistakes (speaking about the computers themselves and not the software that runs them) • They do only what they are told to do

  3. What’s not so great about computers? • They are fast (so they can get into trouble quickly) • They don’t think or understand • They aren’t capable of independent thought (you must tell them EXACTLY what to do)

  4. What’s so great about humans? • We can think and reason • We can be logical (or illogical) • We can be emotional (or unemotional) • We can be creative

  5. What’s not so great about humans • We make mistakes • We don’t understand how we do what we do (putting things in writing demonstrates this)

  6. What’s not so great about programming? • It seems difficult • We MUST think from the computer’s POV

  7. What’s so great about programming? • We get a very quick and very dim-witted entity to be our slave • We can save ourselves (or our companies) time, money, resources • We can accomplish things we can otherwise not accomplish. • It’s not difficult, it’s different

  8. What is the “definitive element” of programming? • Process: A process is a set of sequential instructions or “operations” to accomplish a task.

  9. How many kinds of process operations are there? There are just three operations necessary to develop program algorithms: • Input • Output • Calculation

  10. Input Getting data from an “external location” associated with an “internal location” (an area of RAM that can be addressed or be made easily accessible). • Read x • x = Cells(5,2).Value

  11. Output Putting data associated with an “internal location” to an “external location”. • Print y • Cells(3,3).Value = y

  12. Computation Performing operations (mathematical) on data stored at “internal locations” and storing the result at an “internal location”. • z = x+y • zAnswer = erfc(x)+exp(erfc(y))

  13. So all processes are composed of a series of input, computation and output steps.

  14. What is structured programming? • Structured programming is an efficient way to design programs to control the flow of processes to accomplish complicated and sophisticated tasks.

  15. What are the structures in structured programming? • All programs can be generated from just three structures. • Sequence – a linear arrangement of process steps • Decision – a branching arrangement involving one or more processes • Repetition – a controlled looping of a process

  16. What is invocation? • Invoking is simply the naming of a collection of structures. This powerful concept allows us to hide or expose the details of complex programs (processes).

  17. What is a NS Diagram? • Nassi-Shneiderman (NS) diagrams (developed by Ike Nassi and Ben Shneiderman) illustrate programming structures and operations graphically. • An alternative to the overly flexible traditional flow chart, NS charts enforce structure and modularity in the programming process.

  18. What is a NS Diagram? • The first key to building a well-structured system is to design the system before building it. Can you imagine hiring an architect who directs a contractor to build the kitchen and living room of your new home only to find out there is no wall space left for a door to the bedroom? Yet novice programmers attempt to build software systems in this piecemeal fashion. • One often hears the excuse “I don’t have time to design my program.” In truth, a program will be up and running properly faster if it is designed properly in the first place. If you don’t have time to design, then you certainly don’t have time not to design.

  19. What is a NS Diagram? What is required of a good design tool? A good design tool should: • Enforce structured design. • Enforce program modularity. • Be easy to use. • Generate documents easily understood by others.

  20. What is a NS Diagram? • The classical flow chart used for program design has many shortcomings, the greatest being its extreme flexibility. Any imaginable structure can be represented by a flow chart (including bad ones); hence, desirable structures cannot be enforced. • Furthermore, traditional flowsheet symbols attempt to show the most detailed level of code (individual operations). Hence most programmers manage to write the program first (without proper design) and then make a diagram to explain the programs “flow”. This defeats any attempt at modularity.

  21. What is a NS Diagram? • The N/S chart starts with the basic characterization of modern day languages as being block-structured languages. In these languages, procedures are represented as rectangular blocks. A block has a beginning and an end. When the procedure is called (when the process is entered) instruction execution begins at the top and proceeds to the bottom of the block. This is called a “sequential operation” or stepwise execution.

  22. NS Diagram for Sequential Operations

  23. NS Diagram for DecisionIF Form • The conditional IF structure is shown in the next slide. At the top of the block is a conditional test. Depending upon the outcome of the test, one of two paths are taken through the block. If the test result is “T” (true) steps 1a, 2a, 3a, etc. are executed. If the test result is “F” (false) steps 1b, 2b, 3b, etc. are executed. In either case, control is passed to the top of the block and falls to the bottom of the block.

  24. NS Diagram for DecisionIF Form

  25. NS Diagram for Decision CASE Form • The CASE structure is shown in the next slide. A case is used when there are more than two “branches” in the decision. A variable or expression is evaluated. Depending on its value, the proper group of operations are executed. There is also a possibility of “no match” in which case one can provide for a “none” case.

  26. NS Diagram for Decision CASE Form

  27. NS Diagram for LoopFOR Form • The FOR structure shown in the next slide executes the operations repetitively over a specified range of the control variable (say “i”). Entering the block from the top causes the first value of “i” to be chosen, and the operations are evaluated relative to that value. Arriving at the bootom, control is returned to the top of the block where the next value of “i” is chosen. When all values of “i” have been exhausted, control passes from the block.

  28. NS Diagram for LoopFOR Form

  29. NS Diagram for LoopWHILE Form

  30. NS Diagram for LoopUNTIL Form

More Related