Object-Oriented Concepts in AB Suite

Содержание

Слайд 2

Objective By the end of this module, you’ll be able to—

Objective

By the end of this module, you’ll be able to—
Define object-oriented

concepts
Implement object-oriented concepts in AB Suite application development
Слайд 3

Module Topics Object-Oriented Concepts—An Overview History of object-orientation Objects Classes Instances

Module Topics

Object-Oriented Concepts—An Overview
History of object-orientation
Objects
Classes
Instances
Methods
Principles of Object-Orientation
Encapsulation
Composition
Generalization
Inheritance
Polymorphism
AB

Suite Framework
Слайд 4

Object-Oriented Concepts—An Overview

Object-Oriented Concepts—An Overview

Слайд 5

History of Object-Orientation Object-Orientation (OO): Developed at Xerox’s Palo Alto Research

History of Object-Orientation

Object-Orientation (OO):
Developed at Xerox’s Palo Alto Research Center in

the 1970s
Developed to make software development simpler
Developed to simplify applications and improve maintainability
Слайд 6

Some Key Object Oriented Principles

Some Key Object Oriented Principles

Слайд 7

Objects An object is the UML way of representing an entity

Objects

An object is the UML way of representing an entity
Real, like

a car
Conceptual, like a bank transaction
An object is a software bundle of related state and behavior
State is the current condition an object is in and it might change
Behavior is how an object responds to operations
Слайд 8

AB Suite Objects

AB Suite Objects

Слайд 9

Classes A class acts as a blueprint of an object. A

Classes

A class acts as a blueprint of an object.
A class describes

a group of objects that are the same.
An instance is an individual object of a class at runtime.
Слайд 10

Class Types Primitive class — Is an abstract description of a

Class Types

Primitive class — Is an abstract description of a simple

item of data, such as a customer name or age. For example, strings, numbers, and so on.
Complex class — Is a composition of other classes.

Belongs to the Customer class, a Complex class

Name: Jenny (String)
Gender: Female (String)
Age: 42 (Number)

Primitive classes

Слайд 11

Instances Instances defined by AB Suite objects are: Attribute - Member

Instances

Instances defined by AB Suite objects are:
Attribute - Member of an

object that holds the state of a class
Variable - Temporary storage for information
Parameter - Special variable used to pass data into and/or out of a method call
You can define an instance of a class by setting its Multiplicity property to > 0.
For example, to create an instance of class Customer, set the Multiplicity property of the Customer element to 1.
Слайд 12

Current Instance Current Instance is the particular instance of an object

Current Instance

Current Instance is the particular instance of an object being

invoked.
Current instance qualifiers in System Modeler:
This—Refers to the current instance in which the method is running, this can a framework instance or a user-defined instance
Super—Refers to the superclass of the current instance
Owner—Refers to the owner of the current instance
Component—Refers to the current segment
Current instance qualifiers help to reduce programming logic.
Слайд 13

Example Consider that the CUST ispec contains a user defined method

Example

Consider that the CUST ispec contains a user defined method MyMethod().
MyMethod()

contains logic that refers fields from the CUST table.
Consider an instance of CUST ispec, MyCUST in the SALE event.
When MyMethod() is invoked from MyCUST, the logic is:

Referring the instance using the current instance qualifier

Referring the instance by name

Слайд 14

Methods Methods contain logic that defines the behavior of a class.

Methods

Methods contain logic that defines the behavior of a class.
Provide an

interface to the class using:
Parameters
Return variables
AB Suite methods:

Framework Methods

User Defined Method

Слайд 15

Parameters and Return Variables Method parameters and return variables return during

Parameters and Return Variables

Method parameters and return variables return during a

method call.
Values passed back to the calling method can prompt the calling method to take a particular action.
You can set the return value of a method using the Return command

Return CUSTOMER

Слайд 16

Method Logic Method Logic defines the behavior of a class. It

Method Logic

Method Logic defines the behavior of a class.
It protects the

calling method from internal changes.
You can write method logic using current instances by:
Explicitly specifying the current instance qualifier
Implicitly specifying the attribute name of the instance
Слайд 17

Principles of Object Orientation

Principles of Object Orientation

Слайд 18

Encapsulation Encapsulation is also known as information hiding. It works on

Encapsulation

Encapsulation is also known as information hiding.
It works on the concept

of visibility and ownership of members
It is a means of managing access to an object’s members
Private ( ), visible only within the class
Protected ( ), visible within its class and any class inheriting from it
Public ( ), visible outside the class
It reduces maintenance cost by minimizing scope of change.
Слайд 19

Example Business Rule: A Product’s Stock balance (STOCKBAL) should never be

Example

Business Rule: A Product’s Stock balance (STOCKBAL) should never be less

than zero

Stock balance = STOCKBAL – Quantity
(STOCKBAL) 1000 – 1500
= -500

STOCKBAL updated, but STOCKBAL is < 0, which is against business rule

Sale Event

Without Encapsulation

With Encapsulation

Stock balance = STOCKBAL – Quantity
(STOCKBAL)

