Professional Documents
Culture Documents
Basics of Programming
Courses
Course Objective
The objective of this course is to introduce the concepts of
programming, structure and interpretation of computer programs and
algorithms. This course is aimed at participants with little or no programming
experience. By the end of this course the participant should be justifiably
confident of their ability to write small programs that allow them to
accomplish useful goals.
Course Content
1.
Introduction to Programming
i.
ii.
2.
3.
What is Programming?
iii.
Introduction to Variables
iv.
Introduction to Operators
v.
Control Structures
https://aspire.tcs.com/aspire/courses/basics_of_programming/index.html
1/3
12/9/13
vi.
vii.
viii.
4.
ii.
iii.
ii.
7.
Composite Datatypes
Programming Approaches
i.
6.
Introduction to Functions
5.
Introduction to Arrays
Structured Programming
Modular Programming
Introduction to Optimization
ii.
iii.
iv.
Introduction to Testing
Who Does Testing
iii.
Testing Approaches
iv.
Levels of Testing
v.
vi.
Testing Techniques
When to Start and Stop Testing
https://aspire.tcs.com/aspire/courses/basics_of_programming/index.html
2/3
12/9/13
vii.
8.
Debugging
iii.
iv.
Courses
https://aspire.tcs.com/aspire/courses/basics_of_programming/index.html
3/3
12/9/13
Basics of Programming
Introduction to Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.1_what-is-programming_1.html
2/2
12/9/13
Basics of Programming
Introduction to Programming
2.
3.
4.
5.
1/4
12/9/13
pseudo code is not executable on the computer. It lets you state your solution
with more precision than plain English. However psuedo code has lesser
precision than is required when using a formal programming language. An
example is given below:
Example : Read number n and print the integers counting up to n.
Read n
Initialize the variable i to 1
while i 'less than or equal to n' do
Print i
Increment i
end while
Stop
In the above example, the program enters the while loop only if
the condition ( i less than or equal to n) is true. Two statements Print i and
Increment i are executed for each iteration. At the end of each iteration, the
condition is evaluated again and the loop continues as long as the condition is
true.
Flowchart
It is a pictorial representation of a step-by-step solution to a
problem. It consists of arrows representing the direction the program takes
and boxes and other symbols representing actions. It is a map of the steps
involved in a program. The American National Standards Institute (ANSI) has
come up with a standard set of flowchart symbols. The following figure shows
the flowchart symbols and how they might be used in a simple flowchart of a
everyday action preparing a letter for mailing.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.1_what-is-programming_2.html
2/4
12/9/13
flow chart.
Please refer the links below to learn more about pseudo code and
http://ceng.anadolu.edu.tr/emrekacmaz/bil158/flowchartpseudocode-examples.pdf
http://ozark.hendrix.edu/~burch/csbsju/cs/150/sched/pseudo.pdf
http://www.cosc.canterbury.ac.nz/tim.bell/dt/Tutorial_Pseudocode.pdf
http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html
3/4
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.1_what-is-programming_2.html
4/4
12/9/13
Basics of Programming
Introduction to Programming
Desk-checking
2.
Translating
3.
Debugging
Let us discuss each of these phases.
Desk-checking
This is similar to proofreading. This phase is sometimes avoided
by the developer/programmer who is looking for a shortcut and is eager to run
the program on the computer once it is written. However, with careful deskchecking we can discover several errors and possibly save our time in the long
run. In desk-checking you simply sit down and mentally check or trace, the
logic of the program in an attempt to ensure that it is error-free and is in
workable condition. Many organizations take this phase a step further called
as walk through, a process in which a group of programmers review the
program and make suggestions or comments in a collegial way.
Translating
A translator is a program that
I.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.1_what-is-programming_3.html
1/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.1_what-is-programming_3.html
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.1_what-is-programming_3.html
3/3
12/9/13
Basics of Programming
Introduction to Programming
2.
3.
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.2_why-programming-is-required_1.html
2/2
12/9/13
Basics of Programming
Introduction to Programming
Machine languages
2.
Assembly languages
3.
High-level languages
4.
5.
Natural languages
Let us look at each of these categories.
1. Machine languages
Humans do not like to deal with numbers alone: they prefer
letters and words also. machine language consists of numbers. Eeach type of
computer has its own machine language. This lowest level of language,
represents data and program instructions as 1s and 0s-binary digits
corresponding to the on and off electrical states in the computer. In the early
days of computing, programmers used rudimentary systems for combining
numbers to represent instructions such as add or compare. These programs
are not convenient for people to read and use and the industry quickly moved
to develop assembly languages.
2. Assembly languages
Assembly languages are considered as very low level language.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.2_why-programming-is-required_2.html
1/3
12/9/13
They are not as convenient to use as the more recent languages. At the time
they were developed, however, they were considered as a great leap forward.
To replace the 1s and 0s used in machine language, assembly languages use
mnemonic codes. Mnemonic codes are abbreviations that are easy to
remember: A for add, C for compare, MP for Multiply and so on. Although
these codes are not English words, they are better accepted than numbers (0s
and 1s)alone. Just like machine language, each type of computer has its own
assembly language.
The programmer who uses an assembly language requires a
translator which is used to convert the assembly language program into
machine language. A translator is required because machine language is the
only language that the computer can actually execute. The translator is an
assembler program, which is also referred to as an assembler. It takes the
programs written in assembly language and converts them into machine
language. Programmers need not worry about the translating aspect, they only
need to write programs in assembly language.
Although assembly languages represent a step forward, they still
have many disadvantages. A key disadvantage is that assembly language is
detailed to the extreme, making assembly language programming repetitive,
error prone and tedious.
3. High-Level Languages
The first widespread use of high-level languages in the early
1960's transformed programming into something quite different from what it
had been. Programs were written in an English-like manner, thus making them
more easy and convenient to use. A programmer can accomplish more with
less effort, and programs can now take care of much more complex tasks.
These so-called third generation languages spurred a great
increase in data processing that characterized the 1960's and 1970's. During
that period, the number of mainframes in use increased from hundreds to tens
of thousands.
A translator is used to translate the symbolic statements of a
high level language into computer executable machine language, this
translator is usually called as a compiler. There are many compilers for each
language and one for each type of computer. For example, it is necessary to
have a COBOL compiler for each type of computer on which COBOL programs
are to be run. A program can be compiled to different machine language
versions on different machines, the source program itself, the COBOL version
can be essentially identical on each machine.
Some languages are used to serve a specific purpose, such as
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.2_why-programming-is-required_2.html
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.2_why-programming-is-required_2.html
3/3
12/9/13
Basics of Programming
Introduction to Programming
II.
III.
IV.
5. Natural Languages
The word "natural" has become most popular in computing
circles. Fifth generation languages are most often called natural languages
because of their resemblance to the "natural" spoken English language. Instead
of being forced to key correct commands and data names in correct order, a
manager tells the computer what to do by keying in their own words.
1/2
12/9/13
http://homepage.cs.uri.edu/faculty/wolfe/book/Readings/Reading13.htm
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module1/session1.2_why-programming-is-required_3.html
2/2
12/9/13
Basics of Programming
Introduction to Programming
1/2
12/9/13
programming concepts. For many years, Pascal was considered the entry
language for such people, and was generally used in schools and universities to
teach programming at a professional level. Nowadays more "practical"
languages like C++, C#, and Java are taught, for the reason that they provide a
more direct approach to learning how to develop software with tools that are
more commercially viable than Pascal.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.1_overview-of-software-development_1.html
2/2
12/9/13
Basics of Programming
1/6
12/9/13
2/6
12/9/13
At the design documents stage, you have to define what is in that black box.
The design documents are usually created by the senior software
developers and these documents define individual software components to the
level of functions and procedures. This is the last document completed before
development of the software starts. These design documents are passed on to
software developers as they begin coding. Architecture documents and MRDs
usually need to stay in sync, as sales and marketing will work from MRDs
while engineering works from engineering documents.
3/6
12/9/13
2.1.1.5 Testing
Testing is probably the most important phase for long-term
support as well as for the company's reputation. If you dont control the
software quality, it will not be able to compete with other products on the
market. If software crashes at the site of the customer, he loses productivity as
well money and you lose credibility. On most occasions these losses are huge.
Unhappy customers will never buy other products from the same vendor and
will not refer other potential customers. You can avoid this situation by doing
extensive testing. This testing is often called as Quality Assurance, or QA, in
the software world. Generally testing starts as soon as the initial software
components are available. There are multiple types of testing. Each of these
has its own importance.
1. Unit Testing - Unit testing is testing one part or one component
of the product. The developer generally does this when he/she has completed
writing code for that part of the software. This makes sure that the component
is doing what it is intended to do. This also saves time for software testers as
well as developers by eliminating many cycles of software being passed back
and forth between the developer and the tester. When a developer is ready with
a particular part of the software, he/she can write test cases to test
functionality of this part of the software. The component is then passed on to
the testers who run test cases to make sure that the unit is working properly.
2. Sanity Testing - Sanity testing is a very basic check to see if all
software components compile with each other without any problems. This is to
ensure that developers have not defined conflicting or multiple functions or
global variable definitions.
3. Regression or Stress Testing - Regression or stress testing is a
process done in some projects to carry out a test for a longer time period. This
type of testing is used to determine behavior of a product when used
continuously over a period of time. It can expose some bugs in software like the
ones related to memory leakage. In some cases developers allocate memory but
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.1_overview-of-software-development_2.html
4/6
12/9/13
forget to release it. This is usually referred to as memory leakage. When testing
goes on for many days or weeks, it often results in allocation of all of the
available memory until no memory is left. This is the point where your
software starts showing abnormal behavior. Another potential problem in
long-term operation is counter overflow. This happens when you increment a
counter but forget to decrement it resulting in an overflow when the product is
used for long time. The regression testing may be started as soon as some
components are ready. This type of testing requires, by its very nature, a very
long period of time. The process should be continued as more components of
the product are integrated. The process of integration and communication
through interfaces may create new bugs in the code.
4. Functional or System Testing - Functional testing is carried out
to make sure that the software is doing exactly what it is supposed to do. This
must before any software is released to customers. Functional testing is done
by testers whose primary job is software testing, not the developers
themselves. In small software projects where a company cant afford dedicated
testers, other developers may also do functional testing. The key point to keep
in mind is that the person who wrote a software component should not be the
person who tested it. A developer will always have a tendency to test the
software the way he/she wrote it. He/she may easily miss any problems in the
software. The testers need to prepare a testing plan for each component of the
software. A testing plan would contain test cases that are run on the software.
The tester can prepare these test cases using functional specifications
documents. The tester may also get assistance from the developer to create test
cases. Each test case must include methodology used for testing and expected
results. Additionally, the tester may also need to create a certain infrastructure
or environment to test the functionality of a piece of code. For instance, you
may simulate a network to test routing algorithms that may be part of a router.
The next important job of the tester is to create a service request if an anomaly
is found. The tester must include as much information in the service request as
possible.
Typical information included in reporting bugs includes:
Test case description
How the test was carried out
Expected results
Results obtained
A description of that environment, If a particular environment
was created for testing.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.1_overview-of-software-development_2.html
5/6
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.1_overview-of-software-development_2.html
6/6
12/9/13
Basics of Programming
1/3
12/9/13
Future enhancements
If a user needs a change in the configuration process, it is also
mentioned
Generally a user must be given enough information to
understand the new release enhancements and decide whether an upgrade is
required or not.
2.1.1.7 Documentation
There are broadly three categories of documentation related to
software development processes
Technical documentation developed during the development
process, such as the architecture, functional and design
documents.
Technical documentation prepared for technical support staff,
including technical manuals that support staff use to provide
customer support.
End-user manuals and guides. This is the documentation for the
end user to assist the user getting started with the product and
using it.
All three types of documents are necessary for different aspects
of the support of the product. Technical documents are necessary for future
development, bug fixes, and adding new features. Documentation for technical
support staff contains information that is too complicated for the end user to
understand and use. The support team needs this information in addition to
user manuals to better support customers. Finally each product should have
the user manuals. Technical writers often develop user manuals which are
based on functional specifications. In the timelines of most software
development projects, even before the start of code development, functional
specifications are prepared. So the technical writers can start writing user
manuals while developers write the code. So when the product is ready, the
user manuals is almost completed.
2/3
12/9/13
products.
Most common support requests from customers are related to
one of the following:
Help in installation and getting started.
To release a patch or update to the whole product.
A new feature is required by the customer.
In addition to that, you may also want to add new features to the
product for the next release because competitor products have other features.
Better support will increase your customer loyalty and will create referral
business. You may adopt two strategies to add new features. You may provide
an upgrade to the current release as a patch, or wait till you have developed a
list of new features and make a new version. Both strategies are useful
depending how urgent the requirement for new features is.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.1_overview-of-software-development_3.html
3/3
12/9/13
Basics of Programming
What is a Problem?
A problem can be defined as an opportunity for improvement.
Every problem has a gift for you in its hands, says Richard Bach. An
optimist looks at challenging or problematic events as potential opportunities
for improvement. He will be always seeking answers for the questions such as:
Is there more than one probortunity? "Probortunity a synonym
by combining the words problem and opportunity.
Is it my personal probortunity or Is it the probortunity of the
organization?
Is it an annoyance or an actual probortunity?
Is this the real probortunity, or merely a symptom of a larger
one?
A problem can be defined as the difference between the actual
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_1.html
1/2
12/9/13
state and desired state. A problem could also be the result of the knowledge
that there is a gap between the actual and desired or ideal state of objectives.
Clarity of the problem is determined by the clarity of the knowledge which one
precisely wants and which one has. Greater clarity of the problem will help in
finding a better and an effective solution.
A problem can also result from the recognition of an imperfect
present and the belief in the possibility of a better future. The belief that ones
hopes can be achieved will give one the will to aim towards a better future.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_1.html
2/2
12/9/13
Basics of Programming
A. Rational Problem-Solving
Rational problem solving rests on the following principles (R. K.
Wagner - Learning to solve practical problems):
Problems are identified by comparing actual performance with
an expected standard performance
Problems are deviations in actual performance from the expected
standard
A precise and complete description of the problem is needed to
identify a solution:
What is happening?
Where is it happening?
When is it happening?
To what extent is it happening?
The cause of the problem can be found by comparing the
problem and non-problem situations.
Recent problems are due to the result of some change in the
situation that has caused an unwanted deviation from
expectations.
The Rational Decision-Making Model requires the following steps
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_2.html
1/3
12/9/13
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_2.html
3/3
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_3.html
1/4
12/9/13
2/4
12/9/13
3/4
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_3.html
4/4
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_4.html
2/2
12/9/13
Basics of Programming
5. Select the best solution: Now that there are a wide variety of
possible solutions available, it is time to select the best solution from among
them to fix the problem, given the circumstances, resources and other
considerations. Here the managers are trying to figure out what exactly would
work best given the nature of the problem. There are always a number of
things that can affect a solution, for instance, money, time, resources,
procedures, rules, policies, and so on. All of these factors must be thought
about. Managers should prioritize the solutions by their effectiveness. This is a
slow process of elimination. There may be some possible suggestions that may
need to be immediately eliminated. Eventually, managers should narrow down
the choices to one best possible solution which will promise them the best or
optimal outcomes.
6. Implementation: Implementation is a crucial part of problemsolving process. In order to implement the solutions chosen, managers must
have an action plan and communicate it to those people who are directly and
indirectly affected. Gemmy Allen (Problem-Solving & Decision-Making) says
that communication is most effective when it precedes action and events. In
this way, events conform to plans and events happen when, and in the way,
they should happen. Managers should answer the below vital questions before
they are asked, like
What should be communicated?
What is the possible reason for the decision?
Whom all will it affect and how?
What are the benefits expected for the individual, department,
and the organization as a whole?
What adjustments will be required in terms of how work will be
done?
What is each individuals role in implementing the decision?
What are the results expected from each individual?
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_5.html
1/2
12/9/13
When does the action called for by the decision go into effect?
7. Evaluation: This is the final step in the problem-solving
process. Managers should review the effectiveness of the solution against
desired outcomes. Questions like did the solution work? If not, why? What
went right, and what went wrong? What adjustments do they have to make to
ensure that the solution will work better? This stage will require careful
analysis that improves upon the best solution.
The review of your progress can help a manager identify any
problem. Steps may need to be revised or new steps need to be added. One may
need to consider a different solution, if the current one, with which he/she has
been, is not helping.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_5.html
2/2
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.2_overview-of-problem-solving-techniques_6.html
2/2
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module2/session2.3_phases-in-the-execution-of-a-computer-program_1.html
2/2
12/9/13
Introduction
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.1_introduction-to-basic-programming-concepts.html
1/1
12/9/13
Datatypes
Basics of Programming
3.2 Datatypes
3.2.1 Data and Datatypes
Programs need data in the form of numbers, time, names, date,
description etc.
Consider a program to calculate the sum of two numbers.
sum = x+y
Here the two numbers are the data and the type of data (numeric
data-integer, decimal etc.) is data type. In more elaborate terms, a data type
used in a program determines the type of data, memory needed for storing the
data, and the kind of operation that can be performed with the data (e.g. you
can multiply two numbers together, you can concatenate alphabets and make
it a word and multiple words into a sentence.)
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.2_datatypes_1.html
1/2
12/9/13
Datatypes
What can we infer from the figure above? We can see that
different types of data like integer , string , date etc. have been used in the
above form.
A datatype represents the type of data, memory storage and the
operations that can perform using the data.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.2_datatypes_1.html
2/2
12/9/13
Datatypes
Basics of Programming
Example Value(data)
Numeric
100, 99.99 , -7
Character(char)
Logical(boolean)
true, false
String
Numeric Types
Data Type
Common sub
types
Description
Example
Integer
int, long
represents integers
9009, -1
Floatingpoint
float , double
represents real
numbers
99.99,
0.0001
1/2
12/9/13
Datatypes
types.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.2_datatypes_2.html
2/2
12/9/13
Variables
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.3_variables_1.html
1/3
12/9/13
Variables
Program Steps:
Declare a variable radius to store radius of the circle.
Declare a variable area to store the area of circle.
Declare a constant Pi to store the constant value.
Calculate the area of circle ( Pi* radius* radius).
Store the result in variable area
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.3_variables_1.html
2/3
12/9/13
Variables
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.3_variables_1.html
3/3
12/9/13
Variable
Basics of Programming
1/3
12/9/13
Variable
2/3
12/9/13
Variable
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.3_variables_2.html
3/3
12/9/13
Operators
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.4_operators.html
1/2
12/9/13
Operators
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
Operators are special symbols that perform specific operations on
one or two operands, and then return a result.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.4_operators.html
2/2
12/9/13
Control Structures
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.5_control-structures_1.html
1/2
12/9/13
Control Structures
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.5_control-structures_1.html
2/2
12/9/13
Control Structures
Basics of Programming
1/2
12/9/13
Control Structures
if
if-else
switch
3.5.2.3 Repetition
Executing one or more steps of an algorithm or program based on
some condition. The repetition control structure is also known as the looping
or iteration control structure.
The following are the common looping control structures use in
programming languages.
while
do-while
for
Links for reference:
http://www.scriptingmaster.com/asp/conditional-logic.asp
http://www.tutorialspoint.com/java/java_loop_control.htm
http://revolution.byu.edu/programmingconcepts/ControlStruct.php
http://www.cplusplus.com/doc/tutorial/control/
http://www.tutorialspoint.com/java/java_decision_making.htm
Sequence, Selection and Repetition (Iteration) are the three main
control structures used to control the flow of program.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.5_control-structures_2.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.6_arrays_1.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.6_arrays_1.html
2/2
12/9/13
Basics of Programming
Array Creation
Language
Syntax
Example Value(data)
C/C++
datatype array-name[size]
char albhabets[26]
Java
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.6_arrays_2.html
1/3
12/9/13
variable_name = array_name[index];
Eg. num1 = nums_array[4];
3.6.2.4 Array creation example
Consider a program that stores the scores of the participants who
attended a quiz and calculates the average score of all participants.
The type of data(quiz score and average score) which we need to
use in this program is numeric.
If the selected programming language is Java/C/C++, then we can
select int or float as numeric type. Lets select int for individual score and float
for average score.
Assume the total number of participants as 100 and declare a
constant named SIZE that stores the total number of participants.
const int SIZE = 100;
Create an array to store the scores of 100 participants.
int quizScores[SIZE ];
Add participant score to the array (index starts from 0).
quizScores[0] = 25; quizScores[1] = 30; ...
For calculating the average score, iterate the array using for loop
and calculate the sum and find the average.
int totalScore= 0;
float avgScore =0.0;
/* iterate the array */
for (int i=0 ; i<SIZE ; i++) {
totalScore = totalScore + quizScores[i];
}
avgScore = totalScore/SIZE;
So we calculated the average score of all participants by storing
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.6_arrays_2.html
2/3
12/9/13
individual score in an array and iterating the array using a for loop.
Links for reference:
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
https://www927.ibm.com/ibm/cas/hspc/student/data_structures/ArraysOneDim.html
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.6_arrays_2.html
3/3
12/9/13
Basics of Programming
1/2
12/9/13
specific task.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.7_functions_1.html
2/2
12/9/13
Basics of Programming
// function body
}
Here return_type means the type of data(numeric , String,) the
function will return after executing the logic in the body part. If the function
does not return any data but performs a task then the return type will be void
(means no return_value).
Example:Function definition
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.7_functions_2.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.7_functions_2.html
2/2
12/9/13
Functions
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.7_functions_3.html
1/3
12/9/13
Functions
2/3
12/9/13
Functions
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.7_functions_3.html
3/3
12/9/13
Basics of Programming
1/2
12/9/13
char grade;
} Student;
Java program
class Student{
int id;
String name;
String college;
String stream;
char grade;
};
Both define a new type Student, where Id, name, college, stream,
grade are members (data members) or properties of Student type.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.8_composite-types_1.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.8_composite-types_2.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module3/session3.8_composite-types_2.html
2/2
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.1_introduction-to-developing-a-user-interface_1.html
2/2
12/9/13
Basics of Programming
However this type of user interfaces poses the following disadvantages too:
Learn-ability and Retention of commands is generally poor this is
especially applicable to non-expert users, who would find learning and
remembering individual commands of each task difficult. Hence they
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.1_introduction-to-developing-a-user-interface_2.htm
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.1_introduction-to-developing-a-user-interface_2.htm
2/2
12/9/13
Basics of Programming
1/3
12/9/13
Use of GUI over Command line user interfaces provides us with the
following benefits:
Increase in productivity for normal users, as there is no need for
any specific training for the users to start using a well designed
GUI. The users do not need to learn or remember any commands
to effectively use a GUI.
Decrease in training cost and support line cost (saving time and
money) A well designed and consistent GUI does not require
any training for the users. Also the users are less likely to get
stuck while trying to find a way around getting used to the
application. Hence the training and support cost are
significantly reduced.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.1_introduction-to-developing-a-user-interface_3.htm
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.1_introduction-to-developing-a-user-interface_3.htm
3/3
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.1_introduction-to-developing-a-user-interface_4.htm
1/1
12/9/13
Basics of Programming
The best example of this from real world is the "Butterfly Ballot" used in
Palm Beach, Florida during the 2000 U.S. presidential election was a fiasco, primarily
due to the design of a confusing user interface.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.2_what-is-the-need-for-a-good-UI.htm
1/2
12/9/13
www.elsevierdirect.com/companions/9780120884360/casestudies/Chapter_01.pdf
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.2_what-is-the-need-for-a-good-UI.htm
2/2
12/9/13
Basics of Programming
1/3
12/9/13
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_1.htm
3/3
12/9/13
Basics of Programming
4.3.2.1 HTML
When you look at a web page in a browser, you see words, at the
simplest level. These words usually appears with some style characteristics,
such as different colors and font sizes. Generally, a page also displays images
or may be video. Sometimes there is a form where you can enter (or search) for
information, or change the display of the page to your liking. Sometimes a page
contains animated content and content that changes while the rest of the page
remains the same.
Several technologies (such as JavaScript, CSS, AJAX, Flash, JSON)
can be used to define the elements of a web page. However, a web page is
defined, at the lowest level, using HTML (HyperText Markup Language).
Without HTML, there will be no web page.
What is HTML?
HTML is a markup language. It tells the web browser how to
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_2.htm
1/3
12/9/13
display content. HTML separates "content" (words, images, audio, video, and
so on) from "presentation" (the definition of the type of content and the
instructions for how that type of content should be displayed). HTML uses a
set of pre-defined elements to identify content types. Elements contain one or
more "tags" that contain or express content. Tags starts and ends with angle
brackets, and the "closing" tag (the one that indicates the end of the content) is
prefixed by a forward slash.
For example,
the paragraph element
consists of the start tag "
<p>" and the closing tag "
</p>".
The
following
example show a paragraph contained within the HTML paragraph element:
<p>My dog ate all the guacamole.</p>
in the tags.
The browser uses the tags to indicate how to display the content
dog
the
When
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_2.htm
3/3
12/9/13
Basics of Programming
HTML Tags
HTML documents are written in plain text. It can be written in
any text editor that allows content to be saved as plain text (although most
HTML authors prefer to use a specialized editor that highlights syntax and
shows the DOM structure). Tag names may be written in either upper or lower
case. However, the W3C (the global consortium that maintains the HTML
standard) recommends using lower case (and XHTML requires lower case).
HTML attaches special meaning to anything that starts with the
less-than sign ("<") and ends with the greater-than sign (">"). Such markup is
called a tag. Here is a simple example:
<p>This is text within a paragraph.</p>
In this example there is a start tag and ends with a closing tag.
Closing tags looks the same as the start tag but also contain a forward slash
immediately after the leading less-than sign. Almost all the elements in HTML
are written using both start and closing tags. The starting and closing tags
should be appropriately nested, that is closing tags should be written in the
opposite order of the start tags. Proper nesting is the one rule that must be
obeyed in order to write valid code.
This is an example of valid code:
<em>I <strong>really</strong> mean that</em>
This is an example of invalid code:
Invalid: <em>I <strong>really</em> mean that</strong>
Note that in the first example, the closing tag for the nested
element is placed before the closing tag for the element in which it is nested.
Some elements do not contain any text content or any other
elements as such. Empty elements such as these need no closing tag. Below is
an example:
<img src="smileyface.jpg">
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_3.htm
1/3
12/9/13
Attributes
The start tag may contain additional information, as in the below
example. Such information is called an attribute. Attributes usually contains 2
parts:
An attribute name.
An attribute value.
A few attributes can only have a single value. They are Boolean
attributes and may be shortened by only specifying the attribute name or
leaving the attribute value empty. Thus, the below 3 examples have the same
meaning:
<input required="required">
<input required="">
<input required>
Attribute values that consist of a single word or number may be
written as they are, but when there are two or more strings of characters in the
value, it must be enclosed within quotation marks. Both single and double
quotes are allowed. Most web developers prefer to always use quotes to make
the code less ambiguous to the eye and to avoid mistakes. The below code
includes such a mistake:
<p class=foo bar> (Beware, this probably does not mean what you
think it means.)
In the above example the value of class was supposed to be "foo
bar" but since there were no quotes the code is interpreted as if it had been
written like this:
<p class="foo" bar="">
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_3.htm
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_3.htm
3/3
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_4.htm
2/2
12/9/13
Basics of Programming
4.3.2.2 CSS
HTML was originally designed as a simple way of presenting
information, with far less importance given to the aesthetics of a web page
than the content (and largely being left up to the web browser). Now that the
web has become as popular as it has, the content presentation has become
almost critical to a websites success. CSS is a technology which is a key in
presentation, used to design websites.
In the late 90s, HTML coders noticed that they were retyping the
same old tags again and again on the same page, leading to larger HTML files
and above all, more time was consumed in this unfruitful process, which
further led to frustration. You may also have found yourself in the same
situation, adding in mountains of <font> tags, despite wanting them all the
same; or using tricks like invisible gifs for spacing.
Then, someone had a great idea: have one file that defines all the
values that those piles of tags would have done, and then have the pages
checking this file and formatting the content pages accordingly. You can hence
leave out most of the formatting tags in HTML and use only nice structural
elements (such as headings, paragraphs and links) separating structure and
presentation.
In late 1996 CSS (Cascading StyleSheets) became a reality, acting
as a partner to your HTML code; taking care of all the layout, fonts, colors and
overall look of your site.
If you ever decide to change the look of your site, you modify that
one CSS file (your style sheet) and all the HTML pages reading from that file
will display accordingly. This makes maintenance of your design much easier.
CSS Syntax
The syntax for CSS is different than that of HTML markup. It
mainly consists of only 3 parts.
selector { property: value }
The selector is the HTML element that you want to style. The
property is the title of the actual property, and the value is the style you apply
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_5.htm
1/2
12/9/13
to that property.
Each selector can have multiple properties, and each of those
properties within the selector can have independent values. The value and
property are separated with a colon and contained within curly brackets.
Multiple properties have to be separated by a semi colon. But a comma is used
to separate multiple values within a property, and if an individual value
contains more than one word you surround it with quotation marks. A sample
of this is shown below
body {
background: #eeeeee;
font-family: Times New Roman, Calibri;}
As you can see in the above code we have separated the color
from the font-family with a semi-colon, various fonts are separated with
commas and contained the Times New Roman within quotation marks. The
end result sets the body color to light gray, and sets the font to ones that most
users will have installed on their computer.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_5.htm
2/2
12/9/13
Basics of Programming
2. External Stylesheet
Next we will explore the external method. Using any text or HTML
editor such as 'Notepad', an external CSS file can be created. A CSS file
contains no HTML, only CSS. You simply save it with the .css file extension.
You can associate the file externally by placing one of the following links in the
head section of every HTML file you want to style with the CSS file.
<link
Stylesheet.css />
rel=stylesheet
type=text/css
href=Path
To
1/3
12/9/13
rel=stylesheet
type=text/css
href=Path
To
</head>
<body>
or
<head>
<title></title>
</style>
By using an external style sheet, all of your HTML files link to one
CSS file in order to style the pages. Meaning, that if you need to alter the design
of all your pages, you only need to edit one .css file to make global changes to
your entire website.
Here are a few reasons this is better.
Easier Maintenance
Reduced File Size
Reduced Bandwidth
Improved Flexibility
3. Inline Styles
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_6.htm
2/3
12/9/13
Which is better?
So with all these various ways of inserting CSS into your HTML
files, you may now be wondering which is better, and if more than one method
is used, in what order do these different ways load into the browser?
All the different methods will cascade into a new pseudo
stylesheet in the following order:
1. Inline Style (inside HTML element)
2. Internal Style Sheet (inside the <head> tag)
3. External Style Sheet
As far as which way is better, depends on what you want to do. If
only one file need to be styled then placing it within the <head></head> tags
(internal) will work fine. Whereas if you are planning on styling multiple files
then the external file method is the way to go.
Choosing between the <link related=> & the @import methods are
completely up to you. I will mention that the @import method may take a
second longer to read the CSS file in Internet Explorer than the option.
To learn how to implement CSS in HTML pages, refer the link below
www.w3schools.com/css/default.asp
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_6.htm
3/3
12/9/13
Basics of Programming
Conclusion
With the use of HTML and CSS you'd be able to develop
attractive looking webpages. But these webpages would only contain static
information. That is the users can only read/consume the information that you
have on the pages. No user interaction would be possible with static pages.
But the good news is, there are various other technologies using
which the webpages can be made dynamic. Examples of those technologies are
asp.net, jsp, javascript etc. The discussion on specific technologies are out of
the scope of this curriculum. However for further reading you may refer the
website below.
JavaScript :
www.w3schools.com/js/default.asp
ASP.NET :
www.w3schools.com/aspnet/default.asp
JSP
www.tutorialspoint.com/jsp/index.htm
https://aspire.tcs.com/aspire/courses/basics_of_programming/module4/session4.3_basic-steps-to-be-followed-for-developing-a-good-UI_7.htm
1/1
12/9/13
Programming Approaches
Basics of Programming
Programming Approaches
5.1. Introduction
Organizations and individuals are continually searching for more
efficient ways to perform the software development process. One way of
lowering the time and cost of development is to standardize software programs
and the process of programming. The benefits of standardized programs are
that they are easier to code, maintain, debug, and modify. In recent years,
many different techniques have appeared attempting to minimize differences
in the way programmers' design and develop software.
1/2
12/9/13
Programming Approaches
implies that instructions may be executed selectively using IF-THEN and/or IFTHEN-ELSE statements. These conditional statements work in the following
way. IF a condition is true or is met, THEN a specific set of instructions will be
executed.
If the condition is false, then another set of instructions will be
executed. For example, if an employee works for more than 40 hours a week,
THEN calculate his gross pay based on an overtime rate of 50% more than his
normal hourly pay. If the employee work 40 hours or less a week, THEN
calculate gross pay based on the normal hourly rate of pay. IF-THEN-ELSE
works the same way, but in this case the word ELSE is substituted with a false
case, a condition not met. IF the employee works more than 40 hours a week,
then calculate gross pay based on a time and a half the rate, ELSE calculate
gross pay based on the normal rate. Alternatively when there are many
options, one can employ the CASE statement. The iteration principle indicates
that one part of the program can be repeated or iterated a limited number of
times. In most computer languages, the repetition or iteration may be activated
by using REPEAT ---UNTIL or using the WHILE loop and the FOR loop.
Structured Design
According to structured design principles, a program should be
designed from the top-down or bottom-up as a hierarchical series of modules.
A module is a logical way of partitioning or subdividing a program so that
each module performs one or a small number of related tasks.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.1_structured-programming.html
2/2
12/9/13
Programming Approaches
Basics of Programming
Programming Approaches
1/3
12/9/13
Programming Approaches
Master file
Earnings
Deductions
Taxing
Net earning
Print reports
The tasks given above can be shown by a hierarchical chart
(Hierarchical Program Organization) as shown below.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_1.html
2/3
12/9/13
Programming Approaches
Bottom-up Design
Already existing facilities/designs are used/taken into consideration as
a model for a new (better) design. With the use of Bottom-up design strategy, we take
an already existing computer program as a model for our new program. We try to
utilize the existing facilities or design in a way, which gives out program a better
performance.
Stepwise Refinement
Stepwise refinement is a top-down design strategy. The program is
developed by successively refining levels of procedural detail. In every refinement
step, one or several instructions of the given program are decomposed into more
detailed ones. This successive decomposition or refinement of specifications
terminates when all instructions are expressed in terms of any underlying computer
or programming language. Each step of refinement implies some design decisions. It
is important that the programmer is aware of the underlying criteria.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_1.html
3/3
12/9/13
Programming Approaches
Basics of Programming
Programming Approaches
1/3
12/9/13
Programming Approaches
such as:
Procedures
A procedure has a header, followed by declarations of variables
used within the procedure known as local variables (identifiers) and finally
statements that are to be performed when the procedure is invoked. The
procedure header is the mechanism used to give a name to the procedure. The
procedure header also may contain the values that can be communicated
between the procedure and its invocation known as parameters.
The common structure for defining a procedure (in C++) is:
void Procedure_Name(parameter)
{
.
//List of Statements.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_2.html
2/3
12/9/13
Programming Approaches
}
Example:
void WelcomeNote ()
{
Cout<<Say Hello to Programming Concepts;
}
Procedures in c++ start with the keyword void.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_2.html
3/3
12/9/13
Programming Approaches
Basics of Programming
Programming Approaches
Functions
The general structure for defining a function (in C++) is:
Data_type Function_Name(parameter)
{
.
.
Return statement;
}
Example:
float Cube (float x)
{
float product;
product = x*x*x;
return product;
}
The most important thing to note is that the function must have a
result type which dictates what type of value the function represents.
A function is a special sort of sub-program - it is used when a
sub-program is needed which takes a number of inputs and returns a single
output value (as with cube above). This is typical of many algebraic functions
(sine, cosine, exp, log, cube) but is otherwise fairly unusual since the subprograms that we want to define quite often have either no output at all or very
many outputs - in these cases we use a procedure.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_3.html
1/4
12/9/13
Programming Approaches
Parameters
As we've seen, procedures and functions can take a list of
quantities called parameters. Initially you might like to regard the parameters
as the inputs to the module (but this is not always true).
For example:
void sumAndDifference( float a, float b)
{
a = a+b;
b = a-b;
cout<<"The sum is "<<a;
cout<<"The difference is"<<b;
}
Both total and difference are local variables and only exist within
the procedure, as soon as the procedure finishes they and their values
disappear. The following program is an example of the main program:
void main()
{
float val1, val2;
val1=2;
val2=4;
sum_and_difference(val1,val2);
cout<<val1;
}
The values of val1 and val2 are simply copied into the variables a
and b of the procedure sumAndDifference. At the end of the procedure the values
are not copied back! The value of val1 that the final output statement displays
is therefore 2 (not 0).
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_3.html
2/4
12/9/13
Programming Approaches
Built in functions
While most programming languages enable you to write your
own functions (as above), most also provide a library of common functions
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_3.html
3/4
12/9/13
Programming Approaches
https://aspire.tcs.com/aspire/courses/basics_of_programming/module5/session5.2_modular-programming_3.html
4/4
12/9/13
Basics of Programming
1/2
12/9/13
look if you accidentally created more objects than needed (object creation in
loops is a typical reason for performance problems).
High level optimization is to be done in the source code, and low
level optimization is done at the compiled-code level. Low level optimization
may be good on some platforms and bad on other platforms.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.1_introduction-to-optimization.html
2/2
12/9/13
Basics of Programming
Identify the
parts of the application
or program executed
more frequently or which
consume more execution
time. 80 or 90 % of a
program's execution time
may be spent executing
20% or 10% of the code
(Pareto principle).
1/1
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_1.html
1/1
12/9/13
Basics of Programming
j += (i-sqrt(i)-sqrt(sqrt(i)))/sqrt(123456)+(i-sqrt(i)-
}
print(j);
}
In the above program 1/sqrt(123456) and 1/sqrt(654321) are sub
expressions which are repeated for every iteration. This can be modified by
defining a common sub expression, in which the above example can be
modified.
commonValueInAllLoopIterations
for( i=36000000;i>0;i--)
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_2.html
1/2
12/9/13
{
j += (i-sqrt(i)-sqrt(sqrt(i)));
}
j=j*commonValueInAllLoopIterations
print(j);
}
In the above program the common sub expression is evaluated by
multiplying the value of the variable 'commonValueInAllLoopIterations'
residing outside the for loop with value that is stored in the variable 'j'.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_2.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_3.html
1/1
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_4.html
1/3
12/9/13
}
This would give us the output, but it is a poor code from a reuse
point of view. In case at a later time da or hra calculation changes, we need to
change it at different places.
This is where modularity comes to the picture. The same code can
be modularized as follows:
2/3
12/9/13
requires the da or the hra alone, they can just call the corresponding function.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_4.html
3/3
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_5.html
2/2
12/9/13
Basics of Programming
* Below code snippet calculates the sum by simply looping the value of
*
* @parameter n - means the input value
*/
function sumOfIntegers(int n)
{
int i, sum = 0; // declare the variables i, sum
condition i <= n
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_6.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.3_standard-techniques-list_6.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module6/session6.4_code-optimization-summary.html
1/1
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.1_introduction-to-testing.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.2_who-does-testing.html
1/2
12/9/13
The Acceptance testing is done by the end user at the end of the
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.2_who-does-testing.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.3_testing-approches.html
1/1
12/9/13
Basics of Programming
for each
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.4_levels-of-testing_1.html
2/2
12/9/13
Basics of Programming
1/2
12/9/13
Top-Down integration:
In this testing, the highest/top level modules are first tested
and then progressively lower-level modules are tested.
In a comprehensive software development environment, bottomup testing is usually done first, followed by top-down testing. The process will
finally conclude with multiple tests of the complete application, preferably in
scenarios which are designed to mimic the environment which will be
encountered in customers' computers, systems and network.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.4_levels-of-testing_2.html
2/2
12/9/13
Basics of Programming
1.
2.
3.
4.
1/2
12/9/13
More ideas will be shared about the application and more tests
can be performed on it to determine its accuracy and the reasons why the
project was initiated. Acceptance testing is done not only to point out simple
spelling mistakes, cosmetic errors or Interface gaps, but also to point out any
bugs in the application that will result in system crashes or major errors in the
application at a later stage.
By performing acceptance tests on an application, the testing
team will get to know how the application will perform in production
environment. There may also be legal and contractual requirements for
acceptance of the system. In such cases the application should satisfy the
above requirements before it is accepted by the client.
7.4.2 Non-Functional Testing:
Testing the application against client's and performance
requirement. Non-Functioning testing is done based on the requirements and
test scenarios given by the client.
Non-Functional Testing covers:
Load and Performance Testing
Stress & Volume Testing
Compatibility & Migration Testing
Data Conversion Testing
Operational Readiness Testing
Security Testing
Performance testing
into projects.
You will get to learn more on non functional testing once you are
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.4_levels-of-testing_3.html
2/2
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_1.html
2/2
12/9/13
Basics of Programming
10
15
NM(non members)
10
Table 1
1/2
12/9/13
positive (>0)
[1..499]
C3 Valid
[500..4999]
C4 valid
[5000.. MAX]
C5 valid
[> MAX]
C6 invalid
Variable 2
Customer Type (cust_type):
M (member)
C1
NM (non member)
C2
Input conditions/data
Expected
output(Rs)
Error
900
Table 2
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_2.html
2/2
12/9/13
Basics of Programming
Boundary
values
[1..499]
0,1,499,500
[500..4999]
4999,5000
[5000.. MAX]
MAX, MAX+1
Table 3
Customer type [M, NM]
So test cases can be formed with permutation combination of the
two variables here.
Advantages of Black Box Testing
Tester can be non-technical.
Used to verify contradictions in actual system and the
specifications.
Test cases can be designed as soon as the functional
specifications are complete.
Disadvantages of Black Box Testing
The test inputs need to be from large sample space. That is, from
a huge set of data which will take time. Also it is difficult to
identify all possible inputs in limited testing time. So writing
test cases is slow and difficult.
Chances are more that there will be unidentified paths during
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_3.html
1/2
12/9/13
this testing.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_3.html
2/2
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_4.html
2/2
12/9/13
Basics of Programming
Syntactic Errors:
Every programming language has its own grammar rules. Error in
these rules are considered part of syntactic errors. Like in 'c' language,
semicolon is mandatory at the end of each line.
Logical Errors:
It is an error in the logic applied. For Instance, To add two number
say a and b, mistakenly the developer may write it as a - b , instead of a + b, its
a logical error Code is verified for both syntactic error and logical error by
passing multiple set of data. From the above example we can see that for
performing white box testing, we have to come up with two basic steps. The
following points explain what testers do in white box testing technique:
Step 1) Understand the source code
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_5.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.5_testing-techniques_5.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.6_when-to-start-stop-testing_1.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.6_when-to-start-stop-testing_1.html
2/2
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.6_when-to-start-stop-testing_2.html
1/1
12/9/13
Basics of Programming
7.7 Debugging
In computers, debugging is the process of
finding and fixing/bypassing bugs or errors in a
program source code or it can called as the engineering
of a hardware device. To debug a program or hardware
device, the programmer has to start with a problem,
need to isolate the source of that particular problem,
and then finally fix it. User of a program who does not
know how to fix the problem must learn enough about
the problem so that he can avoid it until the problem is
given a permanent fix. When someone says they've
debugged a program or "worked the bugs out" of a
program, they mean that they have fixed the problem
and the bugs no longer exist in the application.
For any new s oftware or hardware development process, debugging is a necessary process
whether it is a commercial product or an enterprise or personal application program. For complex products,
debugging is done as the result of the unit test for the smallest unit of a system, again at component or
module test when parts are brought together, and then at system test when the product is used with other
existing products, and finally during customer beta test (explained earlier), where users try the product out in
a real world situation. As most computer programs and programmed hardware devices contain thousands of
lines of code, almost any new product is likely to contain a few bugs.
Debugging tools (called debuggers) will help identify coding errors at various development
stages. Some programming language packages will include a facility for checking the errors in the code the
moment it is being written.
Some of the debugging tools available are GDB (For Unix C++), Expeditor (MF) and so on. Please
do a search in Google to get some of the most commonly used debugging tools in the software industry.
Links :
http://www.worldcolleges.info/College/EBooks/download/software%20testing%20life%20cycle(STLC).pdf
http://www.ipl.com/pdf/p0820.pdf
http://www.cs.swan.ac.uk/~csmarkus/CS339/presentations/20061202_Oladimeji_Levels_of_Testing.pdf
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module7/session7.7_debugging.html
1/1
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_1.html
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_1.html
2/2
12/9/13
Basics of Programming
1/3
12/9/13
During this phase, the needs of the company are outlined. Users (and in
some cases, clients) make their wish-lists about what they would like the software to
do. Business Analysts(who analyzes the requirements) ask questions about the
intended use of the software system, what type of data will be processed,how the
data can be accessed and how the software should handle the data in the system. At
the end of analysis phase, the development team should have a detailed list of
functions that the software system will perform. In this phase,emphasis is on the
system's goals, rather than the way in which the system will achieve those goals.
Design
In the design phase, the results of the requirements analysis phase are
translated into software design plan. Focus shifts from the system's goals to the way
in which those goals will be achieved and how the ideas of the requirementsgathering phase are achieved. Designers consider many different criteria, from the
hardware and operating system platform that hosting the software or the solution to
the way subsystems will communicate with each other.
During the design phase, the designer's convert the dreams of the users
and managers into reality. Emphasis is on making a practical,working design for
what has been outlined in the requirements analysis phase.
Construction
During this phase, the output of the design phase are translated into
program code. Software that does not meet the needs of the user or the company is
wasteful. During construction phase the programmers should make it their central
goal to fulfill the requirements of the users and to meet the design outlined in the
design phase
Testing
In the testing phase, the results of the implementation/construction
phase are run through a series of tests to verify that it functions and it meets goals of
the requirements phase. A testing plan is created to describe the unit and system
tests that will be performed. Unit testing is performed on individual software
component. The process of integration brings together all the software components
to create a complete software system. System testing is performed on the software
system as a whole component.
Please go through ' Testing and Debugging ' module to know more
details about testing.
Maintenance
Once the product has been delivered/deployed to customers, it enters
into the maintenance phase. During this stage, specialists from the development and
testing team monitor the product 'in the wild' to see how it is adapting to regular
user/customer usage. If customers encounter any unforeseen problems, the
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_2.html
2/3
12/9/13
maintenance team would take corrective action and fix the issues.
Refer the links given below to get more information about SDLC.
http://softwarelifecyclepros.com/wp-content/uploads/2012/05/TutorialSoftware-Development-LifeCycle-SDLC.pdf
http://www.cpe.ku.ac.th/~plw/oop/e_book/ood_with_java_c++_and_uml/ch4.pdf
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_2.html
3/3
12/9/13
Basics of Programming
Waterfall Model
2.
V-Shaped Model
3.
Iterative Model
4.
Incremental Model
5.
Spiral Model
1. Waterfall Model
It is one of the most widely used SDLC Model. It is also called as "
Classic Life Cycle" or "Linear Sequential model" . It is one of the simplest model
to understand and use. It is characterized by a series of steps that must be
completed in a linear or sequential order. It is called ' Water fall ' because we
move to next step after getting input from previous step (phase), like in a
waterfall, water flows down to from the upper steps. Each phase is completed
and verified before the next phase. There is sequential progression from one
phase to another in this model.
The origin of this model is in the construction and manufacturing
industry. Since formal software development process did not exist at that time,
this hardware oriented process model was adapted for software development
as well.
Waterfall model is not only simple to understand, but it is also
very easy to use. The highlight is that, there are defined phases or steps in
waterfall model life cycle and the preceding phase must be completed before
the next phase starts. After the first phase/step is completed, it is considered as
a stepping stone to the next phase. There are a number of different life cycle
models, that are now used, in the software development, waterfall model
remains one of the top most used model.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_3.html
1/4
12/9/13
2/4
12/9/13
3/4
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_3.html
4/4
12/9/13
Basics of Programming
2. V-Shaped Model
Like the Waterfall model, the V-Shaped life cycle model provides
a sequential path of individual phases that must be completed before
development proceeds to the next phase. V-shaped model means Verification
and Validation model.
Validation- It is the assurance that a service ,product or system
meets the needs of the customer.
Verification- The evaluation of whether or not a product, service,
or system complies with the, requirements, specification, or an imposed
condition. It is an internal process.
The main difference between v-shaped development model and
waterfall development model is the early test planning. Following figure is a
simplified illustration of the V-Shaped life cycle model.
V-shaped model is applicable to projects where :
Requirements are clearly known and defined in advance
Software development tools and the technologies are well known
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_4.html
1/4
12/9/13
Verification phases
Requirements
Requirement analysis (upper left point of the V )is the first step in
the verification process. The requirements are collected by analyzing the needs
of the users. User acceptance tests and System tests are designed as part of
this phase. System and acceptance test design plan focuses on verifying the
functionality specified in the requirements definition.
High-level Design
As the V-shaped model moves down the left side, developers will
focus on high-level design architecture and the overall system design. System
engineers will analyze and understand the business of the proposed system or
software by studying the user requirement document. They will come up with
different techniques and possibilities by which the user requirements can be
implemented. If any of the requirements are not feasible, then the user is
informed about the issue
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_4.html
2/4
12/9/13
Validation phases
Unit testing
In computer programming, unit testing is a method by which
individual units of source code are tested to determine if they are fit for use
through the documents prepared during Low-level design. A unit is defined as
the smallest testable part of an application or software.
Integration testing
The separate modules will be tested together to find out faults in
the interfaces and in the interaction between integrated components or
modules through the documents prepared as part of High-level design.
Acceptance and System testing
After the integration test is completed, the focus is on the system
and acceptance testing to check, the integrated product/software meets the
specified requirements or not. This phase is used to determine whether a
software system satisfies the requirements specified in the requirements
analysis phase through the documents prepared as part of the requirement
analysis phase.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_4.html
3/4
12/9/13
Advantages of V-model
It is very simple and easy to use.
Preparing test plans early in the process gives the V-model a
higher chance for success.
Appropriate for small development projects in which
requirements are well understood and defined in advance.
Disadvantages of V-model
Like the Waterfall model, all requirements must be defined at the
beginning of the project. So it is difficult to add or change
requirements later in the development process.
All software development occurs in a single phase, so there are
no early working versions or prototypes.
The emphasis in test planning is to reduce the risk,but like the
waterfall life cycle model, the V- model risks time and energy in
the absence of careful planning.
Similar to Waterfall model, the V-model is inappropriate for
complex projects.
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_4.html
4/4
12/9/13
Basics of Programming
3. Iterative Model
It addresses many issues associated with the waterfall model. In
the Iterative Model , analysis is done the same way as it is done in the Waterfall
Model .
An iterative model does not start with a full specification of
requirements. Development begins by specifying and implementing just a part
of the software, which can then be reviewed to identify further requirements.
This process is then repeated to produce the new version of the software for
each cycle in this model. An iterative life cycle model consists of repeating the
following four phases in sequence.
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_5.html
2/2
12/9/13
Basics of Programming
4. Incremental Model
It builds an iterative approach into the waterfall model.
Development projects are divided into several smaller(more manageable)
iterations. Each iteration passes through a mini waterfall process model.
Requirement analysis, design, implementation and testing phases are
completed for each iteration. In this model, software is designed, implemented,
integrated and tested as a series of incremental builds. Incremental model may
be applicable to projects where:
Requirements are known and well defined, but realization may be
delayed.
Basic functionality is required early.
1/2
12/9/13
system.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_6.html
2/2
12/9/13
Basics of Programming
5. Spiral Model
It is similar to the incremental life cycle model but incorporates risk
analysis. It is divided into four phases
I.
Planning
II.
Risk analysis
III.
Development/Engineering
IV.
Evaluation
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_7.html
1/3
12/9/13
2/3
12/9/13
Summary
All SDLC models share common phases of development:requirements
gathering, designing of the software system, Development of software, and the
testing . Waterfall model is one of the simplest and easiest to use,It consists of five
phases that are executed sequentially. The incremental model applies a series of
iterations to the waterfall model. The Spiral model is built upon the waterfall and
incremental models and focuses on risk analysis.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.1_phases-of-software-development-life-cycle_7.html
3/3
12/9/13
Basics of Programming
1/2
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.2_introduction-to-the-unified-modeling-language_1.html
2/2
12/9/13
Basics of Programming
Class diagram
2.
Object diagram
3.
Component diagram
4.
Deployment diagram
2. Behavioral Diagrams
Any system can have two aspects, static and dynamic. A model is
considered as complete when both the system and dynamic aspects are
covered fully.
Behavioral diagram basically represents the dynamic aspect of a
system. Dynamic aspect can be further described as the changing or moving
parts of a system.UML has the following five types of behavioral diagrams:
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.2_introduction-to-the-unified-modeling-language_2.html
1/2
12/9/13
1.
2.
Sequence diagram
3.
Collaboration diagram
4.
5.
Activity diagram
Course Contents | Prev : Next
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.2_introduction-to-the-unified-modeling-language_2.html
2/2
12/9/13
Basics of Programming
II.
III.
1/3
12/9/13
1. Use Cases
simple
ii.
iii.
iv.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_1.html
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_1.html
3/3
12/9/13
Basics of Programming
2. Actors
An actor is an external entity (outside of the system) that
interacts with the system by participating a Use Case. Actors can be in real life
people (for example users of the system), external events and other computer
systems.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_2.html
1/3
12/9/13
2/3
12/9/13
3/3
12/9/13
Basics of Programming
ii.
iii.
iv.
v.
vi.
Following figure shows what the above use case might look like in
UML schematic form. The use case is drawn as an oval. The actors are
represented as stick figures. Actors and use case are connected using lines.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_3.html
1/4
12/9/13
2/4
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_3.html
3/4
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_3.html
4/4
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.3_developing-use-case-diagrams_4.html
1/1
12/9/13
Basics of Programming
II.
III.
IV.
1/4
12/9/13
diagram:
i.
ii.
iii.
iv.
v.
vi.
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_1.html
2/4
12/9/13
System . The class diagram has been drawn considering all the points
mentioned above:
An object is the actual implementation of a class .It is also known
as the instance of a class.
Customer and Order are identified as the two elements of the
Order system and they have a one to many relationship, because
a customer can have multiple orders.
The two inherited classes (SpecialOrder and NormalOrder) have
all the properties as the Order class. They have additional
functions like receive () and dispatch ().
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_1.html
3/4
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_1.html
4/4
12/9/13
Basics of Programming
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_2.html
1/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_2.html
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_2.html
3/3
12/9/13
Basics of Programming
1/6
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_3.html
2/6
12/9/13
3/6
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_3.html
4/6
12/9/13
Join
For the consolidation of two or more parallel flows we can use a
synchronization bar, which is represented as a thick vertical or horizontal line.
It takes two or more inputs and gives only one output.
5/6
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_3.html
6/6
12/9/13
Basics of Programming
1/3
12/9/13
passenger task service is completed. This is represented by a the black dot with
border(the activity final node).
After successful check-in (7) we come to a black cross bar. All
arrows that come from this black bar (7) symbolize flows that are processed
simultaneously( the luggage is being loaded onto the airplane (9) and the
passenger is boarding the airplane (10) ).
Between point (8) and point (11) the flows are independent from
each other. Simultaneously processed Flows (9 and 10) are merged at the
second cross bar (11). It means that only when the passenger is on the plane
(10) and the luggage has been loaded onto the plane (9), then the control flow
continue below the cross bar (11).
In this example, one more action (12) and subsequent to that the
final state (13) follow, meaning that after the passenger is on the plane (10)
and the luggage has been loaded onto the plane (9), the airplane can taxi
towards the runway (12).
We can see here that the last action airplane taxis toward runway
(12) is only defined as a single action, even though this process is very complex
and could be described in many other activity diagrams.
Following figure illustrates the activity diagram with partitions .
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_4.html
2/3
12/9/13
https://aspire.tcs.com/aspire/courses/basics_of_programming/module8/session8.4_examining-other-uml-diagrams_4.html
3/3