Anda di halaman 1dari 5

CIT2574N Object-Oriented Development

Tutorial 1 Answer
Submission date: 07 Jan 2015

Question 1
Class diagram
Question 2
Question 3
(i). Classes and objects
A class in the context of object-oriented programming is the blueprint for creation of objects.
Classes describe the properties and methods that form individual objects. As it is a blueprint, a
class can be used to create as many objects as necessary. Objects are created by providing data for
each properties and method. Objects on the other hand describes real world entities. If 2 objects
have the same data for all its properties and methods, they are describing the same object.

(ii). Properties and methods


Properties, also known as attributes, are used to describe the characteristics of a real world object.
For example, a human object has the following properties: name, date of birth, gender, height and
weight.

Each object also have specific behaviors and actions, known in object oriented programming as
methods or functions. Each object is able to perform specific function based on request from
another object. One example is the Math class in Java. It contains the following functions: pow
(for power) and sqrt (for square root). By calling these functions, they are capable of performing a
function.

(iii). Inheritance
Inheritance is the object oriented concept of a sub class inheriting ALL properties and methods of
their superclasses. Using this concept code reusability can be realized when the codes in a
superclass is inherited and reused in the subclasses.

(iv). Encapsulation and message passing


Encapsulation is the object oriented concept of linking properties and methods to a specific
object. In such the object is a capsule of those properties and methods. Encapsulation also utilize
the concept of information hiding, where the data of an object is hidden from another object. For
example, when object A wants object B to call a function, it does not need to know how object B
achieves the result of the function. Object A just need to perform message passing by calling
Object Bs function and providing the appropriate parameters. Object B will perform the function
and return the result to Object A.

(v). Polymorphism
Polymorphism means many forms. This is an object oriented concept where a function, object
or symbol can take on many forms and perform differently in different situations. One example is
the symbol + in VB. When you put string + string, it performs the concatenation operation. But
when you put integer + integer, VB will perform addition to the 2 values. In such we see that the
symbol + performs differently with different data types hence the concept of polymorphism.
Question 4
In object oriented development, the entire structure of the software is developed in advance with the
intention to reuse any classes or data that was developed earlier. This saves programmer from
recoding any functions that was defined in earlier classes. Many objects can also be derived from a
single class saving the time to create many classes in a single software.

This is a negative point in smaller programs because of the overhead of creating classes and objects
that are only used once. But when we put this in larger softwares, where the reuse of objects are more
prevalent, then the advantage of object-oriented becomes more obvious when the codes and objects
are reused in many occasions throughout the development.

Question 5
Structured programming (or functional programming) is still being used because some softwares do
not require the creation of objects to solve its problems. For example, in an accounting software, it
deals entirely in numeric and functions to solve numerical problems. So instead of wasting time by
first creating the objects, then next inserting the data for each of the objects properties, functional
programming just focuses on creating the function to solve the numeric problem.

Some functions also do not require the reuse of data, but rather just focus on the top down approach of
data processing. So when a user enter a value, it is put through some function and finally a result is
returned to you. Data from previous objects or entry is not required in this instance, so no reusability
is involved in this instance.

Anda mungkin juga menyukai