Sei sulla pagina 1di 40

1.1. What is Programming?

A problem is defined as any question, something involving doubt, uncertainty, difficulty or a


situation whose solution is not immediately obvious. A situation which is a problem for one
person may not be a problem for another person. Figure 1.1 graphically represents the concept of
problem solving.

A Computer is a tool that can be used to solve problems by writing programs. Writing a program
without knowing the problem that we are trying to solve is like swinging a knife without
knowing what it is that we want to cut.

A program is a set of instructions that tells the computer how to do a task. When a computer
follows these instructions, we say it executes the program

Fig 1.1: Problem Solving

A programming language is a computer language that programmers use to develop applications.


An application is a set of instructions for a computer to execute. A set of rules that provides a
way of telling a computer what operations to perform is called a Program.

Programming is the process of designing, developing, testing, debugging and maintaining the
source code of computer programs. It is used to create a set of instructions that computers use to
perform specific operations or to exhibit desired behaviors. Source code can be written using
programming language such as C++, Java, Python, Smalltalk, C#, etc. The process of writing
source code often requires expertise in many different subjects, including knowledge of the
specialized algorithms, application domain and formal logic.

Within software engineering, programming (implementation) is considered as a phase in the


software development process.

The Programming Process

Developing a program involves different steps similar to any problem solving task. There are
five main steps in the programming process. They are as follows:

1. Defining the problem

2. Planning the solution

3. Coding the program

4. Testing the program

5. Documenting the program


Let us discuss each of these steps.

1. Defining the problem

As a programmer, you meet with end users from the client organization to analyze the problem,
or you meet with a systems analyst who outlines the project. Specifically, the task of defining the
problem consists of identifying what you know (input-given data), and what you want to obtain
(output-the result). Eventually, you create a document or an agreement that specifies the kind of
input, processing, and output required to complete the task.

2. Planning the solution

There are two ways that are commonly used to plan the solution to a problem. These are to draw
a flowchart and to write pseudo code, or both.

Pseudo code

Pseudo code is an English-like non-standard langauge that permits you to focus on the program
logic without having to be concerned about the precise syntax of a particular programming
language. However, 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 an everyday action preparing a
letter for mailing.

Figure 1.2: Flowchart

Please refer the links below to learn more about pseudo code and flow chart.

http://ceng.anadolu.edu.tr/emrekacmaz/bil158/flowchart-pseudocode-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. Coding the program

As a programmer, your next step is to code the program to express the solution in a programming
language. You will translate the logic from the flowchart or pseudo code to a programming
language. As we have already discussed, a programming language is a set of rules that provides a
way of instructing the computer what operations to perform. There are many programming
languages such as BASIC, COBOL, Pascal, FORTRAN, C, etc.

Programming languages are precise like the English language. To get your program to work, you
have to follow the exact syntax (rules) of the language you are using. However, there is no
guarantee that your program will work because the syntax in programming language is correct.
The correctness of the language is the first step that you require. After that, the program must be
keyed, probably using a personal computer, in a form that the computer can understand.

4. Testing the program

Some experts claim that a well designed program can be written correctly the first time and there
are mathematical ways to prove that a program is correct. Most of the programs may have a few
bugs (errors) when executed for the first time. This is a little discouraging at first, since
programmers tend to be careful, precise and detail-oriented people who take pride in their work.
There are many ways in which mistakes or problems may happen in programs. You will
probably have made some of them. Eventually, after coding, we must prepare to test the program
on the computer.

Testing involves three phases:

1. Desk-checking

2. Translating

3. Debugging

Let us discuss each of them.

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 desk-checking we can identify 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 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. Checks the syntax of the program to make sure that the programming language was used
correctly, giving you all the syntax related error messages called diagnostics, and

II. Then translates the program into a form which the computer can understand. A by-product of
the process is that the translator tells us if we have improperly used the programming language.
These mistakes are called syntax errors. The translator gives descriptive error messages.

Programs are most commonly translated using a compiler. A compiler translates the entire
program at one time. The translation involves your original program (Source file) which is
transformed by a compiler into an object module. Pre-written programs from a system library
may be added during the load/link phase, which results in a load module. The load module can
then be executed by the computer.
Debugging

Debugging is used extensively in programming. It means detecting, locating, and correcting bugs
(mistakes) by running the program. These bugs are called as logic errors, which tells the
computer to repeat an operation but not telling it when to stop repeating. In this phase we run the
program using the test data that we devise. We must plan the test data carefully to make sure we
test every part of the program.

5. Documenting the program

Documenting is an ongoing process. It is a detailed description of the programming cycle and


specific facts about the program in the written form.

Typical program documentation include the origin and nature of the problem, a brief description
of the program, logic tools such as pseudo code and flowcharts, program listings, data-record
descriptions and test results. Comments in the program are also considered as an essential part of
documentation. Many programmers document as they code.

A wise programmer continues to document the program throughout its design, development and
testing. Documentation is used to supplement human memory and to help organize program
planning. Documentation is also critical to communicate with others who have an interest in the
program and may be part of a programming team.

1.2. Why programming is required?

We may have already used software, in the form of spreadsheets or word processing, or to solve
problems. Perhaps we are now curious to learn how programmers write software. A program is a
set of step-by-step instructions that directs the computer to do the tasks we want it to do and
produce the results we want.

There are three good reasons for learning programming:

1. Programming helps us to understand computers. If we learn how to write simple programs, we


will know better about how a computer works.

2. Writing a few simple programs increases our confidence level. We will find great personal
satisfaction in creating a set of instructions that solvea a problem.

3. Learning programming lets us find out quickly whether we like programming and whether we
have the analytical turn of mind that programmers need. Even if we decide that programming is
not for us, understanding the process certainly will increase our appreciation of what computers
and programmers can do.
What Programmers Do?

