220 likes | 335 Views
PROGRAMMING GUIDELINES. SYLISTIC GUIDELINES Meaningful names for identifiers Identifiers identify different parts of C++ programs. Identifiers should have meaningful names. Guidelines followed while dealing with identifiers- Assign meaningful names for identifiers.
E N D
SYLISTIC GUIDELINES • Meaningful names for identifiers • Identifiers identify different parts of C++ programs. • Identifiers should have meaningful names. • Guidelines followed while dealing with • identifiers- • Assign meaningful names for identifiers. • 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 • 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 & Indentation • Comments play very important role as they provide internal documentation of a program. Indentation makes the statements clear & readable. • JAVA comments are given either by //or /*....*/brackets 1.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 at appropriate spaces enhance the program readability. • C++ provides free formatting styles. • When program is formatting is done to make a program more readable, it is called prettyprinting.
Characteristics of a Good program • 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 program’s 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 Code • Reliable: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 1.Crack the problem 2.Code the Algorithm 3.Compile the program 4.Execute the program It is desirable to prune the possible errors in every stage of the program ,not at the run time only.
At 1st stage ,algorithms efficiency &correctness should be checked. • At 2nd stage ,the algorithm should be translated into the program very carefully to avoid errors that may crop up. • At 3rd stage the reported errors should be rectified. • At the run time ,errors if any ,should be removed & 3rd & 4rth stage should e repeated to compile & execute the corrected version of the program. • ROBSTNESS The ability of a program, to recover following error & to continue operating within its environment, is Robustness.
The code that can handle exceptional data errors and operational errors is called Guard Code. TYPE OF ERRORS • Compile – time errors • Errors that occur during compiling-time ,are compile-time errors.
Syntax errors • Syntax refers to formal rules governing the construction of valid statements in a language. • Semantics Errors • Semantic errors occur when statements are not meaningful. • Semantic refers to set of rules which give the meaningful of a statement. • Run-time Errors Errors that occur during the execution of a program are run time errors. These are harder to detect errors .
Some run time errors stop the execution of the program , which is then called program crashed ,or “abnormally terminated.” • Logical Errors • Logical errors occur due to mistaken analysis of the program.
PROBLEM SOLVING METHADOLOGY AND TECHNIQUES The steps to creating a working program are : 1.Understand the problem well -under this we have to understand the problem well so as to figure out “what is required or desired out of the purpose solution ?”and hence to ascertain “what it is that it is to be done. 2.Analyse the problem : - identify minimum number of inputs required for output. - identify processing components
3.Design the program by -deciding step by step solution, & breaking down solution into simple steps. The logical sequence of precise steps that solve a given problem , is called Algorithm . • 4.code of program by -identifying arithmetic & logical operations required for solution -using appropriate control structures such as conditional or looping control structure
Test and debug your program • -rectifying the errors- • 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 is extra information made available to enhance understandability and usability of the program. • 7.mantain your program: It involves modifying the programs to remove previously undetected errors , to enhance the program with different features or functionality ,or to keep the program up -to –date as government regulations or company policies changed.
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 system 2. Technical sophisticated of user 3. People involved in development and use 4. Expected life of documentation A User Documentation (or Manual) Should provide the following information • General Description 2. Run flow & Description 3. Logic Flow
4. Program Testing 5. File Description 6. Record Layouts 7. Output Specification 8. File Disposal 9. Error Message 10. Special run instructions 11. Security consideration 12. 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 maintenance 4. Very helpful in initiating and training 5. Enable trouble shooting when the application system breaks down 6. Essential for internal and external control 7. Ensures that all commitments and expectation are on record
PROGRAM MAINTENANCE i) Corrective maintenance ii) Adaptive maintenance iii) Preventive maintenance iv) Perfective maintenance.