CHAPTER:14 Programming Methodology Prepared By Prepared By : VINAY ALEXANDER ( विनय...

27
CHAPTER:14 Programming Methodology Prepared By Prepared By : VINAY ALEXANDER VINAY ALEXANDER ( ( वववव वववव ववववववववववव ववववववववववव ) ) PGT(CS) ,KV JHAGRAKHAND PGT(CS) ,KV JHAGRAKHAND

Transcript of CHAPTER:14 Programming Methodology Prepared By Prepared By : VINAY ALEXANDER ( विनय...

  • CHAPTER:14Programming MethodologyPrepared By :VINAY ALEXANDER ( )PGT(CS) ,KV JHAGRAKHAND

  • ObjectiveIn this presentation you will learn aboutthe various guidelines regarding development of a good program.Understanding goodness of a programSteps to develop a Program.Errors classification and understandingProgram TestingDocumentation

  • SYLISTIC GUIDELINESMeaningful names for identifiersIdentifiers identify different parts of C++ programs.Identifiers should have meaningful names.Guidelines followed while dealing with identifiers-Assign meaningful names for identifiers. That is Variable, Class and Methods.Do not use similar looking names e. g .,manage ,manager.Always assign names to scalar constants (created with final keyword) as it helps in clarity & readability.

  • Ensure Clarity of Expressions: Expression in the program should be written clearly. Proper parenthesis may be used to enhance the clarity of the expression.Expressions carry out the specified actions.Avoid programming tricks whose intent will not be obvious to a reader.Never sacrifice clarity of expressions even if changed (but unclear) expressions may get you minor gain in machine execution time.Use standard methods in to enhance readability e.g. ,use Math.sqrt () to calculate square root rather than writing your own logic for it.

  • Use Comments & IndentationComments play very important role as they provide internal documentation of a program. Indentation makes the statements clear & readable.C++ comments are given either by //or /*....*/brackets1.Always insert prologues , the comment in the beginning of a program.2.Insert explanatory comments where ever applicable.3.Use comments to help identify {}pairs greatly & enhance program understanding.4.Always indent statements to highlight nesting of groups of control statements.

  • =>The insertion of blank lines & blank spaces: Blank lines can inserted before the declaration of blocks, comment lines, methods prototype etc. It increases readability. Space must be given before and after an operator to make it more readability..=>C++ provides free formatting styles: Program should be pretty typed i.e. All the statement must be written in separate lines. So that program may be readable and understandable.When program is formatting is done to make a program more readable, it is called pretty printing.

  • Characteristics of a Good program:A good Program not only efficiently solves the given problem but also it should be presentable. The following features are expected for its goodness-Effective and efficient: The program produces correct results and is faster, taking into account the memory constraints User Friendly: The program should be user friendly. The user should not be concerned about what is happening inside the program. The user should be only responsible for providing the input data values and rest everything be the programs responsibility.The output provided by the program should also be easily understandable and presentable.

  • Self-Documenting Code: A good program must have self-documenting code. The source code that uses meaningful names for constants, variables and subprogram identifiers to clarity their meaning in the program is called Self-Documenting CodeReliable: The program should be reliable i.e. it must be able to handle unexpected situation like wrong data or no data. The program should display proper error messages.Portable: The program should be portable i.e. It should be able to run on different platforms.

  • STAGES OF PROGRAM DEVELOPMENT PROCESS: A program development problem is a step by step process where each stage contributes to building of an effective and efficient program.=> There are four stages in program development process as given below:1.Crack the problem: The problem is cracked and an algorithm is formulated which gives the solution for the problem.2.Code the Algorithm: The algorithm should be translated into the program(source code)carefully to avoid errors that may crop up.3.Compile the program: It is a process to convert the source code into the object code and reported errors should be rectified4.Execute the program: At the run time ,errors if any ,should be removed & 3rd stage should be repeated to compile & finally execute the corrected version of the program.

  • ROBSTNESSThe ability of a program, to recover following error & to continue operating within its environment, is Robustness.GUARD CODE: The code that can handle exceptional data errors and operational errors is called Guard Code.

  • Types of errors in the programAn error or Bug is anything in the program code that prevents a program to run in correct manner.compile-time errors: An Errors that occur during compiling-time ,are known as compile-time errors.

  • Syntax Error: It is occurred when rules of the programming language are not followed. It is most common due to spelling errors in the Keywords and methods.Semantic Error: It is occurred when a statement written is not meaningful.Ex. X + Y = ZLogical Error: When Program does not give correct result due to mistake in the calculation or use of operators etc. These errors are most difficult to trace in a big sized program.Run Time Error: This error occurred at Run-Time and it is due to incompatible Data Types used, divide by zero in the expression etc. which may cause the termination of program execution abnormally.

  • Run time errors are also called exceptions, and handling such errors in the application is called exception handlingException : Unexpected situation or unexpected error, during program execution is known as Exception. Exception Handling: Way of handling anomalous situation in a program-run , is known as Exception HandlingAdvantages:1. Exception Handling separates error-handling code from normal code.2. It clarifies the code and enhances readability.3. It makes for clear, robust, fault-tolerant programs

  • PROBLEM SOLVING METHADOLOGY AND TECHNIQUESThe following steps are taken while designing a program-1. Understanding the Problem2. Analyzing the Problem3. Designing the Program4. Coding the Program5. Testing & Debugging The Program6. Documentation7. Maintenance of the Program

  • 1.Understand the problem: You must recognize the need of program. Try to explore WHAT component in the problem2.Analyse the problem :After determining the need, carefully analyze the problem to get an effective solution. Try to explore the inputs to get required output.3. Design the program: In this step HOW component is explored. Try to find out the best sequence of steps (Algorithm) to solve the problem. A big problem can be broken in to smaller portion to get effective solution.-The logical sequence of precise steps that solve a given problem , is called Algorithm .

  • 4.Coding of Program: The translate your solution into Programming Language. While translating you need to identify the control structure, arithmetic and logical calculations to be used. An IDE (eg. NetBeans) can be used to code the Program.5.Test & Debug the program: Once a Program has been coded, it can be executed and find out the errors (Syntactical & Logical), if any. The errors also termed as bugs.Testing is the process of finding errors in a program ,and debugging is the process of correcting errors found during the testing process.

  • 6.complete your documentation: Documentation helps to others to understand the program. Details of the program including its source code, Input/Output screen and its operating instructions are recorded and compiled in the form of booklet.7.Maintenance of the Program Maintenance is requiredTo modify the program,To remove the undetected errors orTo enhance the program functionalityTo keep the program up-to-date with its environment.

  • =>DOCUMENTATION: Documentation refers to written descriptions ,specifications, design , code and comment, internal and external to a program , which make a program more understandable , readable and more easily modifiable.MODULES OF DOCUMENTATION: Modules make information easily accessible to the specific user for which they were prepared and they reduce the costs of production and maintenance. The aggregation of modules and their details would depend upon

  • 1. Complexity of the system2. Technical sophisticated of user3. People involved in development and use4. Expected life of documentation=>A User Documentation (or Manual) Should provide the following informationGeneral Description 2. Run flow & Description3. Logic Flow

  • 4. Program Testing5. File Description 6. Record Layouts7. Output Specification8. File Disposal9. Error Message10. Special run instructions11. Security consideration12. Restart and Recovery Procedures

  • =>Programmer s Documentation (Technical Documentation ) : It Provides the technical part of the documentation. It also provide to insure smooth, easy and right maintenance for the system.=>There are two type of Technical Documentation 1. External Documentation 2. Internal Documentation

  • =>The Eternal Documentation of a program consists of a written information that is outside the body of the source code. that is History, modification design ,User manual of a program. =>Internal Documentation: It includes comments, self Documentation code and program formatting .=>Uses of Documentation:1. Facilitates communication about an application between the technical development personnel and the non-technical users

  • 2. Useful for technical personnel not only during development, but also during operations and normal maintenance.3. Essential during abnormal or urgent maintenance4. Very helpful in initiating and training5. Enable trouble shooting when the application system breaks down6. Essential for internal and external control7. Ensures that all commitments and expectation are on record

  • The documentation module (also called Manual) may be following types as per their contents.User Manual: Describes how to use the program and contains all the I/O screens and operating instruction for its user.Operation Manual: Describes the various steps to perform a specific task using the system.Program Manual: It contains the Source code of the program for reference purpose. It is required during program Maintenance.System Manual: It contains overall specification, results of all the programdevelopment stages etc.

  • Program Maintenance: Program maintenance refers to the modification of a program, in order to meet changing requirements or to take care of undetected errors. The following types of Maintenance may occur:Corrective Maintenance: It is required to correct the errors which were undetected during the design of the program.Adaptive Maintenance: Change in users need or program environment may occur and program must be changed to adapt such changes. This change in the program is called Adaptive Maintenance.

  • Preventive Maintenance: Sometimes you could anticipate the errors before they actually occur. Preventive Maintenance is carried out to avoid such errors.Perfective Maintenance: To cope with changing world i.e. changes in the technology, you should tune your system to keep it up-to-date. Due to arrival of newtechnology and facilities, the program is updated to make it perfect in respect of new technological need.