Object-Oriented Concepts in AB Suite
Objective
Module Topics
Object-Oriented Concepts—An Overview
History of Object-Orientation
Some Key Object Oriented Principles
Objects
AB Suite Objects
Classes
Class Types
Instances
Current Instance
Example
Methods
Parameters and Return Variables
Method Logic
Principles of Object Orientation
Encapsulation
Example
Encapsulation—Best Practices
Composition
Example 1
Example 2
Generalization
Inheritance
Example
Customizing Inherited Behavior
IsInner Relationship
Polymorphism
AB Suite Framework
AB Suite Framework Objects
Stereotypes
Overriding Framework Methods
Summary
886.05K

Object-Oriented Concepts in AB Suite

1. Object-Oriented Concepts in AB Suite

2. 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
© 2017 Unisys Corporation. All rights reserved.
2

3. 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
© 2017 Unisys Corporation. All rights reserved.
3

4. Object-Oriented Concepts—An Overview

© 2017 Unisys Corporation. All rights reserved.

5. 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
© 2017 Unisys Corporation. All rights reserved.
5

6. Some Key Object Oriented Principles

© 2017 Unisys Corporation. All rights reserved.
6

7. 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
© 2017 Unisys Corporation. All rights reserved.
7

8. AB Suite Objects

© 2017 Unisys Corporation. All rights reserved.
8

9. 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.
Customer class
Instance of Customer class
John
Jane
Jenny
© 2017 Unisys Corporation. All rights reserved.
9

10. 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)
Primitive classes
Age: 42 (Number)
© 2017 Unisys Corporation. All rights reserved.
10

11. 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.
© 2017 Unisys Corporation. All rights reserved.
11

12. 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.
© 2017 Unisys Corporation. All rights reserved.
12

13. Example

• Consider that the CUST ispec contains a user defined method
MyMethod().
• MyMethod() contains logic that refers fields from the CUST table.
Referring the instance using the current
instance qualifier
• Consider an instance of CUST ispec, MyCUST in the SALE event.
• When MyMethod() is invoked from MyCUST, the logic is:
Referring the instance by name
© 2017 Unisys Corporation. All rights reserved.
13

14. 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
© 2017 Unisys Corporation. All rights reserved.
14

15. 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
© 2017 Unisys Corporation. All rights reserved.
15

16. 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
© 2017 Unisys Corporation. All rights reserved.
16

17. Principles of Object Orientation

© 2017 Unisys Corporation. All rights reserved.

18. 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.
© 2017 Unisys Corporation. All rights reserved.
18

19. Example

Without Encapsulation
Sale Event
Business Rule: A Product’s Stock
balance (STOCKBAL) should never
be less than zero
Stock balance = STOCKBAL – Quantity
(STOCKBAL)
1000 – 1500
= -500
STOCKBAL
is Public
STOCKBAL updated, but STOCKBAL
is < 0, which is against business rule
With Encapsulation
Sale Event
Stock balance = STOCKBAL – Quantity
(STOCKBAL)
UpdateStockbal()
STOCKBAL is not updated, as
STOCKBAL is < 0
STOCKBAL
is Private
Returns False
© 2017 Unisys Corporation. All rights reserved.
19

20. 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.
© 2017 Unisys Corporation. All rights reserved.
20

21. 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
© 2017 Unisys Corporation. All rights reserved.
21

22. 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
CUST ispec
presentation
Customer Number field appears as a
drop-down list in the SALE event
presentation
© 2017 Unisys Corporation. All rights reserved.
22

23. Example 2

• In System Modeler, a composite class:
– Can be used anywhere in the model
– Can be used more than once in an <Ispec> class
Address
streetNum
streetName
streetType
town
SalesOrder
delivAddress
billAddress
orderNum
custID
billAddress
delivAddress
SalesOrder object owns two
instances of Address class
© 2017 Unisys Corporation. All rights reserved.
23

24. 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.
© 2017 Unisys Corporation. All rights reserved.
24

25. 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”.
© 2017 Unisys Corporation. All rights reserved.
25

26. Example

Superclass
More
Generalized
Subclass
More
Specialized
© 2017 Unisys Corporation. All rights reserved.
26

27. 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.
© 2017 Unisys Corporation. All rights reserved.
27

28. 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.
© 2017 Unisys Corporation. All rights reserved.
28

29. 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.
© 2017 Unisys Corporation. All rights reserved.
29

30. AB Suite Framework

© 2017 Unisys Corporation. All rights reserved.

31. 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.
© 2017 Unisys Corporation. All rights reserved.
31

32. 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().
Segment
Ispec
Report
Frame
Group
Insertable
Event
CopyIspec
CopyEvent
SQL Script
Presentation Interface
Serializable Interface
Stereotypes in AB Suite
© 2017 Unisys Corporation. All rights reserved.
32

33. 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.
Framework instance
automatically created
Automatic
Edit
Construct()
Construct() method
invoked on Framework
instance
Transmit form
Prepare()
Prepare() method
invoked on
Framework
instance
Recall/
Refresh
Client
Framework
instance
destroyed
Automatic Update
Main()
CUST ispec recalled
Main() method invoked on
Framework instance
© 2017 Unisys Corporation. All rights reserved.
33

34. Summary

In this module, you have learned about:
• The object-oriented concepts
• Implementing object-oriented concepts in AB Suite
application development
© 2017 Unisys Corporation. All rights reserved.
34
English     Русский Правила