The programmer prepares the set of instructions of a computer program and runs those
instructions on the computer, tests the program to see if it is working properly, and then makes
corrections to it. These activities are all done for the purpose of helping a user to fill a need, such
as paying employees, admitting students to college or billing customers.

Programming can be done as a solo activity, but a programmer typically interacts with a variety
of people. For example, if a program is a part of a system of several programs, the programmer
coordinates with the other programmers to make sure that all the programs fit together
correctly. If you are a programmer, you might also have coordination meetings with users,
systems analysts, managers, and with peers who evaluate your work just as you evaluate theirs.

Levels of Language

Programming languages can be "lower" or "higher," depending on how close they are to the
language the computer itself uses (0s and 1s = low) or to the language people use (English like
high). We will consider five levels of language. These are numbered 1 through 5 to correspond to
generations. In terms of ease of use and capabilities, each generation or level is an improvement
over its predecessor.

The five generations of languages are:

1. Machine languages

2. Assembly languages

3. High-level languages

4. Very high-level languages

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. Each type of computer has its own machine language. This is the
lowest level of language. It represents data and program instructions as 1s and 0s- the binary
digits corresponding to the on and off electrical states in the computer. During 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 to be very low level languages. They are not as convenient
to use as the more recent languages. However, at the time when they were developed, they were
considered as a great leap forward. To replace the 1s and 0s used in machine language, the
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 were 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 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 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 easier and more convenient to use. Using high-level languages, 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 called 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, that is, the COBOL version is essentially identical on each machine.

Some languages are used to serve a specific purpose, such as creating graphics or controlling
industrial robots. Many languages are extraordinarily flexible and are considered to be general-
purpose languages. In the past, the majority of programming applications were written in
BASIC, COBOL or FORTRAN. All of them are general purpose languages.
4. Very High-Level Languages

Very high-level languages are often known by their generation number. They are called fourth-
generation languages or 4GLs. Fourth-generation languages are beneficial because:

I.They are result-oriented; they emphasize "what" instead of "how".

II.They improve productivity because programs are easy to write and modify.

III.They can be used with minimum training by both programmers and non-programmers.

IV.They shield users from needing an awareness of program structure and hardware.

5. Natural Languages

The word "natural" has become very popular in computing circles. Fifth generation languages
are 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.

Choosing a Language

 In a work environment, the manager may decide that everyone in the project will use a
certain language.
 We may need to use a certain language, particularly in a business environment, based on
the need to interface with other programs. If two programs are to work together, it
becomes easy when they are written in the same language.
 We may choose a language based on its suitability or criteria. For example, COBOL will
be the best option for a business program that handles large files.
 If a program is to be run on different computers, it must be written in a language that is
portable and suitable on each type of computer, so that the program needs to be written
only once.
 We may be limited by the availability of languages. Not all languages are available on all
computers and in all installations.
 The language may be limited to the expertise of a programmer. The program may have to
be written in a language that the available programmer knows.

Major Programming Languages are FORTRAN (a scientific language), COBOL (a business


language), BASIC (simple language used for education and business), Pascal (education), Ada
(military), and C (general purposed), C, C++, Java, and Javascript.
2.1. Overview of Software Development

Software development is a discipline in the computer science field that focuses on the creation of
programs that control computer hardware. These programs, also referred to as 'software
applications' or in short 'apps', are groups of instructions that tell a computer what is to be done.
The software development field consists of several computer programming languages, each
designed to fulfill various requirements depending on the project at hand.

It is almost unbelievable to think that a few decades back, the programmers did not even have
desktop computers to work on. Instead they punched instructions into paper cards which were
input into a mainframe computer centrally located in a "machine room". In those times, these
instructions were written in assembly language or machine code, the native language used by
hardware of the computer. As software development evolved, 'higher level' languages were
developed patterning natural languages and better reflecting the human problem-solving process.
Even today, assembly language is still used, especially by low-level engineers developing
computer components and embedded systems. But, most of the desktop and web-based
development is done using high-level languages like ASP, C++, C#, Java, Perl, etc.

If hundred programmers were asked, 'What do they think is the best programming language for
beginners?' you might get one hundred and one answers. Each individual has an opinion. The
question is akin to asking what is the best vehicle to drive - there is simply no right or wrong
answer. Fortunately, some general guidelines exist to get the novice programmer off to a good
start. However, those who are completely new to computers and unsure of whether they are up to
the task (or whether software development will be of interest to them) should start with a
language that is designed to teach basic principles with very minimal complexity. The BASIC
and LOGO programming languages were early attempts to bring computer programming to the
masses. Today a language like Microsoft's Visual Basic would be ideal for a beginner. Visual
Basic helps you to make practical applications with a visual interface in a matter of hours
without getting bogged down by the technical details. Unlike BASIC and LOGO, Visual Basic
has practical applications that can be used in both casual and commercial environments.

Those who are technically inclined or already have a fair amount of experience with computers
may be prepared for more advanced 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.

Life Cycle of a Software Development Project

Software development is a complicated process comprising different stages. Each stage requires
a lot of paperwork and documentation in addition to the process of development and planning.
This is in contrast to the common thinking of newcomers to the software industry who believe
that software development is just writing code.

Every software development project has to go through the following stages at least once:
 Requirement gathering
 Writing functional specifications
 Creating architecture and design documents
 Implementation and coding
 Testing and quality assurance
 Software release
 Documentation
 Support and new features

There may be many additional steps and stages depending upon the nature and the type of the
software product. You may have to go through more than one cycle during the testing phase as
software testers to find problems and bugs. The developers need to fix them before a software
product is officially published or released. Let us go into these stages in detail.

Requirement Gathering

