CHAPTER:11 Programming Guidelines in JAVA Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.

Slides:



Advertisements
Similar presentations
Topics Introduction Types of Errors Exceptions Exception Handling
Advertisements

P5, M1, D1.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
A Review. a review of lessons learned so far… ( 2 steps forward - 1 step back) Software Development Cycle: design, implement, test, debug, document Large.
Chapter 2: Input, Processing, and Output
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Introduction to High-Level Language Programming
1 Shawlands Academy Higher Computing Software Development Unit.
CHAPTER:14 Programming Methodology Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Java Programming Exception Handling. The exception handling is one of the powerful mechanism provided in java. It provides the mechanism to handle the.
Programming Translators.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Programming Lifecycle
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
The Java Programming Language
PROGRAMMING METHODOLOGY STYLISTIC GUI DELINES Meaningful Names for Identifiers. Guidelines followed while dealing with identifiers. 1. Assign meaningful.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Chapter 1 Introduction to Structured Design. Introduction  System  A combination of people, equipment, and procedures that work together to perform.
SE: CHAPTER 7 Writing The Program
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
I Power Higher Computing Software Development The Software Development Process.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
The Software Development Process
1 Program Planning and Design Important stages before actual program is written.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
PROGRAMMING GUIDELINES. SYLISTIC GUIDELINES  Meaningful names for identifiers Identifiers identify different parts of C++ programs. Identifiers should.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Program Development Cycle
Intermediate 2 Computing Unit 2 - Software Development.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
Error Handling Tonga Institute of Higher Education.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Eighth Lecture Exception Handling in Java
Lecture 1 Introduction Richard Gesick.
C++ Plus Data Structures
Chapter 2: Input, Processing, and Output
The Software Development Cycle
About the Presentations
Programming Problem steps must be able to be fully & unambiguously described Problem types; Can be clearly described Cannot be clearly described (e.g.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Computer Programming.
Designing and Debugging Batch and Interactive COBOL Programs
Unit# 9: Computer Program Development
PROGRAMMING METHODOLOGY
Algorithm Correctness
Chapter 2: Input, Processing, and Output
CHAPTER 6 Testing and Debugging.
The Software Development Cycle
Presentation transcript:

CHAPTER:11 Programming Guidelines in JAVA Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND

Objective  In this presentation you will learn about the various guidelines regarding development of a good program.  Understanding goodness of a program  Steps to develop a Program.  Errors classification and understanding  Program Testing  Documentation

STYLISTIC GUIDELINES  Meaningful names for identifiers  Identifiers identify different parts of Java programs.  Identifiers should have meaningful names.  Guidelines followed while dealing with identifiers-  Assign meaningful names for all 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.  Avoid programming tricks whose intent will not be obvious to a reader.  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:  Blank lines can inserted before the declaration of blocks, comment lines, method’s prototype etc. It increases readability. Space must be given before and after an operator to make it more readability..

 Statement Formatting  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 prettyprinting.

 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 program’s responsibility.  The output provided by the program should also be easily understandable and presentable.

 Self-Documenting Code: The source code of the program should have meaningful names for Identifiers and Variables, and proper comment should be used to make it self-documenting.  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: A Program should be portable i.e. It can run on different Hardware and software platform.

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 rectified 4.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.

 ROBSTNESS The 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 program An 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 = Z  Logical 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 handling  Exception : 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 Handling Advantages: 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

Concept of Exception Handling  The raising of imaginary error flag is called throwing an error. When as error is thrown, the overall system responds by catching the error. And surrounding a block of error-sensitive code-with- exception-handling is called trying to execute a block  Exceptional Handling in Java: In java exception handling is done using try{ } and catch{ } blocks. Statements that can raise an error are placed inside the try{ } block and its handling code is written inside the catch{ } block.  if there are multiple exceptional classes that might arise in the try block, then several catch block are allowed to handle them.code must be executed no matter what happens can be placed in finally block.

 The thrown keyword: Keyword thrown is used to inform that an error has occurred. It is specified with method prototype. i.e., Public static void main(String[ ] args) throws IOException  Syntax: try { // tested statement(s); } Catch(ExceptionName e1) { // Trap handler statement(s); } Catch(ExceptionName e2) { // Trap handler statement(s); } Finally { // always executed block } try { int age=Integer.parseInt(ageTF.getText()); } Catch(Exception e) { JOptionPane.showMessageDialog(null, “Enter a Numeric Value”); }

PROBLEM SOLVING METHADOLOGY AND TECHNIQUES The following steps are taken while designing a program- 1. Understanding the Problem 2. Analyzing the Problem 3. Designing the Program 4. Coding the Program 5. Testing & Debugging The Program 6. Documentation 7. Maintenance of the Program

1.Understand the problem: You must recognize the need of program. Try to explore ‘WHAT’ component in the problem 2.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 bet sequence of steps (Algorithm) to solve the problem. A big problem can be broken in to smaller portion to get effective solution.

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 required To modify the program, To remove the undetected errors or To enhance the program functionality To keep the program up-to-date with its environment.

 General Debugging Methods: 1.Create the main class first. 2. Test each method separately. 3. Trace code Blocks. 4. Insert debug code. 5. Test the program under different conditions.

Program verification Program verification is the process of determining the degree to which a software product fulfills its specification.  Types of Program verification 1.Deskchecking: It is a manually verifying of a program. the essential data are written down and the programmer walks the design as specified by the statements, making changes in the data on the paper 2. Walk-through : a manual simulation of the program with simple test input is performed, by a team keeping track of the program’s data on the paper or on a black board. It is not intended to simulate all possible test cases. 3. Inspection: A team carries out the inspection where a reader reads the code line by line. inspection participants point out errors that are recorded on an inspection report.

Program Testing A Program must be tested to remove the errors. The following types of testing methods may be used. 1.Unit Testing: In this method, a single unit (module or package) of the program is tested to meet its specification. It is much easier to test and debug a small module (units) one at a time. 2.Functional (Black Box) Testing: The functionality of the module or program is tested by giving possible input values, treating the code (program) as a “Black box” without concerning its internal working.

3.Structural (White Box) Testing: In this testing module or program is tested to trace the all path of execution of statements in the module. This technique is used to see the structural behavior of the program. 4.Path Testing: In this technique, all the possible paths of statement are tried to execute by giving possible input values or test cases. 5. Metric Based Testing: The goals are based on certain measurable factors. These measurements can also be used to indicate when certain level of testing has been completed

6.Integration Testing: This technique is performed to integrate all the program modules (units) that have been tested independently in unit testing. It can be Top- Down, Bottom-up or in combined approach.

 DOCUMENTATION: A proper developed application must be equipped with its explanations and descriptions to facilitate users. Documentation refers to written descriptions, design, code and comment, internal and external requirement to the 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

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 program development 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 user’s 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 new technology and facilities, the program is updated to make it perfect in respect of new technological need.