You are on page 1of 29

Today’s Objectives

• Programming Languages
– High level, assembly and machine language
– Compilers and how they work
– Interpreters

• Software Development: the key activities

73
What is a Programming language?
Sequence of instructions

Algorithm Program
(in human language) (in computer language)

• A programming language is a set of rules that provides a


way of telling a computer what operations to perform
– Set of rules for communicating an algorithm
– Provides a linguistic framework for describing computations
• Many programming languages exist
– Low-level: directly understandable by computer
– High-level: needs a translator
Levels of programming languages

• (Binary) Machine language


– Unintelligible to human user
• Low-level assembly language
– Mnemonic names for machine operations
– Explicit manipulation of memory addresses
– Machine-dependent
• High-level language
– Readable
– Machine-independent
Levels of programming languages
class Triangle {
...
float surface()
High-level Language Program return b*h/2;
}

LOAD r1,b
LOAD r2,h
MUL r1,r2
Low-level Language Program DIV r1,#2
RET

0001001001000101001001
Executable Machine code 001110110010101101001.
..
Types of Programming Languages

• First Generation Languages


• Second Generation Languages
• Third Generation Languages
• Fourth Generation Languages
• Fifth Generation Languages
First Generation Languages

• Machine language
– Operation codes specify the operation to
perform, like addition or subtraction.
– Operands identify the data to be processed.
– Machine language is machine dependent as it is
the only language the computer can understand.
• Core i7s and ARM Processors have different machine
languages
– Very efficient code but very difficult to write.
Second Generation Languages

• Assembly languages
– Symbolic operation codes replaced binary
operation codes.
– Assembly language programs needed to be
“assembled” for execution by the computer. Each
assembly language instruction is translated into
one machine language instruction.
– Very efficient code and easier to write.
Third Generation Languages

• Closer to English but included simple


mathematical notation.
– Programs written in source code which must be
translated into machine language programs called
object code.
– The translation of source code to object code is
accomplished by a machine language system
program called a compiler.
Third Generation Languages

• Alternative to compilation is interpretation


which is accomplished by a system program
called an interpreter.
• Common third generation languages
– FORTRAN
– COBOL
– C, C++, Java, C#
– VB, VC++
4th & 5th Generation Languages

• 4GL: A high level language that requires


fewer instructions to accomplish a task than a
third generation language.
– Commonly used with databases
• Query languages (example: SQL)
• 5GL: Declarative and Rule-based languages
– LISP, Prolog etc., used in AI
Examples of Programming Languages
• FORTRAN
– FORmula TRANslation
– Developed at IBM in the mid-1950s
– Designed for scientific and mathematical applications by
scientists and engineers
• COBOL
– COmmon Business Oriented Language.
– Developed in 1959.
– Designed to be common to many different computers.
– Typically used for business applications.
Examples of Programming Languages
• C
– Procedural language developed by Bell Laboratories in early 1970s.
– Provides control and efficiency of assembly language while having
third generation language features.
• Often used for system programs.
• Example: >90% of UNIX is written in C; many other OSs.
• JAVA
– An object-oriented language
– Allows a web page developer to create programs for applications,
called applets that can be used through a browser.
– Objective of JAVA developers is that it be machine, platform and
operating system independent.
• Others: Scripting languages like VBScript/Javascript;
Markup languages like HTML etc.
Programming languages are languages

• Learning to speak and use a programming language is in


many ways like learning to speak a human language
– In both kind of languages you have to learn new vocabulary,
syntax and semantics (new words, sentence structure and
meaning)
– Both kind of language require lots of practice to make perfect.
• BUT
• Computer languages lack ambiguity and vagueness
– Take a handful of sand (How much is a handful?)
– The man with the gun stood up (Who exactly?)
• In a programming language a sentence either means one
thing or it means nothing – no ambiguity
How Translators work

• Compilers
– Convert HLL statements into low-level/assembly code
• Assemblers
– Convert assembly code into machine code
• Libraries
– Collections of useful pre-compiled functions
• Linkers
– Link the relevant libraries to your compiled code to create the final
executable file (.exe)
• IDEs
– Combine all of the capabilities needed for developing software
– Examples: Microsoft VC++ IDE, Netbeans (Oracle), (Open Source) Code
Blocks, Eclipse etc.
Today’s Objectives

• Software Development
– Program versus software product
– Key SDLC activities

