Download this book
Transcript
5 Program Structure And Layout 5.1 Modular Programming In C51 The first three editions of this work started this chapter with: "This is possibly not the place to make the case for modular programming, but a brief justification might be appropriate." However the interviening years have indicated that this is the place where the case for modular programming must be made! In anything but the most trivial programs the overall job of the software is composed of smaller tasks, all of which must be identified before coding can begin. As an electronic system is composed of several modules, each with a unique function, so a software system is built from a number of discrete tasks. In the electronic case, each module is designed and perfected individually and then finally assembled into a complete working machine. With software there are many similar modeling techniques used for designing the structure and modules of the code. A system, any system (properly applied) is better than no system. At one time graphical modeling was the answer and this spawned CASE, Computer Aided Software Engineering abd CAD, Computer Aided Design tools. They were expensive, promised the earth..... and with CASE largely failed to deliver. Things have improved greatly. Flow charts were in, then out and back in and some say never went away. Firstly remember that any tool is only as good as the person using it. You can make a complete mess with or without the design tools tool (some would say that the automated tools help you make a mess more eficiently). For most 8051 designs the software structures can usually be drawn using paper and pencil. I have only used a tool in this case for clarity of the drawings. Keyed Data Customer Cash Card Message Cash Bank Service Till Account Information Print Slips Bank Transaction Bank Computer For the 8051, using mainly C or assembler, the structured or modular design methods should be used. Structured or modular designed software is the C equivelent of the Object Orientated Programming used with C++, Ada and the like. Both Structured and OO programming share many concepts and good modular programming has many of the attributes of OOP but due to the differences in the way the languages work can not have all of them. For the 8051 a structured method like Yourdon (one of the more popular) would be used. The Yourden method has several views of the software and it is worth looking at these as an example as to why modular programing should be used on all systems. www.hitex.co.uk page 39 of 190 Version 3.6 (draft)