Title: Object-Oriented Programming with NaturalX
1Object-Oriented Programming with NaturalX
m i n d c r o s s
- Presented by Rosanne Verteramo
- Sr. Training Consultant
- MindCross Training Consulting
1
MindCross Training Consulting -
www.mindcross.com
2Overview
- In such a rapidly changing field as OOP, it is
essential to not only keep up but to lead the
way. This presentation will cover the basic
concepts of object-oriented programming and the
elements of object oriented design, including
objects, classes, and methods. It will introduce
NaturalX and show you how to do Object-oriented
programming (OOP) using NaturalX and the Natural
development environment on NT.
3Topics
- An Introduction to Object-Oriented Programming
(OOP) - The basic principles
- Object-oriented design
- Classes and methods
- OO Programming with NaturalX
- What is NaturalX?
- Component-oriented development with NaturalX
4Introduction to Object-Oriented Programming
m i n d c r o s s
4
MindCross Training Consulting -
www.mindcross.com
5Object-Oriented Programming
- Why Object-oriented Programming (OOP)?
- It will quickly and easily lead to increased
productivity and reliability due to reuse - Reusable components
- Easy transition from existing languages
- Similar to other programming techniques
- Enables Enterprise Application Integraiton (EAI)
6Object-Oriented Programming
- Understanding the concepts.
- A new way of thinking
- A programming technique
- Oriented around objects and data
- Object-oriented languages do not force
object-oriented programming
7The Basic Principles of OOP
- An analogy sending wine and cheese to a friend
in another state
Friend
Wine and cheese
Me
8The Basic Principles of OOP
- An analogy sending wine and cheese to a friend
in another state
Friend
Wine and cheese
Me
method
message
agent
9Elements of OOP - Objects
- Everything is an object
- A software bundle of related variables and
methods a code block - Used to model real world objects
- Two characteristics
- State - Maintained within variables / data
- Variables are known as properties
- Behavior - Implemented within methods / functions
- An object is an instance
10Elements of OOP - Objects
- Everything is an object (continued)
- Packaging properties/variables within the method
of an object is known as encapsulation - Exposing properties makes them publicly available
to the user of the object
Object
11Elements of OOP - Objects
- Everything is an object (continued)
- Encapsulating variables/properties and methods
within an object provides two primary benefits - Modularity
- The source code for an object is written and
maintained independently of other objects - Promotes reusability
- Information hiding
- Modifications to the information will not affect
other users of the object
12Elements of OOP - Messages
- Communication between objects is accomplished by
passing messages - Actions are produced in response to requests,
called messages - An object may accept a message, and in return
will perform an action and return a value - Additional information is passed to a method
within an object as arguments or parameters
13Information Hiding Encapsulation
- As a user of a service being provided by an
object, you only need to know the name of the
messages that the object will accept - Its not necessary to know how the actions
performed in response to the request will be
carried out - The object is responsible for carrying it out the
request
14Elements of OOP - Receivers
- Messages differ from traditional function calls
in two very important respects - In a message there is a designated receiver that
accepts the message - The interpretation of the message may be
different, depending upon the receiver
15Elements off OOP - Classes
- A class is a blueprint that defines the
properties and methods for that class - Every object is an instance of a class
- The variables and methods will be common to all
objects - Behavior is associated with classes, not with
individual instances - All objects that are instances of a class use the
same method in response to similar messages
16Elements off OOP - Classes
- Every objects state is independent of every
other object related to that class - For every instance of a class the system
allocates enough memory for the object and all
its data
17Classes and Instances
- An object is an instance of a class
- Class Square
- Instance Maggies_ green_ square
18Classes and Instances
- Class hierarchies
- Classes can be created from other classes
- Class Bike
- Class Mountain_Bike
- Mountain_Bike is considered a sub-class of Bike
- Bike is considered the superclass
19Elements of OO - Inheritance
- Classes are organized into a singly-rooted tree
structure, inheritance hierarchy - Relates to both data and/or behavior
- Everything from a higher level class is
automatically applicable to lower levels in the
hierarchy
20Classes and Instances
- Class hierarchies - inheritance hierarchy
Class dot
Class line
Class rectangle
Maggies green square
21Elements of OOP - Encapsulation
- The proper use of methods
- One must provide the intended user of a module
with all the information needed to use the module
correctly, and with nothing more
22The Basic Principles of OOP
- OOP is not simply features added to a programming
language - - it is a new way of thinking - The OOP views a program as a community of agents,
termed objects - Each object is responsible for a specific task
- An object is an instance of a class
23The Basic Principles of OOP
- Communication is accomplished by passing messages
- An object is an encapsulation of state (data
values) and behavior (operations) - Every object has its own memory
- The behavior of objects is dictated by the object
class
24The Basic Principles of OOP
- Classes are organized into a tree structure
called the inheritance hierarchy - An object will exhibit its behavior by invoking a
method (similar to executing a procedure) in
response to a message - The OOP view of computation is that an
application is a conglomeration of interacting
computing objects
25OO Programming with NaturalX
m i n d c r o s s
25
MindCross Training Consulting -
www.mindcross.com
26What is NaturalX
- Software AGs technology for component-oriented
development using Natural
Natural
Mainframe
Unix
Windows
Open VMS
AS/400
Database
27What is NaturalX
- Component-oriented development
Component
Component
Component
NaturalX
Visual Basic
Visual C
28What is NaturalX
- Component-oriented development
EntireX DCOM
EntireX DCOM
EntireX DCOM
29Natural Development Environment
- Natural Studios
- User-friendly GUI for development of procedural,
event-driven, and component-based Natural
applications - Includes a Class Builder for developing NaturalX
classes/components - Automatically generates code and statements
necessary for the NaturalX class module
30Natural Development Environment
31NaturalX Statements
- Define Class . . .
- Define Interface . . .
- Property . . .
- Method Is. . .
-
32NaturalX Commands
33Steps to Creating NaturalX Classes
- Using the Class Builder
- Create a new Class with name
- Create a new Interface with name
- Create methods with appropriate names
- Implement methods as subprograms
- Create properties with appropriate names
- Create Object data area
- Stow class with module name
- Register
34Steps to Creating NaturalX Classes
35(No Transcript)
36(No Transcript)
37(No Transcript)
38(No Transcript)
39(No Transcript)
40(No Transcript)
41(No Transcript)
42(No Transcript)
43(No Transcript)
44(No Transcript)
45(No Transcript)
46Components of a NaturalX Class
47Components of a NaturalX Class
Class Name and ClassID (GUID)
Interface Name and Interface ID (IID)
Method Name
PDA
Properties
48(No Transcript)
49NaturalX Structure for Classes
- Define Class . . .
- Define Interface . . .
- Property . . .
- End-Property
- Method . . .
- End-Method
- End-Interface
- End-Class
50(No Transcript)
51NaturalX Syntax for Class objects
- Define Class xxxxxxxx
- Object using LDA
- Local using GUID_LDA
- ID GUID_Variable (from GUID_LDA)
- Interface InterfaceName
- ID Interface_ID (from GUID_LDA)
- Property PropertyVariable
- IS VariableName (link variable to property)
- End-Property
- Method MethodName
- IS SubprogramName
- Parameter Using PDA
- End-Method
- End-Interface
- End-Class
- End
52NaturalX Statements
- Create Object . . .
- Send Method . . .
-
53Calling NaturalX Components
- Declaration
- Define data local
- 1 ObjectName HANDLE of OBJECT
- End-Define
- Instantiation
- Create Object ObjectName of CLASS ClassName
- Giving NaturalError
- Invoking Methods
- SEND Method MethodName to Object ObjectName
- WITH Parameters
54Calling NaturalX Components
- SEND syntax
- SEND Method MethodName to Object ObjectName
- WITH Parameters
- RETURN ReturnValueField
- GIVING NaturalError
- Parameter options
- By Value Input parameters of the method
- By Reference Input and output parameters
- By Value Result Return value for the method
55Writing the Client Program
1 MyEmpl Handle of Object Create Object MyEmpl
Of Class 'DEMOCLASS Send Method 'GET_EMPL' To
Object MyEmpl WITH PID result
56Registering Classes with NaturalX
- Manual Register/Deregister
- Register ClassName LibraryName
- DeRegister ClassName LibraryName
- Automatic Registration using Natparms
- AUTOREGISTER
-
57(No Transcript)
58Distributing Components
- DCOMCNFG
- Microsoft utility which specifies information
needed for DCOM - Location of COM object
- Permissions
- Runtime specifications
- On Server - define launch and access permissions
- On Client - define location of COM object
59Distributing Components
Component on NT Server
Define location of component on client machine
Define security (launch and access privileges)
60(No Transcript)
61(No Transcript)
62(No Transcript)
63(No Transcript)
64(No Transcript)
65(No Transcript)
66(No Transcript)
67Writing the Client Program
1 MyObject Handle of Object
Create Object MyObject Of Class
'EAS.EMPLOYEE'
Height MyObject.Height
MyObject.Height Height
68The Component Browser
- Means for Browsing all Components
- GUIDs
- Interfaces
- Properties
- Methods
- Type library is created for every NaturalX class
as part of the Register process
69Summary
- OOP is a new way of thinking
- OOP involves the use of classes, objects,
methods, and properties - A class is a blueprint for a software module
- An object is an instance of a class
- A method represents the code within the class for
behavior
70Summary
- Properties represent data
- Encapsulation allows reuse and promotes
information and function hiding - Inheritance hierarchy is the ability to create
classes from other higher level classes - NaturalX is a tool allowing you to create
components using the Natural programming language
71Summary
- NaturalX uses classes, interfaces, and methods,
and properties - An interface is a group of methods
- A method is processed in NaturalX as a subprogram
- There is a one to one ratio between Natural
methods and subprograms - Properties are needed within NaturalX to make
class data publicly available
72Summary
- Properties store their data within an Object data
area - There is one object data area per class in
NaturalX - GUIDs can be created automatically in NaturalX
when stowing the class
73The End
Thank you, from MindCross Training
Consulting Training worldwide