Requirement gathering is usually the first stage of any software product. This stage officially
commences when you are thinking about developing software. In this phase, you meet customers
or prospective customers, and do a market analysis of the requirements and features that are in
demand. You might as well find out if there is a real need in the market for the software product
you are trying to develop. In this stage, most of the work is done by the marketing and sales
people, or people who have direct contact with the customers. These people talk to customers
and try to understand what exactly their requirements are.

A comprehensive understanding of the customers’ needs and writing down features of the
proposed software product are the keys to success in the requirement gathering phase. This phase
is actually a base for the whole development of the software. If the base is not laid appropriately,
the product will not find a place in the market. If a very good software product which is not
required in the market is developed, it does not sell no matter how well you build it. You can
find many instances of software products that failed in the market because the customers did not
require them. The marketing people usually create a Marketing Requirement Document or MRD
that contains formal representation of the market data gathered. You can also consider your
competitors’ products (if any). This process is called competitive analysis.

Finally, list down the features required by the product. Appropriate consideration must be given
to the economics of software creation at this point. Questions that must be asked are: is there a
market? Can I make some profit? will the revenue justify the cost of development?

Writing Functional Specifications

Functional specifications may consist of one or more documents. These documents show the
behavior or functionality of a software product on an abstract level. Assuming the product is a
black box, these specifications define its input/output behavior. The product requirements
documentation put forward by people who have contact with the end user of the product or the
customers, forms the basis of the functional specifications.
In larger products, functional specifications may consist of separate documents for each feature
of the product. For example, if the product is a router, you may have a functional specification
document for RIP (Routing Information Protocol), another for features on security, and so on.
Functional specifications are important because developers use them to create design documents.
The documentation people also use them when they create manuals for end users. If different
groups are working in different physical locations, functional specifications and architecture
documents (discussed next) are also a means to communicate.

Keep in mind that sometimes during the product development phase you may need to amend
functional specifications keeping in view new marketing requirements.

Creating Architecture and Design Documents

When you have all of the requirements collected and arranged, it is the turn of the technical
architects team, which usually consists of highly qualified technical specialists, to create the
architecture of the product. This defines different components of the product and how they
interact with each other. Often, the architecture also defines the technologies used to develop the
product. While creating the architecture documents, the team also needs to consider the timelines
of the project. This is the target date when the product is required to be on the market. Often
excellent products fail because they are either too early or late to market. The marketing and
sales people usually decide a suitable time frame to release the product. Based on this timeline,
the architecture team may drop some features of the product if it is not possible to bring the full-
featured product to market within the required time frame. After deciding the components of the
product and defining their functionalities, interfaces are designed for these components to work
together.

Most often, no component works in isolation; each one has to coordinate with other components
within the project. Interfaces are the rules and regulations that define how these components will
interact with each other. There maybe major problems down the road if these interfaces are not
designed properly and appropriately detailed. Different people will work on different
components of any large software development project and if they don’t fully understand how a
particular component will communicate with others, major problems arise during integration. For
some products, new hardware is also required to make use of technology advancements. The
architects of the product also need to consider this aspect of the product. Once the architecture,
software components and their interfaces are defined, design documents are created as the next
phase of development. At the architecture level, a component is defined as a black box that
provides certain functionality. 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.
Implementation and Coding

The software developers use the design documents and development tools (editors, compilers,
debuggers etc.) and start writing software. This is often the longest phase in the product life
cycle. Every developer has to write his/her own code and collaborate with other developers to
make sure that the different components can inter-operate with each other. A revision control
system such as CVS (Concurrent Versions System) is needed in this phase. There are many open
source revision control systems as well as commercial ones available these days. The version
control system provides a central repository to store the individual files. A normal software
project may contain anywhere from hundreds to thousands of files. In larger and complex
projects, directory hierarchy must also be decided beforehand so that files are stored in
appropriate locations. During the development cycle, different developers may modify the files.
If the rules are not followed by everybody, this may easily break the whole compilation and
building process. A typical example is duplicate definitions of the same variables causing
problems.

Similarly, if included files are not written properly, loops get created easily. Other problems pop-
up when multiple files are included in a single file with conflicting definitions of variables and
functions. Coding guidelines must also be defined by architects or senior developers. As an
example, if software is intended to be ported to some other platform, it must be written on a
standard like ANSI. During implementation, developers must write enough comments inside the
code so that if anybody starts working on the code in the future, he/she would be able to
understand what has already been written. Writing good comments is extremely important as all
other documents, no matter how good they are, will be lost eventually. Ten years subsequent to
the initial work, it's probable that you may find only that information which is in the form of
comments, present inside the code. Development tools also play an important role in this phase
of the project.

Good development tools save a lot of time for the developers. They also help to save money in
terms of improved productivity. In terms of time saving the most important development tools
are editors and debuggers. An editor helps a developer to write the code quickly.

A good debugger helps to make the code operational in a short period of time. Before the start of
the coding process, considerable time must be spent in choosing good development tools. During
the development phase, review meetings also prove helpful. Through review meetings, potential
problems are identified earlier in the development. Review meetings are also helpful to keep
track of whether the product is on time or if more effort is needed to complete it within the
required time frame. There will be times when you may also need to make changes in the design
of some components because of new requirements from the marketing and sales team. Review
meetings are a great tool to convey these new requirements. Here, architecture documents and
MRDs are kept in sync with any changes/problems encountered during development.

Testing

Testing is probably the most important phase for long-term support as well as for the company's
reputation. If you don’t 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 helps the software
testers as well as developers save time 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 the 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 the 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 the 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 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 be done before any software is
released to customers. Functional testing is done by testers whose primary job is software testing,
and not the developers themselves. In small software projects where a company can’t 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 certain infrastructure or environment to test the functionality of a piece of code. For
instance, you may simulate a network to test the 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

