OBJECT ORIENTED PARADIGM: Problem Solving in OO Paradigm

Object-oriented problem solving approach is very similar to the way a human solves daily problems. It consists of identifying objects and how to use these objects in the correct sequence to solve the problem. In other words, object-oriented problem solving can consist of designing objects whose behavior solves a specific problem. A message to an object causes it to perform its operations and solve its part of the problem.

The object-oriented problem solving approach, in general, can be divided into four steps. They are:

(1) Identify the problem,

(2) Identify the objects needed for the solution,

(3) Identify messages to be sent to the objects, and

(4) Create a sequence of messages to the objects that solve the problem.

Following is an example of solution to a simple problem using the four steps.

Example 1: Object-oriented Problem Solving Approach

Step 1: Problem Identification - Compute the sum of two numbers and print out the result.

Step 2: Object Identification - Identify objects needed to solve the problem.

Num1 - first number (object).   Num2 - second number (object).   Sum - result of the addition of the two numbers (object).

Step 3: Message Identification - Messages needed to send to objects.

+ aNum - This is the message sent to the receiver             object with an parameter aNum.  The result of             this message is the value (a numeric object) of the            total sum of the receiver object and aNum.   print - a message that displays the value of the receiver             object.

Step 4: Object-message sequences - Following is the object-message sequence to solve the problem.

(Num1 + Num2)print

The message + with a parameter Num2 (an object), is sent to the object Num1. The result of this is an object (Num1 + Num2), which is sent the message print. The parentheses are included to avoid any ambiguity as to which message should be activated first.

Note: The sequence of Smalltalk evaluation is from left to right unless is specified by parentheses ( ). For example:

2 + 3 * 4               is 20  while        2 +(3 * 4)              is 14
OBJECT ORIENTED PARADIGM: Problem Solving in OO Paradigm OBJECT ORIENTED PARADIGM: Problem Solving in OO Paradigm Reviewed by Unknown on 11:15:00 Rating: 5

No comments:

Powered by Blogger.