Uploaded by hacker132

Revision notes for P2

advertisement
Revision notes for theory part of paper-2
Algorithm: Sequence of steps to be followed in the completion of a task.
There are several methods to represent an algorithm
 Structured English
 Pseudocode
 Flowchart
Algorithms usually performs three different activity Input: Entering data to a system for processing
 Process: Performing calculation or assigning values
 Output: Displaying result after processing
Features used to make a Pseudocode easier to read and understand:






Indentation
Using meaningful identifier
Annotation or commenting
Capitalization of keywords
Putting gap between lines
Modularization
Programming Constructs:
 Sequence: sequential execution of the instructions.
 Selection: determines which path the program control should take based on a condition
 Iteration: repeatedly executing a statement or set of statements for a certain number of
times or until a condition is satisfied.
Stepwise Refinement: Process of breaking down a task into series of subtasks from which it becomes
easier to program.
Decomposition/ Modularization: Process of breaking down a complex system into smaller parts that are
more manageable and easier to understand.
Benefits of Modularization/Decomposition:
 It reduces the complexity of a program since a program is divided into smaller
manageable subprograms
 Debugging and testing the program become easier as individual
subroutines/modules can be debugged or tested separately.
 The subprograms can be reused.
 Different programmer get scope to work on same program as a result it reduces the
development time.
Subroutine: A set of statements that can be grouped together and easily called in a program whenever
required, rather than repeating all of the statements each time.
 Function: It is a subroutine which must return a single value to the calling program
 Procedure: It is a subroutine which usually does not return any value to the calling program.
Library Routine: A tested and ready-to-use subroutine available in a programming language that can be
incorporate into a program.
User define Routine: A subroutine written by the user to perform a specific task required by a program.
Advantages of using Library Routine:




These are robust(Unlikely to fail)
Saves time
Available to all programs
Well tested and tried
Disadvantages of using Library Routine:
 It cannot be edited
 Decreases the speed of execution slightly
Advantages of using User define functions:





These can be reused
These can be edited
More specific to the requirements
Easy to debug and maintain
Reduces complexity of the program
Similarities between built-in function and user defined function:






They both have an identifier(Name)
They return a value
They have none, one or more parameters
Both perform a specific task
Both represent re-usable code
Both are 'called’
Difference between built-in function and user defined function:
 Built-in functions are made available by the programming language / already in the
system
 Built-in functions are ready made and tested
 User-defined functions can be modified but built in function cannot be modified.
 User defined functions can be designed to meet the user's requirements
 User-defined functions can only be used in that program but built in function can be
used in any program
Arguments: The list of variables used in a calling function.
Parameters: The list of variables used in the header of a function definition.
Explain why parameters are used with subroutines:




To pass values to/from subroutine
To avoid using of global variables
To allow recursion
To make the subroutine re-usable
Parameter passing method:
 By value (ByVal): Only a copy of the variable is sent as parameter. Changes to
the value of the variable will not change the variable outside the module.
 By Reference (ByRef): The address of the variable is passed. Original value of
the variable will be changed if any change is made to the variable inside the
module.
Scope of a variable:
 Local Variable: The variables which are declared in a subroutine and works within the
subroutine.
 Global Variable: The variable which are declared at the beginning of the program and
works in all of the subroutines in that program.
Structure chart: a chart which shows the breakdown of a system to its lowest manageable
levels.
Features that are shown on a structure chart:





Hierarchy of modules
Parameters that are passed through each module
Sequence of module execution.
Selections.
Iterations.
Transferrable Skill: any existing skill that can be used to handle a new situation. Programming is
a transferrable skill, as skill of a programming language can be used to recognize common
features of an unknown programming language. It can be able to recognize variable
declarations, data types, assignments, sequence, selection, iteration, modules, etc.
Data Structure: A particular way of organizing data in a computer so that it can be used
effectively. Followings are examples of data structures








Variable
Constant
Array
Stack
Queue
Linked List
Binary Tree
Graph
Hash Table
Features of IDE:
For presentation:
 Pretty printing: different color coding of keywords
 Auto indentation
 Expansion and collapse block: Displays choice of keywords and available identifiers