The bug should be forwarded to the developer so that the developer may correct the problem.
Many software packages are available in the market to track bugs and fix problems in software.

Software Releases

Any software product is officially released before you start selling it. This means that you create
a state of the software in your repository, ensure that it has been tested for functionality and the
code is frozen. A version number is assigned to the released software. After releasing,
development may continue but it will not make any change in the released software. The
development is often carried on in a new branch and it may contain new features. The released
software is updated only if a bug fixed version is released. Generally companies assign
incremental version numbers following some scheme when the next release of the software is
sent to market. The version number change depends on whether the new software contains a
major change to the previous version or it contains bug fixes and enhancement to the existing
functionality. Software releases are also important because they are typically compiled versions
of a particular code version, and thus provide a stable set of binaries for testing.

1. Branches - In almost all serious software development projects, a version control system is
used. This system keeps a record of changes in source code files and is usually built in a tree-like
structure. During the release of the software, the state of each file that is part of the release
should be recorded. By creating branches to this state, future developments can be made.
Sometimes special branches may also be created that are solely used for bug fixing.

2. Release Notes - Every software version contains release notes. These are prepared by people
releasing the software version with the help of the developers. Release notes show what
happened in this software version.

Typically the information includes:

 Bug fixes
 New functionality
 Details of new features added to the software
 Any bugs that are not yet fixed
 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.

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 use of the end user. It assists
the user in 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 provide better support to 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
manual is almost completed.

Support and New Features

Your customers need support when you sell a product. This is true regardless of the size of the
product, and even for non-software related products.

The 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 required by the customer

In addition to these, 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 these strategies are useful depending how urgent the
requirement for new features is.
2.2. Overview of problem solving Techniques

Good problem solving skills empower managers in their professional and personal lives. Good
problem solving skills seldom come naturally; they are consciously learnt and nurtured. Good
problem solving skills should include:

 developing innovative and creative solutions;


 developing solutions which are practical;
 showing independence and initiative in identifying problems and solving them;
 applying a range of strategies to problem-solving;
 applying problem-solving strategies across a range of areas;

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 state and the 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 one's hopes can be achieved will give one the will to
aim towards a better future.

Key approaches to Problem solving

There are different ways of problem solving – each has its own advantages and disadvantages.
The process an individual adopts as a manager will be influenced by organizational policies,
his/her own personality and communication style, and the kind of information available about the
problem. Broadly, there are two problem solving models available to a manager.

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 some change in the situation that has caused an unwanted
deviation from expectations.

The Rational Decision-Making model requires the following steps, which if followed, are
assumed to lead to "value-maximising choices." These steps are as follows:

 need to define the problem,


 identify the decision criteria,
 weigh the criteria which can be used to determine rank of importance,
 generate alternative solutions,
 rate each alternative on a different criteria, and
 compute the optimal decision.

B. Lateral or Creative Problem-Solving

Lateral or creative problem solving does not follow any standard set of procedures. It is a
‘subconscious process based on past distilled experiences’. It is based more on the gut feeling of
the manager than on an objective process of weighing alternatives.

There are a set of conditions and it is accepted that under those conditions intuitive approach is
generally preferred to rational approach. Intuitive method is preferred when:

 there is a high level of uncertainty,


 little precedence to draw on exists,
 variables are not that easily predictable,
 facts are limited or facts are contradictory,
 analytical data is not of much use,
 there are several plausible solutions; and
 decision needs to be made in a short period of time

The creative/lateral problem solving is very flexible. So it can be used to examine real problems
and issues.
Problem solving process

There are a variety of problem-solving processes. But each process consists of a series of steps –
which include identifying the problem, searching for possible solutions, selecting the most
optimal solution and implementing a possible solution. It is useful to view problem solving as a
cycle because, sometimes, a problem needs several attempts to solve it or at times the problem
itself changes. The diagram below shows a seven-step problem solving process.

2.1 : Seven-Step Problem Solving Process

1. Identifying the Problem: The first step in the problem solving process is sizing up the
situation to identify the problem. This may sound simple enough, but sometimes managers might
be uncertain about even what the problem is; they might just be feeling anxious or be confused
about what is getting in the way of their objectives. If that is the case, they can ask themselves or
consult with their friends or a professional expert. Other useful techniques for identifying the
problem include-

 Comparison with others


 Monitor for weak signals
 Brainstorming
 Checklists
 Comparison of current performance with objectives or past performance
 Listing complaints & role playing

2. Exploring the Problem: Having identified the problem, managers should analyze the problem
to see what is the root cause for it. Often people get caught up in symptoms or effects of a
problem or issue and never drill down to the real cause. They get mad at someone’s attitude,
anger, or actions, which is not the real cause of the problem. The key here is to focus on
analyzing the problem for the real root cause without being affected by emotional issues.
Seeking answers to questions such as the following will help explore the problem:

Identify the Problem – Ask Who?

 Who says that this is a problem?


 Who caused or is causing the problem?
 Whom does it or will it affect?
 Who has done something about the problem?

Identify the Problem – Ask What?

 What happened or will happen?


 What are the symptoms?
 What are the consequences for others?
 What circumstances surround the occurrence of the problem?
 What is not functioning as desired?

Identify the Problem – Ask When?

 Did it or will it happen?


 Why did it happen?
 When did it first occur?

Identify the Problem – Ask Where?

 Where is the problem occurring?


 Did it or will it have an impact?
 Where did it have an impact?

Identify the Problem – Ask Why?

 Why is this, a problem?


 Did it or will it occur?
 Why did it occur?
 Why was nothing done to prevent the problem from occurring?
 Why did no one recognize and do something about the problem at the earliest?
 Why is a response needed now?

Identify the Problem – Ask How?

 How should the process be working?


 How are others dealing with this or similar problems?
 How do you know this is a problem; what supporting information do you have?

