Presentation is loading. Please wait.

Presentation is loading. Please wait.

Principles & Techniques of

Similar presentations


Presentation on theme: "Principles & Techniques of"— Presentation transcript:

1 Principles & Techniques of
Programming Compiled by : S. Agarwal Lecturer & Systems Incharge St. Xavier’s Computer Centre St. Xavier’s College, Kolkata. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

2 Program Definition A program is a collection of instructions that tell the computer what to do. A program is called software, hence, program, software and instructions are synonymous. A program is written in a programming language and is converted into the computer’s machine language by software called assemblers and compilers. They are just like translators. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

3 A program is made up of Instruction Buffers Constants
 Instruction are the directions that the computer will follow and a particular sequence of instructions is called the program’s logic. Buffers are reserved spaces in the computer memory that will accept and hold the data while it is being processed. Constants are fixed values within the program that are used for comparing. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

4 Characteristics of good Programe
Programming style consists of three important qualities: Readability Portability Maintainability Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

5 Readability You should write the source code or the program in high level language that it is readable to you and to others. This includes aesthetic formatting, meaningful variables names and consistency within and across the source files. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

6 Portability Write the code using high level language so that it is easy to transfer the program to other machines as well. If possible avoid nonstandard features and also use the standard library runtime routines rather than writing your own and thus save time. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

7 Maintainability As you write the program, think about how you might want to change or extend it in future. For example, put data structure definitions in header files where changes will automatically broadcast to all source files that include the header file. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

8 Poor programming style Good programming style
Sharing data among functions by making the data global Sharing data by passing arguments Creating numerous special-purpose functions Creating fewer functions Using GOTO statements Using structured control flow statements Writing redundant code sequentially Using functions for code sequences that are used repeatedly Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

9 Introduction to flowcharts
A flowchart is a graphical representation of the sequence of operations in an information system or program. Program flowcharts show the sequence of instructions in a single program or subroutine. Since a flowchart shows the flow of operations in pictorial form, any error in the logic of the procedure can be detected easily. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

10 Flowchart Symbols Processing A processing symbol is used in a flowchart to represent arithmetic and data movement instructions. Flow lines Flow lines with arrowheads are used to indicate the flow of operation, that is, the exact sequence in which the instructions are to be executed. Decision The decision symbol is used in a flowchart to indicate a point at which a decision has to be made and a branch to one of two or more alternative points is possible. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

11 This symbol is used to start or end a flowchart.
Terminal (begin / end) This symbol is used to start or end a flowchart. Input / Output This symbol is used to denote any kind of input or output. Connector If a flowchart becomes very long, the flow lines start crisscrossing at many places that causes confusion and reduces the clarity of the flowchart. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

12 Rules for Writing Flowcharts
First formulate the main line of logic, then incorporate the details in the flowchart. Maintain a consistent level of detail for a given flowchart. Do not give every detail on the flowchart. A reader who is interested in greater details can refer to the program itself. Words in the flowchart symbols should be common statements and easy to understand. Be consistent in using names and variables in the flowchart. Go from left to right and top to bottom in constructing the flowchart. Keep the flowchart as simple as possible. The crossing of flow lines should be avoided as far as possible. If a new flowcharting page is needed, it is recommended that the flowchart be broken at an input or output point. Moreover, properly labeled connectors should be used to link the portions of the flowchart on different pages. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

13 Advantages of Flowcharts
Conveys Better Meaning Since a flowchart is a pictorial representation of a program, it is easier for a programmer to understand and explain the logic of the program to some other programmer. Analyses the Problem Effectively A macro flowchart that charts the main line of logic of a software system becomes a system model that can be broken down into detailed parts for study and further analysis of the system. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

14 Effective joining the part of a System
A group of programmers are normally associated with the design of large software systems. Each programmer is responsible for designing only a part of the entire system. So initially, if each programmer draws a flowchart for his part of design, the flowcharts of all the programmers can be placed together to visualize the overall system design. Any problem in linking the various parts of the system can be easily detected at this stage and the design can be accordingly modified. Flowcharts can thus be used as working models in the design of new programs and software systems.  Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

15 Efficient Coding Once a flowchart is ready, programmers find it very easy to write the concerned program because the flowchart acts as a roadmap for them. It guides them in proceeding from the starting point of the program to the final point ensuring that no steps are omitted. The ultimate result is an error free program developed at a faster rate.  Systematic Debugging Even after taking full care in program design, some errors may remain in the program because the designer might have thought about a particular case. These errors are detected only when we start executing the program on a computer. Such type of program errors are called bugs and the process of removing these errors is known as debugging. A flowchart is very helpful in detecting, locating and removing mistakes (bugs) in a program in a systematic manner. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