87
Program versus S/W Product
Program Software Product
• Small scale • Medium to large scale
• Developed quickly, without • Detailed project planning,
detailed design design and implementation
• Single/small group of • Large, possible distributed team
developers of developers
• Single user/small group of • Medium to large market of end
target users users
• No associated documentation • Proper documentation and well
or maintenance support planned maintenance phases

88
Software Development Life Cycle
• Very important to clearly identify the various
phases of the software development process
– Identify the key activities of each phase
– Define the entry/exit criteria for each phase
• Phases
– Feasibility Study
– Requirements gathering, analysis and specification
– Design
– Implementation and Unit Testing
– Integration and System Testing
89
– Maintenance
Feasibility Study
• Main aim: determine whether developing the product is
– Financially worthwhile
– Technically feasible
• Activities during Feasibility Study
– Work out an overall understanding of the problem.
– Formulate different solution strategies.
– Analyze alternate solution strategies in terms of resources
required, cost of development, and development time.
– Do cost/benefit analysis to determine which solution is best.
• Phase Outcome/Exit criterion
– Is this project a viable / profitable / feasible option for the
organization or not?
90
Requirements Analysis and Specification

• Aim of the phase:


– To understand the exact requirements of the customer,
– To document them properly.
• Consists of two distinct activities:
– requirements gathering and analysis
– requirements specification.
• Engineers doing requirements analysis and specification
are called analysts in the software industry
• Outcome/ Exit criterion
– Software Requirements Specification (SRS) Document

91
Design
• Aims/activities of the phase:
– To transform the requirements specification into a form suitable
for implementation in some programming language
– During this phase, the software architecture is derived from the
SRS document.
• Outcome
– Software architecture of the top level modules of the software
detailing the data organization and algorithms within each
module

92
Coding and Unit Testing
• Aim of the phase:
– To translate software design into source code of the chosen
programming language.
• Activities
– Each module of the design is coded
– Each module is unit tested: tested independently
– Each module is documented
• Outcome/Exit Criteria:
– A set of program modules that have been individually tested and
documented

93
Integration and System Testing

• Different modules are integrated in a planned manner


– Normally integration is carried out through a number of steps.
• During each integration step, the partially integrated
system is tested.
• After all modules have been successfully integrated and
tested, system testing is carried out.
• Goal of system testing: to ensure that the developed
system functions according to its requirements as
specified in the SRS document.

94
Maintenance Phase
• Maintenance of a software product:
– Requires much more effort than the effort to develop the
product itself.
– development effort to maintenance effort is typically 40:60.
– Adaptive, corrective and perfective maintenance

95
Relative Effort for Phases
• Maintenance of a software product:
– Requires much more effort than the effort to develop the product itself.
– development effort to maintenance effort is typically 40:60.
– Adaptive, corrective and perfective maintenance
60
Relative Effort
• Phases between feasibility 50
study and testing 40
– known as development phases.
30
• Among all life cycle phases 20
– maintenance phase consumes
maximum effort. 10

• Among development phases, 0

Maintnce
Design

Test
Coding
Req. Sp
– testing phase consumes the
maximum effort. 96
SDLC Models

• Many followed by software companies all over


the world
– Classical Waterfall Model
• Iterative Waterfall
– Evolutionary/Iterative Enhancement
– Prototyping Model
– Many others…
Why Software Engineering
is so important
• Mars Climate Orbiter crashed in September 1999 because of
wrong units in a program.
• Shooting down of Airbus A320 by USS Vincennes, 1988
– attributed to the cryptic and misleading output displayed by the
tracking software
• Ariane 5 satellite launcher malfunction cause:
– Faulty code reuse
• Knight Capital, 2012, lost $440,000,000 in 30 minutes due to
bug in trading algorithms
• Blackout in 2003 across eight US states and Canada affected 50
million people caused by a race condition bug
• World War 3 (almost) during Cold War!
• Tesla Autopilot Crash, May 2016
Today’s Objectives

• Algorithms and Heuristics


• Flowcharts and Pseudo-code
• Examples

100
Algorithms, Heuristics

• An algorithm is a set of well-defined


instructions for carrying out a particular task.
– Must be sound and complete
– Sound: an algorithm gives you a correct answer
– Complete: works for all cases.
• Usually, algorithms are predictable,
deterministic, and not subject to chance steps
for solving a specific problem
• Heuristics are short cuts or "rules of thumb"
that give some guidance on how to do a task,
but it do not guarantee solutions consistently.