Once the root cause is found, plans can be made to fix it. Analyzing implies gathering
information. If there is not enough information, they should find some ways to research and
collect it.

3. Set Goals: Having explored and analyzed the problem, managers should be able to write a
goal statement that focuses on what is the successful end of the process. Once the root cause is
found, plans can be made to fix it. Analyzing implies gathering information. If there is not
enough information, they should find some ways to research and collect it.

Making and writing down a goal statement will:

 help them to clarify the direction to be taken in solving the problem; and
 give them something definite to focus on

That is, what will occur as a result of the solution? This whole process is about fixing or closing
the gap between the problem and the goal. Writing down the problem ensures that they are not
side-tracking from, but addressing the problem.
4. Look at alternatives: Now that the problem has been analyzed, the managers can start
developing possible solutions. This is a creative as well as practical step where every possible
solution needs to be identified. They should identify the various alternative solutions available to
them through techniques such as –

 Analysis of past solutions


 Reading
 Researching & thinking
 Discussing
 Asking Questions
 Viewing the problem with fresh eyes
 Sleeping on it
 Brainstorming

The idea is to collect as many alternative solutions as possible. Mind mapping is another
technique that can be used for finding alternative solutions. Mind mapping uses pictures and/or
word phrases to organize and develop thoughts in a non-linear fashion. It helps people see a
problem and its solution.

Here’s how to do mind mapping:

 Take a sheet of plain paper and turn it sideways (if using flipchart paper you don’t need
to turn it sideways - it is large enough); Using colored felt pens, draw a small picture (or
write a phrase) in the centre of the paper representing the issue you want to solve; Draw
lines out from the main problem (it helps to use different colors for each line).
 Each line should represent a different aspect of your problem or issue;
 Write down what each line represents either on top of or on the line;
 Add other lines flowing off these main lines;
 Write a word or short phrase on the smaller lines indicating what each new line
represents (you may find that mind mapping works best for you if you write down the
phrases or draw the images first and then connect them with the lines); and
 If you want, add images next to your main line that illustrate what each line means to you
(some people think better with pictures, others with words).

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 problem-solving 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 individual’s role in implementing the decision?
 What are the results expected from each individual?
 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.

Essentials of Effective Problem Solving

 Clear description of the problem


 Description of the negative or limiting factors involved in the problem
 A description of the positive or the constructive factors involved in the problem
 A clear delineation of the “ownership” of the problem - Whose problem is it: mine,
yours, the other guy’s, my boss’, my spouse’s, my child’s, my parents’, my teacher’s?
 Scope of the problem need to be clearly defined: How extensive a problem is it? How
long has this problem existed? How many people are affected by this?
 A clear description of the consequences if the problem were not solved - What is the
possible impact on my family, job, life in this community, etc., if this problem isn’t
solved? What is the worst possible thing that could happen if this problem isn’t solved?
 A list of brainstormed solutions to the problem, with each alternative analyzed as to its
reality, its benefits, and the consequences for following each one.
 A system of ranking each solution to finalize the decision-making process - A rating
system for analyzing each solution is developed, e.g., 100% chance of success, 75%
chance of success, 50% chance of success.
 A clear description of myself as a problem-solver - When it comes to this problem, am I
procrastinating? Am I avoiding the problem? Am I denying the problem? Am I shutting
down or blocking my creativity on this problem? Am I ignoring it, hoping it will go
away? Am I using magical and/or fantasy thinking in addressing the problem?
 Determination to follow through on the solution decided upon jointly. This will involve
full motivation to “take the risk” and pursue the solution to its fullest.
 2.3. Phases in the Execution of a Computer Program
 In computer science, a computer program specifies the behavior that is invoked at some
point, causing that behavior to be exhibited by a running program. That means, a program
has a lifetime that includes distinct phases, starting with editing the code that specifies the
behavior, and extending till the execution of the code, which exhibits the specified
behavior. The major phases of a program's lifecycle are edit time, compile time,
distribution time, installation time, link time, load time, and run time.
 It is important to be aware that these phases do not necessarily happen in a linear order.
But, they can be intertwined in various ways. For instance, during development of the
program, edit time and compile time are repeatedly performed, without any link, load, or
execution.
 Edit time is the phase during which the code of the program is being edited. During this
phase, the code may not be finalised. The editing is usually performed by a human
programmer.
 Compile time is the phase during which the edited program or the source code is
translated into machine code by a compiler.
 A compiler is a computer program (or set of programs) that transforms source code
written in a programming language into another computer language (often having a
binary form known as object code). The reason for wanting to transform source code is to
create an executable program. The name "compiler" is primarily used for programs that
translate source code from a high-level programming language to a lower level language
(e.g., assembly language or machine code).
 The operations performed at compile time usually include syntax analysis, various kinds
of semantic analysis (e.g., type checks and instantiation of template) and code generation.
Programming language definitions usually specify compile time requirements that source
code must meet to compile successfully. For example, the amount of storage required by
types and variable can be deduced.
 Distribution time is the phase during which the program is sent from the entity that
created it, to the one that will invoke it. The format is typically an executable file, but
sometimes source code, especially in the case of a program written in an interpreted
language. The distribution method varies, from physical media such as CD-ROM, to
online download via the internet.
 Installation time is the phase occurring just after distribution. Here, a program is
received into a system that must perform some form of installation process. The process
of installation makes the program available to be executed within the system. The
installation process is able to invoke different phases of a program's lifecycle. For
instance, an executable may be analyzed and re-compiled during installation in order to
improve the execution on the particular hardware of the system being installed on.
 Link time is the phase during which the names of implementations are looked up and
