Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Principles & Techniques of Programming Compiled."— Presentation transcript:

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

2 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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 computers machine language by software called assemblers and compilers. They are just like translators.

3 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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 programs 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.

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

5 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

6 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

7 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

8 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Poor programming styleGood 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 statementsUsing structured control flow statements Writing redundant code sequentially Using functions for code sequences that are used repeatedly

9 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

10 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

11 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

12 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Rules for Writing Flowcharts a)First formulate the main line of logic, then incorporate the details in the flowchart. b)Maintain a consistent level of detail for a given flowchart. c)Do not give every detail on the flowchart. A reader who is interested in greater details can refer to the program itself. d)Words in the flowchart symbols should be common statements and easy to understand. e)Be consistent in using names and variables in the flowchart. f)Go from left to right and top to bottom in constructing the flowchart. g)Keep the flowchart as simple as possible. The crossing of flow lines should be avoided as far as possible. h)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.

13 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

14 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

15 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

16 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

17 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

18 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

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

20 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

21 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

22 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

23 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

24 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

25 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

26 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

27 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

28 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

29 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

30 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Advantages of Relational Database a)The relational database structure can be efficiently used even with a computer that has limited memory and processing capability. b)Relational database is very useful for small databases. c)Relational database is much easier to use because it enable a computer system to accommodate a variety of inquiries in an efficient manner. d)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.

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

32 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

33 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

34 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

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

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

37 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Types of output Outputs can be categorized as follows: 1.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 organizations business relations with its customers. 2.Internal outputs: These remain within the organization but still require careful consideration because they may affect the operational efficiency of the total system. 3.Computer operations output: These are required within the computer services department (e.g. usage statistics, control reports, etc.)

38 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

39 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

40 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

41 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

42 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

43 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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).

44 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

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

46 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

47 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

48 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

49 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

50 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Methods of Testing 1.FUNCTIONAL TESTING Does the logic work properly? This means, answering the following: Does the program work as intended? Can it be made to crash? 2.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?

51 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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

52 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

53 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Software Utilities 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.

54 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Sort and Merge 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.

55 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

56 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

57 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

58 Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : 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.

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


Download ppt "Compiled by : S.Agarwal, Lecturer & Systems Incharge, St. xavier's Computer Centre, Kolkata : Principles & Techniques of Programming Compiled."

Similar presentations


Ads by Google