We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19
IAD1193
Problem Solving Methods
Class 01 Your Instructor 2 • Faudzi bin Ahmad • Phone Number / Whatsapp: 019 643 2511 • Email Address: [email protected] • Facebook: Search by my email address / Faudzi Purd Ahmad • Twitter (@faudzipurd), IG (faudzi.purd.ahmad), TikTok (viktor_ahmadeyev) • Office: 2nd Floor, FCVAC (1st wing near the toilet and staircase) Your course 3 • Midterm Exam – 20 • Assignments – 40 • Final Exam: 40 (written exam) • 3 hours Requirements in my class 4 • You are in my class to learn, therefore, the ground rules are… • A class is a formal area, so … • Come early • Dress nicely (shoes! SHOES! SHOESSS!!!) • If you have million-dollar business and need to conduct it, do it elsewhere (that includes phone calls or social networking) • You may stop me anytime to ask questions … and when I do ask you questions, please do your best to answer Program Design 5 • Programming is an art • Do you need to be good at mathematics to do programming? • Given the right tools (including the right mindset and logical thinking), following the right steps, anyone can write well-designed programs • It is definitely a task worth doing, as it is both stimulating and fulfilling • So what is programming? • Development of a solution to an identified problem • Setting up a related series of instructions that when directed through computer hardware produce the desired result 6 • The first part of the definition that satisfies the programmer’s creative needs – design a solution to an identified problem • This step is so often overlooked • Programmers tend to jump straight to into the coding phase without first designing a proper solution • This usually results in a program that contains many errors – when this happens, programmers will spend a significant amount of time trying to find the errors and correcting them • Therefore, a good practise is to design a solution to the program first BEFORE embarking into the coding part of the program • Dry run through the solution to check on the correctness of the design • Once satisfied, program it into a computer using the programming language of choice The 7 basic steps in program development 7 • Define the problem • Outline the solution • Develop the outline into an algorithm • Test the algorithm for correctness • Code the algorithm into a specific programming language • Run the program • Document and maintain the program Define the problem 8 • Involves carefully reading and rereading the problem until you understand completely what is required • With this initial analysis the problem should be divided into THREE separate components • what are the inputs? • what are the desired outputs? • what are the processes or steps required to produce the desired outputs? Outline the solution 9 • Once you have defined the problem you may decide to break it down into smaller tasks or steps and establish a solution outline • It is a rough draft of the solution and may include • the major processing steps involved • the major subtasks (if any) • the user interface (if any) • the major control structures (decisions, loops, etc) • the major variables and record structures • the mainline logic Develop the outline into an algorithm 10 • The solution outlined beforehand is expanded into an algorithm – a set of precise steps that describe exactly the tasks to be performed and the order in which they are to be carried out • One of the ways to achieve this is by using a pseudocode – a form of structured English to represent the solution algorithm • Flowcharts can be used to represent the algorithm in a pictorial / visual representation Test the algorithm for correctness 11 • This step is one of the most important in the development of a program but almost always sidelined by programmers • The main purpose of checking the correctness of the algorithm (sometimes called as dry run) is to identify major logic errors early so that they may be easily corrected • Test data needs to be walked through each step in the algorithm to ensure that the instructions written actually do what they are supposed to do • The programmer ‘walks through’ the logic of the algorithm exactly as a computer would by keeping track of all major variables on paper • You may use a desk check table for this purpose Code the algorithm – run the program 12 • When you are satisfied with the correctness of your algorithm, you can then start coding the algorithm into a proper program by using the programming language of your choice • Running a program uses a program compiler and programmer-designed test data to machine test the code for • syntax error – detected at compile time • logic error – detected at run time • This is usually the most rewarding step in program development process • If the program has been well designed, the time-wasting frustration and despair often associated with program testing are reduced to a minimum • This step may need to be performed several times until you are satisfied that the program is running as required and coming up with the desired output Document and maintain the program 13 • This is actually not the last step because this is done throughout the other steps of the program design • Documentation includes both external documentation and internal documentation • External – can include the solution algorithm, the test data results etc. • Internal – embedded within the computer program itself • Program maintenance refers to changes that may need to be made to a program throughout its life cycle • It may be done by a different programmer • The documentation may aid another programmer in maintaining the current program which will make life extremely easier as compared to trying to maintain a program without any documentation – reading a computer program is definitely DAUNTING!!!! Program design methodology 14 • Fundamental principle of program design is based on the fact that a program accepts input data, process the data, deliver the output • INPUT PROCESS OUTPUT • A number of different approaches to program design have emerged and the most common are: • procedure-driven (structured programming) • event-driven • data-driven (object-oriented programming) Procedure-driven program design 15 • Based on the idea that the most important feature of a program is what it does – its processes or functions • Programmer identifies and organises the processes in the program solution • The flow of data into and out of each process or function is then considered and a strategy developed to break each function into smaller and more specific flows of data • The details about the actual structure of the data are not considered until all the high-level processes or functions of the program have been identified Event-driven program design 16 • Based on the idea that an event or interaction with the outside world can cause a program to change from one known state to another • The initial state of a program is identified then all the triggers that represent valid events for that state are established • Each of these events results in the program changing to a new defined state where it stays until the next event occurs Data-driven program design 17 • Based on the idea that the data in a program is more stable than the processes involved • It begins with an analysis of the data and the relationships between the data in order to determine the fundamental data structures • Once these data structures have been defined, the required data outputs are examined in order to establish what processes are required to convert the input data into the required output So? What then? 18 • The choice between procedure-driven, event-driven or data-driven program design methodologies is usually determined by the selection of a programming language • Most legacy programming languages like Fortran and Pascal are procedure- driven • Current programming languages like Java, C# can be procedure-driven or mostly used as data-driven • Systems that use visual interface like Visual C# or Visual Java with buttons and such can include all procedure-driven, data-driven and event-driven The end for this session We shall continue