connected together. For instance, a program that invokes libraries does so by stating the
name and an interface of the library. During link time the particular implementation of
that interface is connected to the program that invokes it. This connection can be done
inside the compilation system, or during the installation, as a part of starting execution, or
even invoked during the process of execution.
 Load time is the phase in which an executable image is taken from its stored form, and
placed into active memory, as part of starting execution.
 Run time is the phase during which the behavior of the program is exhibited. Run time is
the time during which a program is running (executing), in contrast to other phases of a
program's lifecycle such as compile time, link time, load time, etc.
 A run-time error is detected after or during the execution of a program, but a compile-
time error is detected by the compiler before the program is ever executed. Storage
allocation, type checking, code generation, and code optimization are typically done at
compile time; however it may be done at run time depending on the particular language
and compiler.

3.1. Introduction to basic programming concepts

When a programmer writes a program, he/she needs to write the instructions to store, process
and arrange data. Also, instructions are required to control the flow of the program. A
programmer needs to understand the following concepts to write a program:

 What is a data type and how to use a data type?


 What is a variable and its use?
 How to control the flow of the program?
 How to arrange and use a group of data?
 How to group a set of instructions into a single unit?
 How to create new data types?

A program is a sequence of instructions (written using a programming language) for


machine/computer to accomplish a task. A textual explanation of squence of instructions is
called an algorithm or pseudocode.

3.2. Datatypes

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 the
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.)

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 form.

A datatype represents the type of data, memory storage and the operations that can be
performed using the data.

Classifying data types

Data types are divided into primitive and composite types. The primitive data types are the basic
data types that are available in most of the programming languages.

Primitive data types are used to represent single values that include numeric types like integer or
float, boolean, character and string.

The data types that are derived from primary data types are known as non-primitive or composite
data types. These data types are used to store a group of values. Composite type includes Array,
Structure, Class etc.

Basic Data Types

Numeric type is divided into Integer type and Floating-point type. The table below shows the
division and examples for numeric types:

Numeric Types

Datatypes are mainly classified into primitve and composite types.

3.3. Introduction to variables

Variables and Constants

The input data needed for a program and the output data generated by the program are stored in
the computer memory. While writing a program, the programmer needs to specify the memory
required for storing the data needed for the program and generated by the program. The memory
location where data is stored is called a variable. The program can change the data in that
memory location any number of times, and hence the name.

A program also needs a memory location where it can store data but cannot alter it later. Such
memory locations are called constant memory locations.
Consider a program that finds the area of a circle. The program takes radius (numeric) as an
input data to calculate the area. When user gives the input data, the program stores it in the
memory for further calculation. The program also stores the result (area of circle) after
calculation. This means that the program uses at least two memory locations (two variables); one
for storing the input (radius of circle) and one for storing the result (area of circle). You know
that Pi is a constant and has a fixed value (3.14). In this program the value of Pi can be stored as
a constant because the program cannot alter the value of Pi.

Program Steps:

 Declare a variable radius to store radius of the circle.


 Declare a variable area to store the area of the circle.
 Declare a constant Pi to store the constant value.
 Calculate the area of circle ( Pi* radius* radius).
 Store the result in variable area.

A variable is a memory location whose value can change throughout the operation of a program.
A constant is a memory location whose associated value cannot be altered by the program during
its execution.

Actions using Variables

Following are the actions that a programmer can do using a variable:

 Declaring or creating a variable


 Initializing a variable
 Storing data to a variable
 Retrieving or fetching data from a variable

Declaring or Creating a variable

To declare or create a variable, the programmer needs to select an appropriate data type and a
meaningful name for the variable. The data type must be used only while declaring a variable.

The general format for declaring a variable is :

data-type variable-name;

Eg: int counter; String name;

Initializing a variable
Initializing a variable means putting an initial value to the variable(bucket). A variable can be
initialized while creating or declaring it.

Eg: int counter=0; char gender='M';

Storing data to a variable

Once a variable is created, data can be stored in the variable. An assignment operator(=) is used
in the program to store data to a variable. The initial value of the variable can be changed by
assigning a new value using the assignment operator(=).

counter = 10;

gender = ‘F’;

Retrieving or fetching data from a variable

To retrieve or fetch data from a variable, use the name of variable.

int x = 10; int y= 20;

int sum = x+y;

In the above program statement, the names of the variables (x and y) are used to retrieve the
values stored in the variables.

Always initialize a variable while declaring or after declaring it

3.4. Introduction to Operators

Operators are special symbols that perform specific operations on one or two operands, and then
return a result.

Consider a program that does mathematical operations like addition, subtraction, multiplication,
division on two numbers. (The program needs two variables to hold the two numeric values.)

int num1 ; // declares a variable num1 of type int to store the first numeric data.

int num2; // declares a variable num2 of type int to store the second numeric data.

int result; // declares a variable result of type int to store the result after operation.

result = num1 + num2; // add num1 and num2 and store the sum in variable result.
In the above program statements, num1 and num2 are the operands and + is the operator. The
sum of num1 and num2 is stored in the variable named result.

Operators can be classified into unary and binary operators. Unary operators are the operators
that deal with only one operand (one variable). Binary operators are the operators that deal with
two operands (variables or constants).

Links for reference:

http://msdn.microsoft.com/en-us/library/x04xhy0h.aspx

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.

3.5. Control structures

Introduction

A program is a set of instructions or commands given to a computer to do a specific activity or


task. The normal execution flow of program statements will be sequential. Sometimes the
sequential flow should be altered because of some conditions which change the flow.

For example, every day a person drives his car from city A to city B through a straight national
highway to reach his office. One day, there is a big traffic jam on the way to city B. If the person
wants to reach city B then the he has to select an alternate route. Here changing route is equal to
changing the flow of program (controlling the flow) and the decision of selectiing an alternate
route will be based on some parameters like distance or condition of the road.

