2. Introduction to programming
โข A Computer is an electronic device that accepts data, performs
computations, and makes logical decisions according to instructions
that have been given to it; then produces meaningful information in a
form that is useful to the user.
โข They have been deployed to solve different real life problems, from
the simplest game playing up to the complex nuclear energy
production.
โข Computers are important and widely used in our society because
they are cost-effective aids to problem solving in business,
government, industry, education, etc.
3. Cont.โฆ
โข In order to solve a given problem, computers must be given the
correct instruction about how they can solve it.
โข The terms computer programs, software programs, or just programs
are the instructions that tells the computer what to do.
โข Computer requires programs to function, and a computer programs
does nothing unless its instructions are executed by a CPU.
โข Computer programming (often shortened to programming or coding)
is the process of writing, testing, debugging/troubleshooting, and
maintaining the source code of computer programs.
4. โข Writing computer programs means writing instructions, that will make
the computer follow and run a program based on those instructions.
โข Each instruction is relatively simple, yet because of the computer's
speed, it is able to run millions of instructions in a second.
โข A computer program usually consists of two elements:
โข Data โ characteristics
โข Code โ action
โข Computer programs (also know as source code) is often written by
professionals known as Computer Programmers (simply programmers).
Cont.โฆ
5. โข Source code is written in one of programming languages.
โข A programming language is an artificial language that can be used to
control the behavior of a machine, particularly a computer.
โข Programming languages, like natural language (such as Amharic), are
defined by syntactic and semantic rules which describe their structure
and meaning respectively.
โข The syntax of a language describes the possible combinations of
symbols that form a syntactically correct program.
โข The meaning given to a combination of symbols is handled by semantic
Cont.โฆ
6. โข Programming languages allow humans to communicate instructions
to machines.
โข A main purpose of programming languages is to provide instructions
to a computer.
โข Programming languages differ from most other forms of human
expression in that they require a greater degree of precision and
completeness.
โข When using a natural language to communicate with other people,
human authors and speakers can be ambiguous and make small
errors, and still expect their intent to be understood.
Cont.โฆ
7. โข Computers do exactly what they are told to do, and cannot
understand the code the programmer "intended" to write.
โข So computers need to be instructed to perform all the tasks.
โข The combination of the language definition, the program, and the
program's inputs must fully specify the external behavior that occurs
when the program is executed.
โข Computer languages have relatively few, exactly defined, rules for
composition of programs, and strictly controlled vocabularies in which
unknown words must be defined before they can be used.
Cont.โฆ
8. โข Available programming languages come in a variety of forms and
types.
โข Thousands of different programming languages have been developed,
used, and discarded.
โข Programming languages can be divided in to two major categories:
๏low-level and
๏ high-level languages.
Cont.โฆ
9. Low-level languages
โข Computers only understand one language and that is binary language or the
language of 1s and 0s.
โข Binary language is also known as machine language, one of low-level
languages.
โข In the initial years of computer programming, all the instructions were given
in binary form.
โข Although the computer easily understood these programs, it proved too
difficult for a normal human being to remember all the instructions in the
form of 0s and 1s.
โข Therefore, computers remained mystery to a common person until other
languages such as assembly language was developed, which were easier to
learn and understand.
10. โข Assembly language correspondences symbolic instructions and
executable machine codes and was created to use letters (called
mnemonics) to each machine language instructions to make it easier
to remember or write.
โข For example: ADD A, B โ adds two numbers in memory location A and
B
โข Assembly language is nothing more than a symbolic representation of
machine code, which allows symbolic designation of memory
locations.
โข However, no matter how close assembly language is to machine code,
computers still cannot understand it.
Cont.โฆ
11. โข The assembly language must be translated to machine code by a
separate program called assembler.
โข The machine instruction created by the assembler from the original
program (source code) is called object code.
โข Thus assembly languages are unique to a specific computer (machine).
โข Assemblers are written for each unique machine language.
โข Although programming in assembly language is not as difficult and error
prone as stringing together ones and zeros, it is slow and cumbersome.
โข In addition it is hardware specific.
Cont.โฆ
12. High-level languages
โข The lack of portability between different computers led to the
development of high-level languagesโso called because they
permitted a programmer to ignore many low-level details of the
computer's hardware.
โข Further, it was recognized that the closer the syntax, rules, and
mnemonics of the programming language could be to "natural
language" the less likely it became that the programmer would
inadvertently introduce errors (called "bugs") into the program.
โข High-level languages are more English-like and, therefore, make it
easier for programmers to "think" in the programming language.
13. โข High-level languages also require translation to machine language
before execution.
โข This translation is accomplished by either a compiler or an
interpreter.
โข Compilers translate the entire source code program before
execution.
โข Interpreters translate source code programs one line at a time.
โข Interpreters are more interactive than compilers.
โข FORTRAN (FORmula TRANslator), BASIC (Bingers All Purpose Symbolic
Instruction Code), PASCAL, C, C++, Java are some examples of high-
level languages.
Cont.โฆ
14. โข The question of which language is best is one that consumes a lot of
time and energy among computer professionals.
โข Every language has its strengths and weaknesses.
โข For example, FORTRAN is a particularly good language for processing
numerical data, but it does not lend itself very well to organizing large
programs.
โข Pascal is very good for writing well-structured and readable programs,
but it is not as flexible as the C programming language.
โข C++ embodies powerful object-oriented features
Cont.โฆ
15. โข As might be expected in a dynamic and evolving field, there is no
single standard for classifying programming languages.
โข Another most fundamental ways programming languages are
characterized (categorized) is by programming paradigm.
โข A programming paradigm provides the programmer's view of code
execution.
Cont.โฆ
16. Procedural Programming Languages
โข Procedural programming specifies a list of operations that the program
must complete to reach the desired state.
โข Each program has a starting state, a list of operations to complete, and
an ending point.
โข This approach is also known as imperative programming.
โข Integral to the idea of procedural programming is the concept of a
procedure call.
โข Procedures, also known as functions, subroutines, or methods, are small
sections of code that perform a particular function.
โข A procedure is effectively a list of computations to be carried out.
17. โข Procedural programming can be compared to unstructured
programming, where all of the code resides in a single large block.
โข By splitting the programmatic tasks into small pieces, procedural
programming allows a section of code to be re-used in the program
without making multiple copies.
โข It also makes it easier for programmers to understand and maintain
program structure.
โข Two of the most popular procedural programming languages are
FORTRAN and BASIC.
Cont.โฆ
18. Structured Programming Languages
โข Structured programming is a special type of procedural programming.
โข It provides additional tools to manage the problems that larger
programs were creating.
โข Structured programming requires that programmers break program
structure into small pieces of code that are easily understood.
โข It also frowns upon the use of global variables and instead uses
variables local to each subroutine.
19. โข One of the well-known features of structural programming is that it
does not allow the use of the GOTO statement.
โข It is often associated with a "top-down" approach to design.
โข The top-down approach begins with an initial overview of the system
that contains minimal details about the different parts.
โข Subsequent design iterations then add increasing detail to the
components until the design is complete.
โข The most popular structured programming languages include C, Ada,
and Pascal.
Cont.โฆ
20. Object-Oriented Programming Languages
โข Object-oriented programming is one the newest and most powerful
paradigms.
โข In object- oriented programs, the designer specifies both the data
structures and the types of operations that can be applied to those
data structures.
โข This pairing of a piece of data with the operations that can be
performed on it is known as an object.
โข A program thus becomes a collection of cooperating objects, rather
than a list of instructions.
โข Objects can store state information and interact with other objects,
but generally each object has a distinct, limited role.
21. Problem solving Techniques
โข Computer solves varieties of problems that can be expressed in a
finite number of steps leading to a precisely defined goal by writing
different programs.
โข A program is not needed only to solve a problem but also it should be
reliable, (maintainable) portable and efficient.
โข In computer programming two facts are given more weight:
๏The first part focuses on defining the problem and logical procedures
to follow in solving it.
๏The second introduces the means by which programmers
communicate those procedures to the computer system so that it can
be executed.
22. โข There are system analysis and design tools, particularly flowchart
and structure chart, that can be used to define the problem in terms
of the steps to its solution.
โข The programmer uses programming language to communicate the
logic of the solution to the computer.
โข Before a program is written, the programmer must clearly understand
what data are to be used, the desired result, and the procedure to
be used to produce the result.
โข The procedure, or solution, selected is referred to as an algorithm.
Cont.โฆ
23. โข An algorithm is defined as a step-by-step sequence of instructions
that must terminate and describe how the data is to be processed to
produce the desired outputs.
โข Simply, algorithm is a sequence of instructions.
โข Algorithms are a fundamental part of computing.
โข There are three commonly used tools to help to document program
logic (the algorithm).
โข These are flowcharts, structured chart, and Pseudo code.
โข Generally, flowcharts work well for small problems but Pseudo code
is used for larger problems.
Cont.โฆ
24. Pseudo code
โข Pseudocode (derived from pseudo and code) is a compact and
informal high-level description of a computer algorithm that uses the
structural conventions of programming languages, but typically omits
detailes such as subroutines, variables declarations and system-
specific syntax.
โข The programming language is augmented with natural language
descriptions of the details, where convenient, or with compact
mathematical notation.
25. โข The purpose of using pseudocode is that it may be easier for humans
to read than conventional programming languages, and that it may be
a compact and environment-independent generic description of the
key principles of an algorithm.
โข No standard for pseudocode syntax exists, as a program in
pseudocode is not an executable program.
โข As the name suggests, pseudocode generally does not actually obey
the synatx rules of any particular language;
โข there is no systematic standard form, although any particular writer
will generally borrow the appearance of a particular language.
Cont.โฆ
26. โข The programming process is a complicated one.
โข You must first understand the program specifications, of course, Then
you need to organize your thoughts and create the program.
โข This is a difficult task when the program is not trivial (i.e. easy).
โข You must break the main tasks that must be accomplished into
smaller ones in order to be able to eventually write fully developed
code.
โข Writing pseudo code will save you time later during the construction
& testing phase of a program's development.
Cont.โฆ
27. Example:
โข Original Program Specification:
๏Write a program that obtains two integer numbers from the user. It
will print out the sum of those numbers.
โข Pseudocode:
Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the sum
Display the result
Cont.โฆ
28. โข Example: pseudo code for a program that calculates the area of a
square:
๏Get the length of one side
๏Multiply the length by itself
๏Store the result in a variable called area
๏Display the area
Cont.โฆ
29. Structured Charts
โข Structured chart depicts the logical functions to the solution of the problem using
a chart.
โข It provides an overview that confirms the solution to the problem without
excessive consideration to detail.
โข It is high-level in nature.
โข Example: Write a program that asks the user to enter a temperature reading in
centigrade and then prints the equivalent Fahrenheit value.
Input Process Output
Centigrade ๏ท Prompt for centigrade value
๏ท Read centigrade value
๏ท Compute Fahrenheit value
๏ท Display Fahrenheit value
Fahrenheit
30. Flowchart
โข A flowchart (also spelled flow-chart and flow chart) is a schematic
representation of an algorithm or a process .
โข The advantage of flowchart is it doesnโt depend on any particular
programming language, so that it can used, to translate an algorithm
to more than one programming language.
โข Flowchart uses different symbols (geometrical shapes) to represent
different processes.
32. โข Example 1: - Draw flow chart of an algorithm to add two numbers and display
their result.
โข Algorithm description
๏Read the rules of the two numbers (A and B)
๏Add A and B
๏ Assign the sum of A and B to C
๏ Display the result ( c)
Cont.โฆ
33. โข Example 2: Write an algorithm description and draw a flow chart to check a number is negative or
not.
โข Algorithm description.
๏1/ Read a number x
๏2/ If x is less than zero write a message negative
๏else write a message not negative
Cont.โฆ
34. โข Some times there are conditions in which it is necessary to execute a group of
statements repeatedly. Until some condition is satisfied.
โข This condition is called a loop.
โข Loop is a sequence of instructions, which is repeated until some specific
condition occurs.
โข A loop normally consists of four parts.
โข These are:
โข Initialization: - Setting of variables of the computation to their initial values
and setting the counter for determining to exit from the loop.
โข Computation: - Processing
โข Test: - Every loop must have some way of exiting from it or else the program
would endlessly remain in a loop.
โข Increment: - Re-initialization of the loop for the next loop.
Cont.โฆ
35. โข Example 3: - Write the algorithmic description and draw a flow chart to find the
following sum.
โข Sum = 1+2+3+โฆ. + 50
โข Algorithmic description
1. Initialize sum too and counter to 1
โข If the counter is less than or equal to 50
โข Add counter to sum
โข Increase counter by 1
โข Repeat step 1.1
Else
โข Exit
2. Write sum
Cont.โฆ
36. System Development Life Cycle (SDLC)
โข The Systems Development Life Cycle (SDLC) is a conceptual model
used in project management that describes the stages involved in a
computer system development project from an initial feasibility study
through maintenance of the completed application.
โข Feasibility study
๏The first step is to identify a need for the new system.
๏This will include determining whether a business problem or
opportunity exists, conducting a feasibility study to determine if the
proposed solution is cost effective, and developing a project plan.
๏This process may involve end users who come up with an idea for
improving their work or may only involve IS people.
37. โข Ideally, the process occurs in tandem with a review of the
organization's strategic plan to ensure that IT is being used to help
the organization achieve its strategic objectives.
โข Management may need to approve concept ideas before any money
is budgeted for its development.
โข A preliminary analysis, determining the nature and scope of the
problems to be solved is carried out.
โข Possible solutions are proposed, describing the cost and benefits.
โข Finally, a preliminary plan for decision making is produced.
Cont.โฆ
38. โข The process of developing a large information system can be very
costly, and the investigation stage may require a preliminary study
called a feasibility study, which includes e.g. the following
components:
๏Organizational Feasibility
๏Economic Feasibility
๏Technical Feasibility
๏Operational Feasibility
Cont.โฆ
39. a. Organizational Feasibility
๏How well the proposed system supports the strategic objectives of the organization.
b. Economic Feasibility
๏ Cost savings
๏ Increased revenue
๏ Decreased investment
๏ Increased profits
c. Technical Feasibility
๏Hardware, software, and network capability, reliability, and availability
d. Operational Feasibility
๏ End user acceptance
๏ Management support
๏ Customer, supplier, and government requirements
Cont.โฆ
40. Requirements analysis
โข Requirements analysis is the process of analyzing the information needs
of the end users, the organizational environment, and any system
presently being used, developing the functional requirements of a
system that can meet the needs of the users.
โข Also, the requirements should be recorded in a document, email, user
interface storyboard, executable prototype, or some other form.
โข The requirements documentation should be referred to throughout the
rest of the system development process to ensure the developing project
aligns with user needs and requirements.
โข End users must be involved in this process to ensure that the new system
will function adequately and meets their needs and expectations.
41. Designing solution
โข After the requirements have been determined, the necessary
specifications for the hardware, software, people, and data resources,
and the information products that will satisfy the functional
requirements of the proposed system can be determined.
โข The design will serve as a blueprint for the system and helps detect
problems before these errors or problems are built into the final system.
โข The created system design, but must reviewed by users to ensure the
design meets users' needs.
Testing designed solution
โข A smaller test system is sometimes a good idea in order to get a โproof-
of-conceptโ validation prior to committing funds for large scale fielding
of a system without knowing if it really works as intended by the user.
42. Implementation
โข The real code is written here.
โข Systems implementation is the construction of the new system and its
delivery into production or day-to-day operation.
โข The key to understanding the implementation phase is to realize that
there is a lot more to be done than programming.
โข Implementation requires programming, but it also requires database
creation and population, and network installation and testing.
โข You also need to make sure the people are taken care of with effective
training and documentation.
โข Finally, if you expect your development skills to improve over time,
you need to conduct a review of the lessons learned.
43. Unit testing
โข Normally programs are written as a series of individual modules,
these subject to separate and detailed test.
Integration and System testing
โข Brings all the pieces together into a special testing environment, then
checks for errors, bugs and interoperability.
โข The system is tested to ensure that interfaces between modules work
(integration testing), the system works on the intended platform and
with the expected volume of data (volume testing) and that the
system does what the user requires (acceptance/beta testing).
44. Maintenance
โข What happens during the rest of the software's life: changes,
correction, additions, moves to a different computing platform and
more.
โข This, the least glamorous and perhaps most important step of all,
goes on seemingly forever.