Introduction to Programming and Problem Solving (CS101) Lecture 3 PDF
Document Details
Uploaded by IrreproachableZombie9040
Ibrahim Shawky
Tags
Related
Summary
This lecture introduces programming and problem-solving concepts, covering software engineering phases such as analysis, design, implementation, and testing. It delves into structured and object-oriented design, and explains algorithms, pseudocode, and stepwise refinement techniques. Examples of pseudocode are included.
Full Transcript
Introduction to Programming and Problem Solving (CS101) Lecture 3 Prepared by/ Ibrahim Shawky Software engineering (Revist) Software engineers typically break the software development process (software development life cycle) into the following four...
Introduction to Programming and Problem Solving (CS101) Lecture 3 Prepared by/ Ibrahim Shawky Software engineering (Revist) Software engineers typically break the software development process (software development life cycle) into the following four phases: Analysis Design Implementation Testing and debugging Software Design After analyze the problem next step is to design an algorithm to solve the problem. If you broke the problem into sub problems you need to design an algorithm for each sub problems. Algorithm: A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time. There are two Kinds of Design Structure design Object oriented design Structured Design Also Called: top-down design, stepwise refinement, and modular programming. Dividing a problem into smaller sub problems. Each sub problem: Analyzed, and A solution is obtained to solve the sub problem. The solutions of all the sub problems are then combined to solve the overall problem. This process of implementing a structured design is called structured programming. Object-Oriented Design the first step in the problem- solving process is to identify the components called objects and determine how these objects interact with one another. After identifying the object, the next step is to specify the following attributes for each object: the relevant data and possible operations to be performed on that data Final program is a collection of interacting objects. This process of implementing an object-oriented design is called object-oriented programing (OOP) language. Example of Object-Oriented Design Example: video store The two main objects are the video and the customer. For a video object: The data might include the movie name, starring actors, producer, and so on. The operations on a video object might include checking the name of the movie, reducing the number of copies in stock by one after a copy is rented. Software Implementation In this phase, you write programming code to implement the operation that identified in the design phase. This course focus on software implementation phase. Testing and debugging Testing refers to test the correctness of the program or making sure that the program does what it is supposed to do. Debugging refers to finding and fixing the errors, if they exist. To increase reliability of program you must discovery error and fixed it. Main test types There are two types of testing: black-box testing and White-box testing. black-box testing The internal working of the function not know It is only required to know what the function does and test it. So, Black-box testing is based on inputs and outputs. Example: - if we make function to check integer if it is greater than or equal to 0 and less than 100 The function is tested on values that surround and fall on the boundaries called boundary value. Example -1, 1,100 White-box testing. relies on the internal structure and implementation of a function will be known. The objective is to ensure that every part of the algorithm is executed at least once. Example: If statement test when true and false you need at least one input for if to ensure it work. Algorithm A programmer starts with a general idea of a task for the computer to perform. the programmer has some idea of how to perform the task by hand, at least in general outline. An algorithm is an unambiguous, step-by-step procedure that terminates after a finite number of steps. An algorithm is not the same as a program. An algorithm can be expressed in any language, including English. Algorithm The most widely used notations for developing algorithms: A flowchart is a diagram containing lines representing all the possible paths through the program. Pseudo-code is a form of stylized (or structured) natural language. Pseudo-code and stepwise refinement Pseudo code is a high-level description of a program's logic written in plain language. It helps to plan out an algorithm before translating it into actual code. Pseudocode is the intermediate state between an idea and its implementation(code) in a high-level language. To write algorithm in pseudo-code, you can use the stepwise refinement method. it’s the type of top-down design (structure design). Pseudo-code and stepwise refinement To write your idea in the form pseudo-code, two steps must be performed: Stepwise break a complex problem down into a number of simpler steps. Sub-algorithm can themselves be broken into smaller portions. Refinement Refinement continues in this manner until each step is sufficiently detailed replacing existing steps/instructions with a new version that fills in more details. Example Example Example Example Example Output devices