Page 212 - DCAP305_PRINCIPLES_OF_SOFTWARE_ENGINEERING
P. 212

Principles of Software Engineering



                   Notes            •  We tend to execute as we think about the problem. Hence, there are inherent difficulties
                                      when writing an algorithm.
                                    •  We normally tailor our plans of action to the particular problem at hand and not to a
                                      general problem (i.e. a nearsighted approach to problem solving).

                                    •  We usually do not write out our plan, because we are usually unaware of the basic ideas
                                      we use to formulate the plan. We hardly think about it – we just do it.

                                    •  Computer programmers need to adopt a scientific approach to problem solving, i.e. writing
                                      algorithms that are comprehensive and precise.

                                    •  We need to be aware of the assumptions we make and of the initial conditions.
                                    •  Be careful not to overlook a step in the procedure just because it seems obvious.
                                    •  Remember, machines do not have judgment, intuition or common sense!
                                 Developing an Algorithm

                                    •  Understand the problem (Do problem by hand. Note the steps)
                                    •  Devise a plan (look for familiarity and patterns)

                                    •  Carry out the plan (trace)
                                    •  Review the plan (refinement)
                                 10.2.2 Understanding the Algorithm

                                 Possibly the simplest and easiest technique to understand the steps in an algorithm, is by means of
                                 the flowchart method. This algorithm is composed of block symbols to represent each step in the
                                 solution process as well as the directed paths of each step. The most common block symbols are:

                                                Symbol   Representation   Symbol  Representation

                                                           Start/Stop                Decision


                                                            Process                  Connector



                                                          Input/Output             Flow Direction


                                 There are many other block symbols, used in flow charting, but for the purposes of this course,
                                 we will restrict our usage to the symbols described above. They are sufficient to illustrate the
                                 steps in developing solutions to the simple problems we will be dealing with.
                                 10.2.3 Top-Down Design Approach (Modularization)

                                 The modularization move toward involves breaking a problem into a set of sub-problems,
                                 followed by breaking every sub-problem into a set of tasks, then breaking each task into a set
                                 of actions.



                                 Problem 1
                                 Add 23 and 35

                                 No further refinement is required.

        206                               LOVELY PROFESSIONAL UNIVERSITY
   207   208   209   210   211   212   213   214   215   216   217