Control structures help to control the flow of a program.

Types of control structures

Sequence, Selection and Repetition (Iteration) are the three main control structures used to
control the flow of program in any programming language.

Sequence:

Statements in the program will be executed one-by-one from the first to the last statement.
Selection:

The selection control structure allows one set of statements to be executed if a condition is true
and another set of statements to be executed if a condition is false.

The following are the common selection control structures use in programming languages.

 if
 if-else
 switch

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

Sequence, Selection and Repetition (Iteration) are the three main control structures used to
control the flow of program.

3.6. Introduction to Arrays

Introduction
Most of the programs deal with a group/collection of data. For example, list of bank account
numbers, exam scores, country names etc. Data could be primitive like integer or composite like
Date.

Program needs to arrange and manage these groups of data. All programming languages provide
one basic data structure named array, that helps to store and manage a group of data.

An array helps to store a collection of data (elements). Like the numbering used in the above
diagram, array uses an index to represent the location of each independent data stored in it.

The main ability of an array is to represent a group of data using a single name and accessing
each individual data stored in it using an index. In programming world, starting index of an array
will always be zero.

Arrays can be one dimensional, two dimensional or multi-dimensional. The figure given above
can be looked upon as a single dimensional array having a single row with 11 columns (0 – 10
seats).
Consider a program that needs to store the names of all the students participating in a quiz
program. The input data for the program is:

 Number of students participating in the quiz


 Names of the students

We need a variable to store the number of students and an array to store the names of students.

int count; //variable to store number of students

String nameArray[count]; // array to store names of students

An array is used to store a group of data of similar type.

Create and Use an Array

Creating and initializing an array

The general format for creating and initializing an array is given below.

datatype array_name[ ] = {value1 , value 2 , value3};

Eg. int nums_array[ ]={11, 22, 33,44,55} ;

Array Creation

Adding elements into an array


After creating an array, data can be added to it. For adding data to an array use the index of the
array. The general format for adding elements to an array is given below.

array_name[index] = value;

Eg. nums_array[0] = 88;

Retrieving data from an array

Use array index to retrieve data from an array.The general format of accessing data from an array
is given below:

variable_name = array_name[index];