16 Systematic Testing Testing is the process of confirming whether a program will successfully do all the jobs for which it has been designed under the specified constraints. For testing a program, different sets of data are fed as input to that program to test the different paths in the program logic. Flow charts help in selecting tests data for confirming the proper working of the logic. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

17 Limitations of Flowcharts
Takes More Time to Draw Flowcharts are very time consuming and laborious to draw with proper symbols and spacing, especially for large complex programs.  Difficult to Make Changes Owing to the symbol-string nature of flowcharting, any changes or modifications in the program logic will usually require a completely new flowchart. Redrawing a flowchart is tedious and many companies either do not change them or produce the flow chart by using a special package designed. Non-standardization There are no standards determining the amount of detail that should be included in a flowchart. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

18 Concepts of DBMS A database collectively refers to one or more files that are maintained, accessed and manipulated by one or more users. A database management system (DBMS) is a set of software programs that control the relationship, storage and retrieval of data (fields, records and files) in a database. It enables individuals to define, manipulate and extract information from database. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

19 What is Database Management System (DBMS)?
A database system involves four major components: Data (facts, figures & statistics) Hardware (circuits, memory, devices etc.) Software (application programs) Users (programmers, end-users & DBA) Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

20 Aim of Database Management System
The main aim behind a database management system is to handle data collectively. This enables us to access information easily, quickly, economically and accurately. Various drawbacks of the conventional data file processing environment are discussed in the next few slides. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

21 Data Redundancy Data elements like employee_name, employee_code, address, etc. are used in various applications. Since data is required by multiple applications, it is stored in different data files resulting in repetition of data. This may lead to inconsistency across different files. In DBMS, data is stored only at one place practically eliminating redundancy and resulting in improvement of the system performance. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

22 Interactive Data Entry and Updating
DBMS provides a way to interactively update (modify) data in a database, as well as interrogate it. This capability allows even a beginner to work with a database very effectively. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

23 Ease of Learning and Use
A major feature of a database management software package is its user friendliness. In other words documentation is adequate and clearly presented. Structural Query language and Report Writers allow users to interactively interrogate the database and analyze it. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

24 Data Independence Data independence is a primary concept of database management. In DBMS package, data is stored in a such a way so as to allow changes to the database structure without affecting the programs that access data. Data independence in DBMS separates data entry from data processing. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

25 Data Security and Integrity
Data security is provided by using passwords. This prevents unauthorized users from accessing the database. Users are allowed access to the whole of database or subsets of database, called Subchema. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

26 Increased Productivity
In organizations when the same database is used by several departments, DBMS provides an easy-to-use query language that enables users to get instant answers to their questions. This reduces the requirement of specially written programs and their frequent modifications according to the changing needs. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

27 Recovery from Failure DBMS have a provision to recover database in the event of hardware / software failure. A backup utility of database is used to obtain backup at regular intervals. Such a utility forms an integral part of a Database Management System. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

28 Performance This objective emphasizes on the reduction of response time to the inquiries made by the users of data. The satisfactory response time is governed by the nature of the user database dialogue. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

29 Relational Database In relational model of data structuring, all data and relationships are represented in two-dimensional tables called a relation. This table manages data in more than one file at one time. Files are treated as tables with rows and columns and not as lists of records. Relational database thus sets data in a table or rows and columns. Relational model of database differs very much from the hierarchical or network counterparts. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

30 Advantages of Relational Database
The relational database structure can be efficiently used even with a computer that has limited memory and processing capability. Relational database is very useful for small databases. Relational database is much easier to use because it enable a computer system to accommodate a variety of inquiries in an efficient manner. Relational database is only concerned with the data and not with the structures which improves performance. Hence the processing time and storage space is comparatively large in relational database but the user is not required to know the intricacies of the structure design thus making RDBMS easy to use and learn. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

31 Phases of Database Design
Designing a database file involves three major steps: Data definition Data refinement Establishing relationships between the fields Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

32 Establishing Relationship between Fields
Data Definition The first phase of Database Design is the data definition. Before you actually create database structure, you must list down all the important fields which you are going to make use of. Data Refinement During this phase, you may refine the list of fields just created so that the fields form an accurate description of the types of data that you will need in the desired database. Establishing Relationship between Fields Drawing relationships among different fields helps to find the importance of each type of field. It is particularly important that you determine which, if any relationships between data fields will call for the use of more than one databases. Relational capability means that the data within one database can be linked, or related, to the data in another database. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

