Hun Myoung Park, Ph.D.

44
Programming & S/W Development Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International University of Japan

description

Introduction to Electronic Government Programming & Software Development Saturday, September 20, 2014. Hun Myoung Park, Ph.D. Public Management & Policy Analysis Program Graduate School of International Relations. Programming Languages. To communicate between human beings and computers - PowerPoint PPT Presentation

Transcript of Hun Myoung Park, Ph.D.

Page 1: Hun Myoung Park,  Ph.D.

Programming & S/W Development

Hun Myoung Park, Ph.D.,

Public Management and Policy Analysis ProgramGraduate School of International Relations

International University of Japan

Page 2: Hun Myoung Park,  Ph.D.

OutlineProgramming LanguagesLanguage TranslatorsSoftware DevelopmentSoftware Analysis and DesignProgrammingImplementation & MaintenanceDocumentation

2

Page 3: Hun Myoung Park,  Ph.D.

Programming LanguagesTo communicate between human beings

and computersInstruct a computer (H/W) to do what you

want to get using a programming languageEach computer can understand its own

machine language onlyInstructions can be written in programming

languages and then translated into the corresponding machine language.

3

Page 4: Hun Myoung Park,  Ph.D.

Machine LanguageFirst generation languageConsists of 1 and 0Only language that computers can

understandEach computer has its own machine langue

(machine dependent)Difficult to write and read programs

4

Page 5: Hun Myoung Park,  Ph.D.

Assembly LanguageSecond generation languageReplace machine language’s binary codes for

instructions and addresses with corresponding symbols and mnemonics

1:1 matchTranslated by assembler More technical and fasterBut less flexible and user friendly (not easy

to read)

5

Page 6: Hun Myoung Park,  Ph.D.

High Level Languages 1Less machine dependentMore readable (closer to human languages

and farther away from machine language) and flexible

But less efficient (bigger and slower)Need to be translated into a machine

language (interpretation or compilation)

6

Page 7: Hun Myoung Park,  Ph.D.

High Level Languages 2BASIC (Beginner’s All-purpose Symbolic

Instruction Code)FORTRAN (FORmula TRANslator) by IBMCOBOL (Common Business Oriented

Language) by ANSI. ADA, PL/1, Pascal

7

Page 8: Hun Myoung Park,  Ph.D.

High Level Languages 3C by Bell Lab C++, and Visual CJAVA by Sun MicrosystemsWeb programming (script) languages: Perl,

PHP, Python, Ruby

8

Page 9: Hun Myoung Park,  Ph.D.

Types of Languages 1First generation (machine language) Second generation (assembly language) Third (high level language), forth (query

languages), and fifth (natural & intelligent languages) generation languages

9

Page 10: Hun Myoung Park,  Ph.D.

Type of Languages 2Low-level languages (i.e., machine &

assembly language) High-level languages (e.g., C and Java) Script languages (e.g., Perl, PHP, Python)

10

Page 11: Hun Myoung Park,  Ph.D.

1st GL (Machine) 2nd GL (Assembly) 3rd GL (High level)

Mac

hine

Frie

ndlin

ess

& H

/W C

ontr

olS

ize

/ Tim

e S

pent

Larger & slower

Smaller & faster

More difficult to work with(Closer to machine)

More control of H/W(More risky to write)

Easier to work with(Closer to human)

Less control of H/W(Less risky to write)

11

Page 12: Hun Myoung Park,  Ph.D.

Programming ParadigmsProcedural programmingObject-oriented programming Functional programmingDeclarative programming

12

Page 13: Hun Myoung Park,  Ph.D.

Procedural Programming 1Imperative or structured languagesTells the computer what you want it to do

step by stepFORTRAN, COBOL, BASIC, C, Pascal, Ada

13

Page 14: Hun Myoung Park,  Ph.D.

Procedural Programming 2Procedures (actions) & objects (data) are

independentPassive objects that cannot initiate an

action by itselfA subprogram (routine or module) is a

section of the program that performs a particular task when it is called from the main program.

14

Page 15: Hun Myoung Park,  Ph.D.

Object-oriented Programming 1Active Objects have both data and

methods (procedures or actions)Methods are not independent of but belong

to the active object.Objects need stimulus to perform actionsVisual Basic, Visual C, C++, Java, SmalltalkEven in script languages (PHP & Python)

15

Page 16: Hun Myoung Park,  Ph.D.

Object-oriented Programming 2A class is a abstract blueprint of objects

that have data and methods An object (instance) is an (actualized)

instance of the class (variables + actions)A class of human beings (name, gender,

height… + eating, sleeping, speaking …)An object of human beings (Seohyun,

170cm, 40Kg … + eating milk, … )

16

Page 17: Hun Myoung Park,  Ph.D.

Object-oriented Programming 3class human {

public name …

public height …

function eating (…) {

}

function studying (…) {

...

}

} // end of class

17

Page 18: Hun Myoung Park,  Ph.D.

Object-oriented Programming 4Inheritance: a class can inherit from other

classes. A class student inherits data and methods from a class human being and has its own data and methods

Student = human beings + student’s data and methods

Faculty = human beings + faculty’s data and methods

Staff = human beings + staff’s data and methodsCodes are reusable (minimize redundancy)

18

Page 19: Hun Myoung Park,  Ph.D.

Object-oriented Programming 5Data abstraction and decoupling:

separating objects from classesEncapsulation and information hiding: Data

are bound closely with their methods. Polymorphism enables to define methods

with the same name that do difference things depending on classes.

A work() may mean teaching in a class faculty but farming in a class farmer.

19

Page 20: Hun Myoung Park,  Ph.D.

Functional ProgrammingDefine primitive functions and combine