appropriate at current insertion point and provides choices in alphabetical order
For initial error:
 Dynamic syntax check: Automatic checking and highlighting of syntax errors, as soon as
line typed
 Type checking
 Checking for unused variable are declared/ checking for used variable which are not
declared
For debugging:
 Breakpoint: Pauses program at a specific line to ensure program operates correctly up
to that line.
 Single stepping: Executes program line-by-line to see the effect of each statement on
variables.
 Variables/expressions Report or watch Window: Monitors variables for comparing
values.
Purpose of a Development Life Cycle: The process of developing a program set out in five
stages: analysis, design, coding, testing, maintenance.
Analysis: Process of investigation, leading to specification of what the program is
required to do.

Face to face interview

Observation

Questioner

Analyzing manual document.
Design: Develop logic plan, using the analysis.

Designing file structure

Designing Input/Output screen

Designing algorithm

Designing test plan.
Coding: The writing of the program
Testing: the testing of the program to make sure it works under all conditions
Maintenance: Makes sure that the program continues to work during use.
There are three different models can be used in software development:
•
Waterfall Model
•
Iterative Model
•
Rapid Application Development (RAD)
Waterfall Model: A linear sequential program development cycle, in which each stage is
completed before the next is begun.
Benefits:
 Easier to manage, understand and use.
 Stages do not overlap and are completed one at a time.
 Each stage has specific outcomes.
 Works well for smaller programs where requirements are known and
understood.
Drawbacks:
 Difficult to change the requirements at a later stage.
 Work program is produced late in the life cycle
 Not suitable for long, complex projects.
Iterative Model: A initial representation starts with a small subset, which becomes more
complex over time until the system is complete.
Benefits:




Some working programs developed quickly at an early stage in the life cycle.
Easier to test and debug smaller programs
More flexible as easier to alter requirements.
Customer involved in each iteration then no surprises when final system delivered
Drawbacks:
 Whole program needs to be defined at start, so it can be broken down into modules to
be developed at each iteration.
 Not suitable for short simple projects
 More resources might be required.
 Needs good planning for every stage.
Rapid Application Development (RAD): a prototyping model, with no (or less) specific planning
put into it. More emphasis on development and producing a product-prototype. A prototype is
a working model of part of the solution. High customer involvement, as customer can use the
prototypes during development.
Benefits:




Reduced overall development time.
Quick initial reviews occur.
Very flexible as requirements are met from the feedbacks of customers.
Modification is easier.
Drawbacks:
 Requires skilled developers
 Only systems that are modularized can be built using RAD.
 Not suitable for short simple projects.
Types of Error:
 Syntax Error- When source code does not obey rules of the language.
 Logical Error- Program works but gives incorrect output due to incorrect
logical/arithmetical statements.
 Run-time Error- An error found in a program when it is executed.
Examples: Division by 0, Out of array index/subscript, Trying to open a file which is not
exist, etc.
Methods of testing:
White-box testing: In this test, all the possible paths of a program are tested.
Black-box testing: In this test, the expected outcomes is checked against inputs.
Alpha-testing: The testing which is carried out by technical persons who were not involved in
the program development. It is usually done in development stage.
Beta-testing: The testing of a completed program by a small group of users before it is released.
Stub testing: Testing the main program without completing the codes of the subroutines. There
a dummy messages/returning values are given as body of the subroutines to indicate that the
subroutine is used.
Integration Testing: Taking modules that have been tested on individually and testing on them
combined together.
Acceptance: A test carried out by the intended users of the system, the people who requested
the software. It is used to prove to the customer that the software works exactly as required.
Manual debugging tools:
Dry run/Tracing: A process where code is manually traced, without any software used.
Walkthrough: A formal version of a dry run, done by team members etc.
Types of test Data: example range is 1 to 100(inclusive)
 Normal data: Any values between 1 to 100(inclusive)
 Abnormal Data: Any values out of the range of 1 to 100
 Extreme Data; the upper and lower bounds. 1 and 100
 Boundary Data: Immediate upper or lower value from the
range like 0 and 101. They are rejected.
Types of Maintenance:
 Corrective: To correct any errors in a program that appears
during use
 Adaptive: The alteration of a program to append some new
requirements.
 Perfective: Process of making improvements to make a
program more efficient.
Download