33 Keywords used for file processing
Updation of file: Updation is the process of modifying a master file with current information according to a specified procedure. Searching a file: Searching is a function or mode that enables the user to locate a record in a sequential file. Insertion in the file: Insertion is the process of adding data or text or record in a file at the indicated location. A record is inserted in a sequential file at the end of the file. The file is then sorted or rearranged in a particular order, either ascending or descending. Inserting record in a sequential file is quite a cumbersome process. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

34 Report production and file updation
The output of a computer system is the primary contact between the system and most users. The quality of this output and its usefulness determines whether the system will be used, so it is essential to have the best possible output. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

35 Methods of outputting information
There are four principal methods of outputting information : Printing Screen display Microfilm Synthetic speech method Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

36 Output design Type of output Content Format Location required
Type of output Content Format Location required Frequency Response time required Volume statistics Sequence Post-printing requirements Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

37 Types of output Outputs can be categorized as follows:
External outputs: These go outside the organization (e.g. invoices, orders, tax returns) and therefore call for special attention as they may directly effect the organization’s business relations with its customers. Internal outputs: These remain within the organization but still require careful consideration because they may affect the operational efficiency of the total system. Computer operations output: These are required within the computer services department (e.g. usage statistics, control reports, etc.) Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

38 Form Design Before introducing a new form, its need must be firmly established. It may be that the transfer of information can be achieved in other ways using forms already in existence. A new form must be justified by assessing the following: Means to obtain information most efficiently. Means to disseminate information most efficiently. Means to store information. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

39 Pseudocodes Pseudocodes is an abbreviated form of expression that makes use of both the English language and certain programming language control words such as IF-THEN – ELSE as well as END – IF. Pseudocode is a program analysis tool that is used for planning program logic. It is an imitation of actual computer instructions written in ordinary natural language such as English. The user describes in plain English language, the sequence of steps necessary to solve a particular problem. Sentences are generally written one per line. Indentation is used in the IF statement to outline which actions are to be taken if a condition is true and which are to be taken if the condition is not true. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

40 Modular Programming In industry and commerce, the problems that are to be solved with the help of computers need thousands or even more number of lines of code. The importance of splitting up the problem into a series of self-contained modules then becomes obvious. A module should not exceed about 100 or so lines and should preferably by short enough to fit on a single page. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

41 Advantages of modular design
Some modules will be standard procedures used again and again in different programs or parts of the same program. Since module is small, it is simpler to understand it as a unit of code. It is therefore easier to test and debug, especially if its purpose is clearly defined and documented. Program maintenance becomes easier because the affected modules can be quickly identified and changed. Modules can be tested independently, thereby shortening the time taken to get the whole program working. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

42 advantages of modular design continued …….
In a very large project, several programmers may be working on a single program. Using a modular approach, each programmer can be given a specific set of modules to work on. This enables the whole program to be finished sooner. More experienced programmers can be given a more complex module to write and the junior programmers can work on the simpler modules. If a programmer leaves part way through a project, it is easier for someone else to take over a set of self contained modules. A large project becomes easier to monitor and control. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

43 Characteristics of Structured Programs
In general terms, structured programming is the development of computer programs that are well organized. The programs are based on top-down modular design. In other words, the problem at hand is analysed or broken down into major components, each of which is again broken down if necessary. Therefore, the process involves working from the most general down to the most specific. The design of the modules is reflected in hierarchy charts. Each module has one entry point and one exit point. The GOTO statement is never used to jump from one module in the program to another. (Pure structured programs do not use GOTO). Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

44 Characteristics of Structured Programs continued ………..
A rule of thumb is that the modules should not be more than one half page long. If they are longer than this, they should preferably be split into two or more submodules. Two-way decision statements are based on IF..THEN, IF..THEN..ELSE and nested IF statements. Loops are not custom designed with the use of the GO TO statement, but are based on the consistent use of WHILE..WEND and FOR..NEXT. In WHILE..WEND, the loop is based on the truth of a condition and in FOR..NEXT, on a counting process and the number of repetitions that can easily be predicted. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

45 Syntax / semantic errors Logic errors Runtime errors
Once a program has been typed in, different types of errors may show up. These include: Syntax / semantic errors Logic errors Runtime errors Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

46 Syntax/Semantic errors
Syntax is a set of rules governing the structure of and relationship between symbols, words and phrases in a language statement. A syntax error occurs when a program cannot understand the command that has been entered. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