STOCKBAL is not updated, as STOCKBAL is < 0

Sale Event

UpdateStockbal()

Returns False

STOCKBAL is Public

STOCKBAL is Private

Слайд 20

Encapsulation—Best Practices Convert a single code sequence into smaller pieces of

Encapsulation—Best Practices

Convert a single code sequence into smaller pieces of code.

This avoids redundancy and helps in reuse of code.
Set the class members that represent the object as Private.
Set the class members that service the external needs of other classes (typically methods) as Public.
Hide implementation by setting the members protected or private.
Expose only interfaces by use of public methods.
Use parameters to pass information from one class to another and into or out of methods.
Do not use global variables for encapsulation.
Set variables that are used only within a method as local variables.
Слайд 21

Composition Composition is a way of combining existing simple objects to

Composition

Composition is a way of combining existing simple objects to build

new and more complex objects.
For example, a Customer object is a composition of Name, Address, Credit limit, and so on
It models a relationship between two objects where one object owns, or is made up of, other objects.
It uses attributes that can have special characteristic such as:
Persistence
Presentation
Слайд 22

Example 1 CASH and SALE events contain an instance of the

Example 1

CASH and SALE events contain an instance of the CUST

ispec

Customer Number field appears as a drop-down list in the CASH event presentation

Customer Number field appears as a drop-down list in the SALE event presentation

CUST ispec presentation

Слайд 23

Example 2 In System Modeler, a composite class: Can be used

Example 2

In System Modeler, a composite class:
Can be used anywhere in

the model
Can be used more than once in an class

SalesOrder
orderNum
custID
billAddress
delivAddress

Address
streetNum
streetName
streetType
town

billAddress

delivAddress

SalesOrder object owns two instances of Address class

Слайд 24

Generalization Generalization is the process of factoring out common behavior and

Generalization

Generalization is the process of factoring out common behavior and structuring

them into another class.
An inheritance hierarchy is formed between the objects
The generalized object is referred to as the superclass
The specializing object is referred to as the subclass
It promotes reuse, reducing complexity among similar objects.
Слайд 25

Inheritance Inheritance is a relationship between two classes. In this mechanism,

Inheritance

Inheritance is a relationship between two classes.
In this mechanism, a class

(subclass) inherits attributes, methods, and relationship of another class (superclass).
It allows the reuse of members of a class, reducing the complexity amongst similar objects.
In System Modeler, the Inherits property enables a “subclass” to acquire all the behavior of its “superclass”.
Слайд 26

Example Superclass More Generalized Subclass More Specialized

Example

Superclass
More
Generalized
Subclass
More
Specialized

Слайд 27

Customizing Inherited Behavior Customizing Inherited Behavior is commonly known as overriding

Customizing Inherited Behavior

Customizing Inherited Behavior is commonly known as overriding members.
In

this process subclass members with the same name as the superclass members are overridden.
You cannot override a member if its IsFinal property is set to True.
Слайд 28

IsInner Relationship Inner class is defined as a class within another

IsInner Relationship

Inner class is defined as a class within another class.
Instances

of the inner class have access to the attributes and methods of its owner.
In System Modeler, the inner class behavior is implemented using the IsInnerClass property.
IsInner is a concept that allows classes to interact through the structural ownership relationship.
IsInner relationship is a simplified interface to private members and the cost of weakened encapsulation.
Слайд 29

Polymorphism Polymorphism is one of the useful applications of Inheritances. It

Polymorphism

Polymorphism is one of the useful applications of Inheritances.
It provides the

ability to refer to the instance of a subclass through a common interface defined in the superclass.
In System Modeler, Inherits property is used to associate the objects that are polymorphic.
Overriding the superclass method enhances the capabilities of polymorphism.
Слайд 30

AB Suite Framework

AB Suite Framework

Слайд 31

AB Suite Framework Objects AB Suite Framework objects consist of built-in:

AB Suite Framework Objects

AB Suite Framework objects consist of built-in:
Classes
Instances
Methods
Framework objects

are inherited implicitly in every user defined class.
Properties of a class control the level of inheritance.
Members inherited from the framework object depend on the primitive type and stereotype.
Слайд 32

Stereotypes Stereotype indicates how an object behaves in the AB Suite

Stereotypes

Stereotype indicates how an object behaves in the AB Suite framework

processing cycle.
For example, ispecs and segments are both classes, but they have different stereotypes.
A stereotyped class or object inherits a set of built-in attributes and methods.
For example, the built-in attributes and methods inherited by a segment class include:
An attribute called GLB.
A built-in method called Startup().

Stereotypes in AB Suite

Segment
Ispec
Report
Frame
Group
Insertable
Event
CopyIspec
CopyEvent
SQL Script
Presentation Interface
Serializable Interface

Слайд 33

Overriding Framework Methods Stereotyped classes inherit a set of framework methods

Overriding Framework Methods

Stereotyped classes inherit a set of framework methods that

do not contain any logic.
To add logic to framework methods invoked during the runtime cycle, you need to override the methods.