Eg. num1 = nums_array[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. Let’s 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 individual score in an array and
iterating the array using a for loop.

3.7. Introduction to Functions

Introduction

Functions are a named group of program statements that perform a specific task. Functions are
reusable sets of code useful to other programs. Each function is like a black box that takes input,
processes it and gives the result.

Programs or functions can call any function to perform a task. A main function is the function
that has the main control flow of a program. All other functions are called sub functions of a
program. In object oriented programing languages like java, functions are called methods.

Functions are a named group of instructions that perform a specific task.

Defining a function

The following questions help to define a function:

 What specific task needs to be performed by the function (body)?


 What are the inputs (arguments/parameters) needed by the function to complete its task?
 Does function return any result? If it returns, what kind of result (data) does it return?
Each function has two parts, header and body. Function header specifies the name of the
function, input parameters and the output type. The function body contains the logic of the
function.

The general format of a function is as follows.

return_type functionName( [datatype parameter1, datatype parameter1, …]){

// 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

Function Examples

Example1: Function that takes an input, performs a task and returns a result.

Example2: Function that takes an input, performs a task and returns no result.

Example3: Function that takes no input, performs a task and returns a result.

Example4: Function that takes no input, performs a task and returns no result.

void alert(){

sendAlertMessage(“ Low Resource”);

}
The function alert takes no input, but performs a task via a function sendAlertMessage() and
does not return any output.

Calling/Invoking a function

The main function should know the name of the sub function and the arguments/inputs needed
by the sub function to invoke/call the sub function.

The common syntax for invoking a sub function is:

functionname([arguments]) ; or

result = function_name([arguments]); //store result in a variable, if function return some data

 float result = avg(10,20,30);


 int count= getCount();
 alert();
 store(“Happy B’day”)

3.8. Composite Datatypes

Introduction

Programs not only use primitive data types but also composite data types like Date, String,
Employee, Student etc. Composite data types are constructed using primitive data types and
other composite data types. Composite data types can be built-in data types (e.g. String or Date)
or programmer defined data types (e.g. Student, Employee).

Consider a program that stores the details of a group of students. Here each student has data like
Id, name, age, college, stream, and grade.

The program requires:

 A new data type, which represents a student


 An array, which can store the student details

Defining data type

Every programming language provides a way to define and use composite data types.

C programming language provides keywords like typedef and struct to define a composite data
type. Object oriented programming language like Java provides a keyword named Class to create
a composite data type.

C program
typedef struct {

int id;

char name[50]; // C language use character array as string

char college[100];

char stream[25]

char grade;

} Student;

Java program

class Student{

int id;

String name;

String college;

String stream;

char grade;

};

Both these programs define a new type Student, where Id, name, college, stream, grade are the
members (data members) or properties of Student type.

Creating a variable of composite type

Composite variables are created like primitive variables. A composite variable consists of a fixed
number of variables "glued together".

The example below shows how to declare and initialize composite variables.

Student stud1 ={ 100, “John” ,”SNC”,”EC”,’A’}; //structure in C

Student stud2 = new Student( 101,”Rohit”,”MIT”,”CS”,’A’); // object in Java


Accessing data members

A special operator named dot operator (.) is used to access data member of a composite data.

Here stud1 and stud2 are variables that store composite data.

char[ ] name = stud1.name;

String college = stud2.college

Composite variable consists of a fixed number of variables glued together.

4.1. Introduction to Developing a User Interface

Introduction

To work with a system, the users have to be able to control and assess the state of the system. For
example, when driving a vehicle, the driver of the vehicle uses the steering to control the
direction, and the accelerator pedal, brake pedal and gears to control the speed of the vehicle.
The driver understands the position of the vehicle by looking through the windshield and the
exact speed of the vehicle by checking the speedometer. The driver's interface of the automobile
is on the whole composed of the instruments that the driver can use to accomplish the tasks of
driving and maintaining the automobile. Interactive entities must constantly be designed to
support the way in which humans interact with the world and information.

In information technology, the user interface is everything designed into an information device
with which a human being may interact -- including the monitor, keyboard, mouse, the
appearance of a desktop, characters in text, help messages, and how an application or a Web site
invites interaction and responds to it. In the previous generations of computers, there was very
little user interface except for a few buttons at an operator's console. The user interface was
mainly in the form of punched card input and report output.

Later, a user was provided with the ability to interact with a computer online and the user
interface was a nearly blank display screen with a command line, a keyboard, and a limited set of
commands and computer responses that were exchanged. This command line led to a new form
of interface in which menus (list of choices written in text) predominated. Eventually, the
graphical user interface (GUI) arrived, originating predominantly in Xerox's Palo Alto Research
Center, adopted and enhanced by Apple Computers, and finally standardized effectively by
Microsoft in its Windows operating systems.
The user interface can, essentially include the total "user experience," which may include the
aesthetic appearance of the device, response time, and the content that is presented to the user
within the context of the user interface.

Different types of User Interface

The three most common types of User Interfaces are:

 Command Line Interface (CLI)


 Graphical User Interface (GUI)
 Web User Interface (WUI)

However, a few other types of User Interfaces also exist

 Touch User Interface(CLI)


 Voice User Interface

Command Line User Interface:

In a command line user interface, the user provides the input by typing a command string with
the computer keyboard and the system provides output by printing text on the computer monitor.
This is normally used by programmers and system administrators, and by technically advanced
personal computer users.

A good example of command line user interface is the windows command prompt, as seen in the
image below.

The advantages of using a command line user interface are:

 Consumes low bandwidth – As the command line interface is devoid of any graphics or
extra data, this is especially useful in a networked environment where network traffic is
to be limited.
 Appeals to expert users – as the commands relevant to a particular task give information
about that task only, any other extra data/information that could potentially cause a
distraction to the user are easily avoided.

However this type of user interface 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 won't be comfortable with the command
line interface.
 Not very user friendly and hence error rates are high – especially when a user is
trying to enter data. A mistake made in typing while using command line is often not
forgiven. That is, a user is usually not warned or prompted for confirmation while using
direct commands in the command line. Hence chances of wrong data being entered are
very high.

Graphical User Interface (GUI):

Graphical User Interface is a type of user interface that allows users to interact with computers
using images rather than text commands. A GUI presents the user with information and actions
available to a user through graphical icons (like My Computer, Recycle Bin icons in Windows)
and visual indicators such as secondary notation, as against text-based interfaces, typed
command labels or text-based navigation. The actions are generally performed through direct
manipulation of the graphical elements (such as clicking on the icons, double clicking etc).

GUI typically allows user interaction with the system through the use of visual elements, such as
windows, buttons, tables, forms, menus, etc. thus freeing the user from learning complex
command languages. This kind of interface takes advantage of the computer's graphics
capabilities to make the program easier to use.

A typical GUI looks like the one in the image below

Basic Components of a GUI:

Pointer - A symbol that appears on the display screen and that you move to select objects and
commands. Usually, the appearance of the pointer is that of a small angled arrow. Word-
processing applications, use an I-beam pointer instead, that is shaped like a capital I.

Pointing device - A device, such as a mouse or trackball, that enables you to select objects on
the display screen.

Icons - Small pictures that represent windows, files or commands. By moving the pointer to the
icon and clicking the mouse button, you can convert the icon into a window or execute a
command. You can also move the icons around the display screen as if they were real objects on
your table.

Windows - You can divide the screen into different areas. In each window, you can display a
different file or run a different program. You can change the size and shape of the windows and
even move them around the display screen at will.
Menus - Most graphical user interfaces let you execute commands by selecting a choice from a
menu.

Toolbars - Represent a group of buttons that perform related functionality and generally have
icons over them instead of text.

Use of GUI over Command line user interface provides us with the following benefits:

Increase in productivity – for normal users, 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 costs are significantly reduced.

Increase in customer satisfaction (aggravation and frustration are reduced) – Most users are
used to Windows and general graphical tools. Hence a simple, consistent and well-designed
interface will enable the users to get used to a new application faster.

Web User Interface (WUI):

WUI is a subset (or a type of) of Graphical User Interface (GUI). WUI accepts inputs and
provides output by generating web pages which are transmitted via the Internet and viewed by
the user using a web browser program.

A typical WUI is depicted in the image below

All Benefits and Attributes that apply to GUI also apply to a WUI.

4.2. What is the need for a good UI

What is the need for a good UI?

For most of the end users, User Interface is the System. Hence the look and feel that a User
Interface provides is one of the major factors that decide the User Satisfaction and User
Experience. For example, if cost isn't a factor for the same function (of making calls), which one
out of the two phones below would you prefer??
A remarkably good User Interface Design can act as the difference between product acceptance
and rejection in the marketplace.

A cumbersome, not easy to learn/ use UI in an otherwise excellent product could result in the
failure of that product. Good User Interface can make a product easy to understand and/or easy
to use, which results in greater user acceptance. Poor user interface is the reason why many
software systems are never even used.

A badly designed user interface can cause a user to make catastrophic errors.

The best example of this from real world is the "Butterfly Ballot" used in Palm Beach, Florida
during the 2000 U.S. presidential election which was a fiasco primarily due to the design of a
confusing user interface.

If the designers of that ballot understood the basics of user interface design, there may very well
have been a different outcome to the electio

Potrebbero piacerti anche