47 Logic errors Logic refers to a sequence of operations performed by a software or hardware. Software logic or program logic is the sequence of instructions in a program. Logic errors are the errors that have been entered in the instructions created because of the mistake made by a programmer. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

48 Runtime error Runtime error occurs when a program is run on the computer and the results are not achieved due to some misinterpretation of a particular instruction. This could be some thing like dividing a number by zero which results in a very large value of quotient. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

49 Program Testing It is the job of the programmer to test, as far as possible, that all parts of the program work correctly. It should be realized that complete testing is not possible except in the case of the most trivial program; one can never be completely certain that all errors have been removed, but sufficient tests can be performed to give a reasonable measure of confidence in the program. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

50 Methods of Testing FUNCTIONAL TESTING Does the logic work properly?
This means, answering the following: Does the program work as intended? Can it be made to crash? LOGIC TESTING Is the necessary logic present? This means answering the following: Are there any functions missing? Does the program or module do everything specified? Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

51 Program/System Development Process
There are eight phases in this process. Phase 1: Create an Analysis Data Flow Diagram for An Existing System Phase 2: Create a Model Data Flow Diagram for the New System Phase 3: Define the Data Requirements Phase 4: Create a System Structure Chart Phase 5: Design the Database Phase 6: Create the Program Specification Phase 7: Develop the Programs of the System using Structured Programming Techniques Phase 8: Document the System Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

52 Data Flow Diagram (DFD)
The solution to the problem can be shown in the form of a data flow diagram. In DFD, you indicate how data moves from one point to another in the system. A DFD does not define what type of data storage is used, or how the data is stored. These types of details may be determined at the later stage. The boxes and data stored in the data flow diagram may by used as objects. A process to reach from one stage of the project to the next stage may be identified as function. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

53 Software Utilities Text Editor Debugging Tool
Text Editor A text editor is a program that facilitates the creation and correction of texts. The text being edited could be an English language letter, but most often, it is a symbolic language program typed by the user. The text editor program does not interpret the meaning of the text but has the capability of changing it when special commands are issued by the user. Debugging Tool It is program that helps the user to locate and correct logical mistakes in his program. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

54 Sort and Merge Memory dump program
In the area of commercial data processing applications, the most widely used routines are sort and merge. Sort programs are used to arrange data into a specified sequence. Memory dump program A memory dump program allows the user to print the contents of specified locations in the main memory at some particular point during the program execution. A memory dump typically shows both program and operand data. By inspecting both program and data, and comparing it with what it should have been if the program had run correctly, the programmer is able to find the mistakes in his program. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

55 Peripheral interchange program (PIP)
Trace routine A trace routine allows the user to trace the flow of his program while it is executed. He can request, for example, that the contents of certain registers or memory locations be printed every time a branch statement is executed or when the values of certain variables are changed. This allows the user to get a clear picture of what his program is doing and thus he is able to correct mistakes in his program. Peripheral interchange program (PIP) These utility programs facilitate transfer of data from one I/O device to another. They make possible the copying of data from one unit, to another unit, for instance from magnetic tape, magnetic disk. It is also possible to copy data from one tape unit to another tape unit or from one disk unit to another disk unit. This results in a more efficient utilization of the data preparation equipment. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

56 File Manager A file manager is a program which permits programmers to create, copy, update or delete files on the disks. A file is a collection of information supplied by the programmer which is stored on the disk as a single entity and is accessible by a name. A directory of files stored on the disk is also maintained by the file manager. The directory itself is also stored on the disk. The directory includes file name, size of the file, date and time, and unused memory capacity of the disk etc. Locater A locater is a program that assigns specific memory addresses for each machine code of a program which is to be loaded into the system memory. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

57 Loader A loader is a program that loads the machine codes of a program into the system memory. It accepts programs either in absolute or relocatable format. If a program is in absolute format. (i.e. the actual addresses of the instructions and data are supplied by the programmer), the loader simply loads the program into the system memory. If a program is in relocatable format, the locater assigns specific addresses to each instruction and data before the loader loads the program into memory. Linker Usually a longer program is divided into a number of smaller subprograms called modules. It is easier to develop, test and debug smaller programs. A linker is a program that links (combines) smaller programs to form a single programs. While developing a program, subroutines are frequently used. The subroutines are stored in a library file. The linker also links subroutines with the main program. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

58 Program Documentation
Documentation of a software system involves collecting, organizing, storing and maintaining a complete historical record of programs and other documents used or prepared during different phases of the system development. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :

59 That's all.. Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata :


Download ppt "Principles & Techniques of"

Similar presentations


Ads by Google