You are on page 1of 15

Computer and Information Technology for (HKCEE) Module A2

3.1Imperative Programming
3.2 Object-Oriented Programming
3.3 Logic Programming
Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.1 Imperative Programming


Imperative language
concerned with giving instructions to a computer
e.g. C, Pascal, Basic, FORTRAN, ADA, COBOL
Advantage:
directly support several loop constructs

© Longman Hong Kong Education Page2


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.1 Imperative Programming


Disadvantages:
assignment statement causes severe problems
limited set of control structures for expressing
iterations
limited set of built-in data structure
complex semantics

© Longman Hong Kong Education Page3


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming


Object-oriented programming (OOP)
emphasize the definition of classes of objects
e.g. Java, C++, Smalltalk
Object
instance of a class
created by the program as needed during
program execution
an encapsulation of state and behaviour

© Longman Hong Kong Education Page4


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming


Class
has attributes and behaviours
public fields
accessible from outside the class
private fields
hidden to the users of the class

© Longman Hong Kong Education Page5


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming

a class visualisation
© Longman Hong Kong Education Page6
Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming

a class notation
© Longman Hong Kong Education Page7
Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming


Encapsulation (information hiding)
integration of attributes and behaviours in an
object so that the object is self-contained
Inheritance
A class can
inherit the features of another class
add its own modifications
speed up program development
allow program consistency
aid in the reuse of codes

© Longman Hong Kong Education Page8


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming

Superclass Parent Class

Subclass1 Subclass2 Subclass3 Child Class

© Longman Hong Kong Education Page9


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming

© Longman Hong Kong Education Page10


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.2 Object-Oriented Programming


Polymorphism
different classes of objects understand and
respond to the message of the same name, but in
different ways
Two types of polymorphism
function overriding
function overloading

© Longman Hong Kong Education Page11


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.3 Logic Programming


Logic programming
solving Artificial Intelligence program
e.g. vision, robotics, expert systems
emphasize the declarative description of a
problem

© Longman Hong Kong Education Page12


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.3 Logic Programming


Expert System (ES)
knowledge base
encapsulate knowledge of a human expert
inference engine
manipulate the knowledge in the knowledge base
human-computer interface
communicate with a human

© Longman Hong Kong Education Page13


Computer and Information
Technology for (HKCEE)
Module A2: Part A

3.3 Logic Programming

Structure of an Expert System


© Longman Hong Kong Education Page14
Computer and Information Technology for (HKCEE) Module A2

END

You might also like