Presentation on theme: "Alexandria University Faculty of Science Computer Science Department"— Presentation transcript:
1 Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102)
2 The Program Development Life Cycle Creating new programs is called program development.Creating successful applications requires planningComputer professionals need to develop new or modified applications from time to timeThe process associated with creating successful applications programs is called the program development life cycle (PDLC).
4 1. Problem Analysis During analysis, a systems analyst and programmer: review specifications, andtalk with users to fully understand what the software should do.Documentation consists of:program specifications,timetable,which language will be used,how the program will be tested, andwhat documentation is required.
5 2. Program DesignProgram design: stage where program specifications are expanded into a complete design of the new program.Structured programming and object-oriented programming are two of the most significant approaches to the design process.
6 Program Design: Program Design Tools Program design tools are planning tools.Structure chartsProgram flowchartsPseudocodeData modeling
7 Structure Charts Structure charts depict the: overall organization of a program, andhow the modules of a program are defined andhow they connect to each other hierarchically.Program modules should be arranged hierarchically in a top-down fashionWhy?? So that their relationship to each other is apparent.
9 FlowchartsUse geometric symbols and familiar relational operators to provide a graphic display of the sequence of steps involved in a programDifferent symbols are used to represent different actions such asStart/stopDecisionInput/outputProcessingLooping symbols
13 PseudocodeUses English-like statements in place of the graphic symbols of the flowchart.Unlike a flowchart, pseudocode is easy to modify and can be embedded into a program as comments.No standard set of rules exists for writing pseudocode, although a number of conventions have been developed.
15 Program Design: Program Design Tools Data modelingis a technique used to illustrate the data in an application and is frequently used with object-oriented programming.In a data model, the objects in the program are identified, along with their variables and class.
16 Program Design: Good Program Design n Good program design is essential; it can save time and it produces a better end result. Some principles of good program design are:Be specificOne-entry-point, one-exit-point ruleNo infinite loopsDocumentation during program design includes all the design specifications
18 3. Program CodingCoding: actual process of creating the program in a programming language.Programming language must be chosen.Coding standards should be adhered to.Make use of reusable code and data dictionaries.Translate coded programs into executable code.Documentation results in finished source code.
20 3. Program Coding cont’dThe coded program is referred to as source code. To be executed, the program is converted by the computer to object code using a special program.A compiler translates the entire program into machine language before executing it. The program then doesn’t need to be recompiled until it is modified.An interpreter translates program statements one at a time. Interpreters are helpful during the debugging stage, but are slower during execution of the finished program.An assembler converts assembly-language statements into machine language.
22 4. Program Debugging and Testing Debugging: process of making sure a program is free of errors or bugs.Preliminary bugging often finds syntax or logic errors.Testing can consist of alpha or beta testing.Documentation includes a copy of the finished program code, plus test data and results.
23 4. Program Debugging and Testing cont’d Preliminary debugging begins after the program has been entered into the computer system.Rarely is a program error-free the first time it runs.Two common types of errors are syntax errors and logic errors:A syntax error occurs when the programmer has not followed the rules of the language.A logic error, or execution-time error, results when the command syntax is correct but the program is producing incorrect results.
24 5. Program MaintenanceProgram maintenance: process of updating software so that it continues to be useful.A costly process, but can be used to extend the life of a program.Documentation consists of amended program package reflecting what problems occurred and what program changes were made.
25 What Is a Programming Language? A programming language is a set of rules used to write instructions to the computer.
26 Categories of Programming Languages Low-level languagesHigh-level languagesFourth-generation languages (4GLs)Natural and visual languages
27 Machine and Assembly Languages Machine and assembly languages are called low-level languagesProgrammers who code in them must write instructions at the finest level of detail, the base level of the hardwareVirtually no one writes machine-language programs anymoreAll programs must be translated by a language translator into machine language before they are executedAssembly languages are fast and consume little storage when compared with higher-level languages, but take longer to write and maintain
28 High-Level Languages· High-level languages differ from their low-level predecessors in that they require less coding detail and make programs easier to write.Programs written in a high-level language (BASIC, COBOL, Pascal, C, etc.) need to be translated into machine language before they can be executed.
29 Fourth Generation Languages (4GL) Very-high-level languages that are much easier to use than the high-level languagesThey are declarative rather than procedural languages.For instance, to draw a bar chart in a procedural language, you must tell the computer how to draw bars and where to place them.In a declarative language, you may be able to just point to the data you want graphed, click several menu choices, and you’re in business.Fourth-generation languages are commonly used to access databases (query languages).
30 Popular Programming Languages FORTRANCOBOLPascalBASIC and Visual BasicC, C++, AND C#Java
32 Markup LanguagesMarkup languages use symbols or tags to describe what a document should look like when displayed.HTML (Hypertext Markup Language)Dynamic HTMLXML (extensible markup language)XHTML (extensible Hypertext Markup Language)WML (Wireless Markup Language )
36 FlowchartsUnderstanding the basic parts of the flowchart and the advantages and limitations of flowcharts.
37 DefinitionFlowcharts a diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem.
38 How to Write a Program? Start Define Problem to Solve Think of an AlgorithmThink of a Technique for the SolutionWrite Solution on a Piece of PaperIf not Finished Repeat Steps 4 and 5Write Code and ProgramDebug and TestIf not Finished Repeat Steps 7 and 8Stop
39 How to Write a Program? Start Job Done No Define Problem to Solve Think of an Algorithm(Technique for the solution)YesWrite Code and ProgramIdea!!!!Debug and TestThink of aTechnique for the solutionJob DoneNoYesStopWrite it downon a piece of paper(before you forget it!!!)
40 Algorithms A computer program makes use of algorithms Algorithm is a complete step-by-step procedure for solving a problem or accomplishing a task.
41 Standard Flowchart Symbols Start Or Stop ProcessStartPrintResultsInput/OutputAOn-Page Connector?YesNoConditionCalculateVariablesProcess RectangleA1Off-page Connector
43 Basic Flow Chart Operations All computer instructions are based on four basic processing patterns:Simple SequenceSelection PatternLoop PatternBranch Pattern
44 Simple SequenceLogic involves executing instructions one statement after another, in the order presented by the program.This is the simplest and most-used pattern.The computer assumes that all instructions are to be executed in this order unless the program presents other instructions.
45 Example of a Simple Sequence Read NamesCompare with CriteriaPrint Eligible Names
46 Selection PatternRequires that the computer make a choice among two or more items.Each choice is based on one of two comparisons a computer can make: true or false (Yes or No).
47 Example of a Selection Pattern ?Honour StudentNoYesList underStudent LoanList underScholarships
48 Loop PatternCauses an interruption in the normal sequence of processing and directs the computer to loop back to a previous statement in the program, repeating the same sequence over again, usually with new data.By looping, the programmer avoids having to repeat the same set of instructions over and over.
49 Example of a Loop Pattern ?More NamesNoYesCompare with CriteriaPrint Eligible Names
50 Branch Pattern Is often used in combination with selection or looping. The branch pattern allows the computer to skip statements in a program.The branch encourages undisciplined jumping around among program statements, a characteristic that is frowned on by most programming experts.Branching is difficult to follow and is an inefficient use of computer power.
51 Example of a Branch Pattern ?Honour StudentNo1YesRead Area of ConcentrationRead Courses Taken1Compare with Criteria
52 Types of Flowcharts Functional Chart Process Flow Chart A chart that is used to describe how activities interact with one another within an organization as well as with other organization and/or systems.Process Flow ChartA chart that is used to describe the sequence and relationship of the tasks that make up an activity3. Process Flow Description ChartDetailed description of the tasks outlined in a Process Flow ChartTypically used to show the kinds of tasks performed within a process (the number of operations, review, and transfers; and the amount of storage and time required to complete an activity)
53 Uses of FlowchartsFlowcharts are generally drawn in the early stages of formulating computer solutions.Flowcharts facilitate communication between programmers and business people.Flowcharts play a vital role in the programming of a problem and are quite helpful in understanding the logic of complicated and lengthy problems.Once the flowchart is drawn, it becomes easy to write the program in any high level language.Often we see how flowcharts are helpful in explaining the program to others.Hence, it is correct to say that a flowchart is a must for the better documentation of a complex program.
54 Advantages of Flowcharts Communication: Flowcharts are better way of communicating the logic of a system to all concerned.Effective Analysis: With the help of flowchart, problem can be analysed in more effective way.Proper Documentation: Program flowcharts serve as a good program documentation, which is needed for various purposes.
55 Disadvantages of Flowcharts Complex Logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy.Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely.Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem.The Essentials of what Is Done can easily be lost in the technical details of how it is done
56 Case Study - 1A certain Company gives each of its sales people $1,000 at the beginning of each month to cover travel, lodging, and food expenses. At the end of the month, a salesperson must total his/her expense receipts. If the amount is less than $1,000 then the difference must be returned to the company.
57 Case Study – 1 (Solution) Here is an algorithm for figuring how much money, if any, must be returned:Total the expense receipts for the month.2. Subtract the amount of the expense receipts from 1,000.3. If the remainder is more than 0, return that amount to the company.