Page 196 - Open Soource Technologies 304.indd
P. 196

Event Driven Programming



                          A tiny box holding a minus sign will appear to the left of the #Region line. To collapse the code,
                          click on the minus sign. The code will be hidden behind a rectangle captioned with the text you
                          specified and the minus sign will be replaced by a plus sign. Click on the plus sign to expand
                          the region. The Region directive is used to make a program more readable or to create an outline
                          for a program. In Figure 8.1(a), Region directives have been specified for each Procedures in
                          Example . In Figure 8.1(b), these two regions have been collapsed.
































                                                     Figure 8.1(b):  Collapsed Region.

                          8.6 Modules


                          Full-featured software usually requires large programs. Writing the code for an event procedure
                          in such a Visual Basic program might pose a complicated problem. One method programmers
                          use to make a complicated problem more understandable is to divide it into smaller, less
                          complex subproblems. Repeatedly using a “divide-and-conquer” approach to break up a large
                          problem into smaller subproblems is called stepwise refinement. Stepwise refinement is part of
                          a larger methodology of writing programs known as top-down design. The term top-down refers
                          to the fact that the more general tasks occur near the top of the design and tasks representing
                          their refinement occur below. Top-down design and structured programming emerged as tech-
                          niques to enhance programming productivity. Their use leads to programs that are easier to read
                          and maintain. They also produce programs containing fewer initial errors, with these errors
                          being easier to find and correct. When such programs are later modified, there is a much smaller
                          likelihood of introducing new errors.
                          The goal of top-down design is to break a problem into individual tasks, or modules, that can
                          easily be transcribed into pseudocode, flowcharts, or a program. First, a problem is restated as




                          190                    LOVELY PROFESSIONAL UNIVERSITY
   191   192   193   194   195   196   197   198   199   200   201