750 likes | 942 Views
Alexandria University Faculty of Science Computer Science Department. Introduction to Programming (CS 102). The Program Development Life Cycle. Creating new programs is called program development . Creating successful applications requires planning
E N D
Alexandria UniversityFaculty of ScienceComputer Science Department Introduction to Programming (CS 102)
The Program Development Life Cycle • Creating new programs is called program development. • Creating successful applications requires planning • Computer professionals need to develop new or modified applications from time to time • The process associated with creating successful applications programs is called the program development life cycle (PDLC).
1. Problem Analysis • During analysis, a systems analyst and programmer: • review specifications, and • talk 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, and • what documentation is required.
2. Program Design • Program 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.
Program Design: Program Design Tools Program design tools are planning tools. • Structure charts • Program flowcharts • Pseudocode • Data modeling
Structure Charts • Structure charts depict the: • overall organization of a program, and • how the modules of a program are defined and • how they connect to each other hierarchically. • Program modules should be arranged hierarchically in a top-down fashion • Why?? So that their relationship to each other is apparent.
Flowcharts • Use geometric symbols and familiar relational operators to provide a graphic display of the sequence of steps involved in a program • Different symbols are used to represent different actions such as • Start/stop • Decision • Input/output • Processing • Looping symbols
Pseudocode • Uses 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.
Program Design: Program Design Tools Data modeling is 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.
Program Design: Good Program Design nGood program design is essential; it can save time and it produces a better end result. Some principles of good program design are: • Be specific • One-entry-point, one-exit-point rule • No infinite loops • Documentation during program design includes all the design specifications
3. Program Coding • Coding: 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.
3. Program Codingcont’d • The 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.
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.
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. • Alogic error, or execution-time error, results when the command syntax is correct but the program is producing incorrect results.
5. Program Maintenance • Programmaintenance: 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.
What Is a Programming Language? A programming language is a set of rules used to write instructions to the computer.
Categories of Programming Languages • Low-level languages • High-level languages • Fourth-generation languages (4GLs) • Natural and visual languages
Machine and Assembly Languages • Machine and assembly languages are called low-level languages • Programmers who code in them must write instructions at the finest level of detail, the base level of the hardware • Virtually no one writes machine-language programs anymore • All programs must be translated by a language translator into machine language before they are executed • Assembly languages are fast and consume little storage when compared with higher-level languages, but take longer to write and maintain
High-Level Languages • ·High-level languagesdiffer 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.
Fourth Generation Languages (4GL) • Very-high-level languages that are much easier to use than the high-level languages • They 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).
Popular Programming Languages • FORTRAN • COBOL • Pascal • BASIC and Visual Basic • C, C++, AND C# • Java
Markup Languages • Markup languages use symbols or tags to describe what a document should look like when displayed. • HTML (Hypertext Markup Language) • Dynamic HTML • XML(extensible markup language) • XHTML (extensible Hypertext Markup Language) • WML (Wireless Markup Language )
Scripting Languages • Scripting languages are used to build program instructions into Web pages, usually to add dynamic content. • JavaScript • VBScript • Perl
Understanding the basic parts of the flowchart and the advantages and limitations of flowcharts. Flowcharts
Definition • Flowcharts a diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem.
How to Write a Program? • Start • Define Problem to Solve • Think of an Algorithm • Think of a Technique for the Solution • Write Solution on a Piece of Paper • If not Finished Repeat Steps 4 and 5 • Write Code and Program • Debug and Test • If not Finished Repeat Steps 7 and 8 • Stop
How to Write a Program? Start Job Done No Define Problem to Solve Think of an Algorithm (Technique for the solution) Yes Write Code and Program Idea!!!! Debug and Test Think of a Technique for the solution Job Done No Yes Stop Write it down on a piece of paper (before you forget it!!!)
Algorithms • A computer program makes use of algorithms • Algorithm is a complete step-by-step procedure for solving a problem or accomplishing a task.
Print Results Calculate Variables A On-Page Connector Input/Output Process Rectangle ? Start Yes A1 Start Or Stop Process No Off-page Connector Condition Standard Flowchart Symbols
Basic Flow Chart Operations • All computer instructions are based on four basic processing patterns: • Simple Sequence • Selection Pattern • Loop Pattern • Branch Pattern
Simple Sequence • Logic 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.
Example of a Simple Sequence Read Names Compare with Criteria Print Eligible Names
Selection Pattern • Requires 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).
Example of a Selection Pattern ? Honour Student No Yes List under Scholarships List under Student Loan
Loop Pattern • Causes 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.
Example of a Loop Pattern ? More Names No Yes Compare with Criteria Print Eligible Names
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.