them to keep creating new functions LISP (LISt Programming) & Scheme

20

Page 21: Hun Myoung Park,  Ph.D.

Declarative ProgrammingLogical reasoning to answer queriesUse deductive logic PrologReport generators: query languagesQuery languages: SQL (structured query

language)Application generators: Visual Basic,

FOCUS

21

Page 22: Hun Myoung Park,  Ph.D.

Declarative languagesDefine computation logic Logical reasoning to answer queries use

deductive logics Used in artificial intelligenceFourth generation languageProlog (PROgramming in LOGic)Query languages: SQL (structured query

language) and Report generators

22

Page 23: Hun Myoung Park,  Ph.D.

Language Translators

23

Page 24: Hun Myoung Park,  Ph.D.

Language Translators 1Computer can understand machine

languages only Language translators translate source

codes into the machine language.A source code file needs to be compiled

and linked to be an object file, executable file in a computer.

24

Page 25: Hun Myoung Park,  Ph.D.

Language Translators 2Lexer reads a source code (program)

character by character and assembles characters into reserved words (token)

Parser performs syntactic analysis and converts tokens to nodes on a syntax tree.

Code generator produces segments of machine code of each node.

Optimizer inspects machine codes and eliminates redundancies.

25

Page 26: Hun Myoung Park,  Ph.D.

Language Translators 3Assembler translates a assembly programsInterpreter (interactive)Compiler (non-interactive, batch)

26

Page 27: Hun Myoung Park,  Ph.D.

InterpreterInteractive way of communicating between

users and machines.Translates each line of the source programs

or translates instructions one by one and return the result promptly.

Java source Bytecode by Java compiler interpreted by JVM emulator

BASIC, LISP (LISt Processor) by MIT for artificial intelligence

27

Page 28: Hun Myoung Park,  Ph.D.

CompilerCompiler translates a whole source code

into an object code before executing it.Most high level languages (e.g., C and

Java) are translated by their compilers.Source code Object file Linking

libraries Executable fileA library is a collection of commonly used

modules that are combined into the executable file.

28

Page 29: Hun Myoung Park,  Ph.D.

Computer Software (Program)A collection of well organized instructions that

a computer executes to achieve specific tasks.

Algorithm or logic is a set of ordered steps to solve a problem.

Programming and coding (writing statements) is only a part of system development

29

Page 30: Hun Myoung Park,  Ph.D.

Software Development

30

Page 31: Hun Myoung Park,  Ph.D.

Software Development In the system development stage, when

customized software is needed Program development life cycle (PDLC)

1. Problem clarification2. Program design3. Program coding4. Program testing5. Program documentation and maintenance

31

Page 32: Hun Myoung Park,  Ph.D.
Page 33: Hun Myoung Park,  Ph.D.

Problem ClarificationObjectives and users (programming needs)Output to be produced by the systemsInput required to get the desired outputProcessing to transform input to output Feasibility (e.g., budget, man powers,

modification of old program?)

33

Page 34: Hun Myoung Park,  Ph.D.

Design the ProgramProgram logic in structured programming;

modularization (subprogram or subroutine)Design details Pseudo-code (narrative outline) FlowchartsControl structure (logic structure),

sequence, IF, case, iteration or loop (DO, FOR, WHILE)

Structured work-through to review

34

Page 35: Hun Myoung Park,  Ph.D.

FlowchartStart

End

Read x

sum = 0i = 1

If i <= x

sum = sum + i

i = i + 1

Print sum

No

Yes

35

Page 36: Hun Myoung Park,  Ph.D.

Components of a Program Variables (data type, constant, variable

declaration and initialization)Input and outputExpression (operators)Statements (assignment, compound

statement, control statements)Subprogram: variables, parameters, call by

value, call by reference

36

Page 37: Hun Myoung Park,  Ph.D.

Control StructuresSequence control Repetition (Loop)

If (score > 90) {

grade = “A”;

} elseif (score > 80) {

grade = “B”;

} else {

grade = “C”;

}

for (i=1; i<x; 1) {

sum = sum + i;

}

while (i<x) {

sum = sum +1;

i = i + 1;

}

37

Page 38: Hun Myoung Park,  Ph.D.

CodingA process of writing a program using a

proper programming languageThe result is a source code (program file in

the text format)Follow coding standardsDocumentation (comments or remarks)

makes it easy to understand and check mistakes.

38

Page 39: Hun Myoung Park,  Ph.D.

CompilingInterpret a source code (program file) and

convert into an object fileSource code Compiling Object file

(object module) Linking Executable file (load module)

Linking combines object files and built-in libraries (commonly used modules)

39

Page 40: Hun Myoung Park,  Ph.D.

DebuggingA process of checking and correcting errors

(bugs) in a programErrorsSyntax errorLogic error in the logic of a programRun-time error occurs while a program is

running

40

Page 41: Hun Myoung Park,  Ph.D.

Software TestingTo check if the software meets the

requirements and works as expectedUnit testing (component testing),

integration testing, system testing, and acceptance testing

Running programs with test data Alpha test at developers’ siteBeta test or pre-release test (outside test)

41

Page 42: Hun Myoung Park,  Ph.D.

Implementation and MaintenanceImplementation to run the program on the

information systems Installation and compatibility testsMaintenance (updating)

42

Page 43: Hun Myoung Park,  Ph.D.

DocumentationDescription of the program developmentData dictionaryDocumentation for usersDocumentation for operatorsDocumentation for programmersDocumentation in source programs

43

Page 44: Hun Myoung Park,  Ph.D.

ConclusionSoftware development is not the same as

coding (programming).Importance of software test .Documentation in all stages.

44