Sie sind auf Seite 1von 51

Global network of innovation

Principles

Global network of innovation Principles Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage
Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles

1

Global network of innovation

Principles : Overview-1

Global network of innovation Principles : Overview-1 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,
Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles

2

Global network of innovation

Object-1

Example: airplane Attributes Attributes Name: LH Berlin Plane ID: ID0057231 Methods Weight: 30,000 kg Length: 70
Example: airplane
Attributes
Attributes
Name: LH Berlin
Plane ID: ID0057231
Methods
Weight: 30,000 kg
Length: 70 m
land
fly
Methods
Events
Events
landed
Private access
Public access
• Encapsulation
Interface
• As a rule, attributes
As
a rule,methods, events
Global network of innovation Object-1 Example: airplane Attributes Attributes Name: LH Berlin Plane ID: ID0057231 Methods

3

Global network of innovation

Object-2

What characterizes an object?

Identity Status (quantity of attributes) Behavior (quantity of methods and events)

What synonyms are used for objects?

Object Instance

Global network of innovation Object-2 What characterizes an object?  Identity  Status (quantity of attributes)

4

Global network of innovation

Example of Objects

Eberwein Plane ticket 1 Mr . Departure: Berlin: 06:10 p.m. Name: Name: Mr Gore Departure: Mumbai:
Eberwein
Plane ticket 1
Mr .
Departure: Berlin: 06:10 p.m.
Name:
Name:
Mr Gore
Departure: Mumbai: 06:10 p.m.
Müllerschön
2
Plane ticket 2
Mr .
Name: Name: Mr Dongare
Departure: Pune : 9:15 p.m.
Global network of innovation Example of Objects Eberwein Plane ticket 1 Mr . Departure: Berlin: 06:10

5

Global network of innovation

Classification Plane Plane ticket Müllerschön Müllerschön Plane ticket 2 Plane ticket 2 Mr . Mr .
Classification
Plane
Plane ticket
Müllerschön
Müllerschön
Plane ticket 2
Plane ticket 2
Mr .
Mr .
Departure: Munich: 11:25 a.m.
Departure: Munich: 11:25 a.m.
Name:
Name:
Eberwein
Eberwein
Plane ticket 1
Plane ticket 1
Mr .
Mr .
Departure: Berlin: 06:10 p.m.
Departure: Berlin: 06:10 p.m.
Name:
Name:
Global network of innovation Classification Plane Plane ticket Müllerschön Müllerschön Plane ticket 2 Plane ticket 2

6

Global network of innovation

Principles : Overview-2

Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles
Global network of innovation Principles : Overview-2 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,

7

Global network of innovation

Class : Blueprint of Object

CLASS < classname > DEFINITION. ENDCLASS.

CLASS < classname > IMPLEMENTATION. ENDCLASS.

Definition part

The class components (for

example, attributes and methods)

are defined in this part.

Implementation part

This part only contains the method

implementations.

Global network of innovation Class : Blueprint of Object CLASS < classname > DEFINITION. ENDCLASS. CLASS

8

Global network of innovation

Important Components in a Class

Attributes

Data Determine the state of the object

Methods

Executable coding Determine the behavior of the object

Global network of innovation Important Components in a Class Attributes  Data  Determine the state

9

Global network of innovation

Principles : Overview-3

Global network of innovation Principles : Overview-3 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,
Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles

10

Global network of innovation

Attributes

Attribute types can have any kind of data type:

Elementary types:

C, I, P, STRING TYPE REF TO (References to objects/interfaces) Define your own types

lcl_airplane

 

name:

LH

weight: 30 000

tank:

tank:
tank:
lcl_tank
lcl_tank
Global network of innovation Attributes Attribute types can have any kind of data type:  Elementary

11

Global network of innovation

Attributes : Syntax

CLASS < classname > DEFINITION.

...

TYPES: < normale Typdefinition >.

CONSTANTS: constant TYPE <type> VALUE <value>.

DATA: variable1 TYPE <type>,

variable7 TYPE REF TO <interface>.

CLASS-DATA: ...

ENDCLASS.

Global network of innovation Attributes : Syntax CLASS < classname > DEFINITION. ... TYPES: < normale

12

Global network of innovation

Attributes : Visibility

Public attributes

Can be viewed and changed by all users and in all methods

Direct access

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION.

PRIVATE SECTION.

DATA: weight TYPE saplane -weight.

ENDCLASS.

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION.

...

PRIVATE SECTION.

TYPE saplane -weight,

name TYPE string.

ENDCLASS.

Private attributes

Can only be viewed and changed from within the class

better
better

No direct access from outside the class

Global network of innovation Attributes : Visibility Public attributes  Can be viewed and changed by

13

Global network of innovation

Attributes : Instance and Static-1

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION.

PRIVATE SECTION. DATA : weight TYPE saplane -weight,

name

TYPE string.

CLASS-DATA : count TYPE I.

ENDCLASS.

Instance attributes

One per instance Statement: DATA

Static attributes

Only one per class

Statement: CLASS-DATA Also known as class attributes

Global network of innovation Attributes : Instance and Static-1 CLASS lcl _airplane DEFINITION. PUBLIC SECTION. PRIVATE

14

Global network of innovation

Global network of innovation Attributes : Instance and Static-2 count: name: LH Berlin weight: 30,000 kg
Attributes : Instance and Static-2 count: name: LH Berlin weight: 30,000 kg name: AA Boston weight:
Attributes : Instance and Static-2
count:
name:
LH Berlin
weight: 30,000 kg
name: AA Boston
weight: 45,000 kg
Main
Static attributes for class LCL_AIRPLANE

15

Global network of innovation

Principles : Overview-4

Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles
Global network of innovation Principles : Overview-4 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,

16

Global network of innovation

Methods

Contain coding

Have an interface

Global network of innovation Methods Contain coding Have an interface lcl _airplane ... fly land 17

lcl _airplane

...

fly

land

17

Global network of innovation

Methods : Syntax

CLASS < classname > DEFINITION .

...

METHODS : <method_name>

[ IMPORTING < im _ var > TYPE <type>

EXPORTING <ex_ var > TYPE <type>

CHANGING < ch _ var > TYPE <type>

RETURNING VALUE( <re_ var > ) TYPE <type>

EXCEPTIONS <exception> ].

ENDCLASS.

CLASS < classname > IMPLEMENTATION .

METHOD <method_name>.

...

ENDMETHOD .

ENDCLASS.

Global network of innovation Methods : Syntax CLASS < classname > DEFINITION . ... METHODS :

18

Global network of innovation

Methods : Visibility

Public methods

Can be called from outside the class

Private methods

Can only be called within the class

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION.

METHODS : set_name importing

im _name TYPE string.

PRIVATE SECTION.

METHODS : init _name.

DATA: name TYPE string.

ENDCLASS.

CLASS lcl _airplane IMPLEMENTATION.

METHOD init _name.

name = ‘No Name‘.

ENDMETHOD .

METHOD set_name.

IF im _name IS INITIAL.

*

Calling init _name

...

ELSE. name = im _name. ENDIF.

ENDMETHOD .

ENDCLASS.

Global network of innovation Methods : Visibility Public methods  Can be called from outside the

19

Global network of innovation

Methods : Instance and Static

Instance methods

Can use both static and instance components in the implementation part

Can be called using the instance name

Static methods

Can only use static components in the implementation part Can be called using the class name

Global network of innovation Methods : Instance and Static Instance methods  Can use both static

20

Global network of innovation

Methods Instance and Static : Example

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION. METHODS :

set_name IMPORTING im _name TYPE string.

CLASS-METHODS : get_count RETURNING VALUE(re_count) TYPE I.

PRIVATE SECTION.

DATA:

name TYPE string.

CLASS-DATA: count TYPE I.

ENDCLASS.

CLASS lcl _airplane IMPLEMENTATION. ... METHOD get_count. re_count = count . ENDMETHOD

ENDCLASS.

Global network of innovation Methods Instance and Static : Example CLASS lcl _airplane DEFINITION. PUBLIC SECTION.

21

Global network of innovation

Attributes & Methods : UML Notations

Class name

Attributes

Methods

lcl _airplane

  • - name: string

  • - count: i

+ set_name( im _name: string)

+ get_count(): i

  • - set_count( im _count: i)

+ public components

  • - private components

_ static components marked with an underscore

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION. METHODS:

set_name IMPORTING im _name TYPE string.

CLASS-METHODS: get_count RETURNING VALUE(re_count) TYPE I.

PRIVATE SECTION.

DATA:

name TYPE string.

CLASS-DATA: count TYPE I. METHODS: set_count IMPORTING im _count TYPE i. ENDCLASS.

Global network of innovation Attributes & Methods : UML Notations Class name Attributes Methods lcl _airplane

22

Global network of innovation

Principles : Overview-5

Global network of innovation Principles : Overview-5 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,
Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles

23

Global network of innovation

Creating Objects

Objects can only be created and addressed using reference variables

lcl _airplane

 

name

weight

 
weight

...

CREATE OBJECT

name: LH Berlin weight: 30,000 kg
name:
LH Berlin
weight: 30,000 kg
Global network of innovation Creating Objects Objects can only be created and addressed using reference variables

24

Global network of innovation

Referance Variables

Global network of innovation Referance Variables CLASS lcl _airplane DEFINITION. PUBLIC SECTION. ... PRIVATE SECTION. ...

CLASS lcl _airplane DEFINITION. PUBLIC SECTION. ... PRIVATE SECTION. ... ENDCLASS.

CLASS lcl _airplane IMPLEMENTATION. ... ENDCLASS.

DATA: airplane1 TYPE REF TO cl _airplane, airplane2 TYPE REF TO cl _airplane.

airplane1

airplane1
 

airplane2

airplane2

Main memory

25

Global network of innovation

Creating Objects : Syntax

CREATE OBJECT <reference>.

DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE REF TO lcl _airplane.

CREATE OBJECT airplane1. CREATE OBJECT airplane2.

Main memory name: weight: 0 name: weight: 0 airplane1 airplane2
Main memory
name:
weight: 0
name:
weight: 0
airplane1
airplane2
Global network of innovation Creating Objects : Syntax CREATE OBJECT <reference>. DATA: airplane1 TYPE REF TO

26

Global network of innovation

Assigning References

... DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE REF TO lcl _airplane.

CREATE OBJECT airplane1. CREATE OBJECT airplane2.

airplane1 = airplane2.

Main memory name: weight: 0 airplane2 airplane1 name: weight: 0
Main memory
name:
weight: 0
airplane2
airplane1
name:
weight: 0
Global network of innovation Assigning References ... DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE

27

Global network of innovation

Garbage Collector

... DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE REF TO lcl _airplane.

CREATE OBJECT airplane1 EXPORTING

.

CREATE OBJECT airplane2 EXPORTING

.

airplane1 = airplane2.

Global network of innovation Garbage Collector ... DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE
airplane1 name: LH B weight: 30,000 kg airplane2 name: AA Bost weight: 45,000 kg Main memory
airplane1
name:
LH B
weight: 30,000 kg
airplane2
name: AA Bost
weight: 45,000 kg
Main memory
Global network of innovation Garbage Collector ... DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE

28

Global network of innovation

Garbage Collector : Procedure

All independent references in the global main memory are checked. The references point to active objects, which are marked internally.

If class or instance attribute references point to other objects, these are also marked.

Objects that are not marked are deleted from the main memory.

Global network of innovation Garbage Collector : Procedure All independent references in the global main memory
Main memory
Main memory
Global network of innovation Garbage Collector : Procedure All independent references in the global main memory

29

Global network of innovation

Principles : Overview-6

Global network of innovation Principles : Overview-6 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,
Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles

30

Global network of innovation

References : Comparison

DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE REF TO lcl _airplane.

CREATE OBJECT airplane1 EXPORTING im _name = ‘ LH Berlin ‘ ... CREATE OBJECT airplane2 EXPORTING im _name = ‘ LH Berlin ‘ ...

IF airplane1 = airplane2 . ... ENDIF.

not equal to

w: 30,000 kg w: 30,000 kg LH Berlin LH Berlin n: n:
w: 30,000 kg
w: 30,000 kg
LH Berlin
LH Berlin
n:
n:

airplane1

airplane2

Main memory

Global network of innovation References : Comparison DATA: airplane1 TYPE REF TO lcl _airplane, airplane2 TYPE

31

Global network of innovation

Buffering References -1

DATA: airplane airplane_table

TYPE REF TO cl _airplane, TYPE TABLE OF REF TO cl _airplane.

CREATE OBJECT airplane. APPEND airplane TO airplane_table.

airplane

airplane
 
airplane airplane_table Main memory
airplane airplane_table Main memory

airplane_table

airplane airplane_table Main memory
airplane airplane_table Main memory

Main memory

CREATE OBJECT airplane. APPEND airplane TO airplane_table.

Global network of innovation Buffering References -1 DATA: airplane airplane_table TYPE REF TO cl _airplane, TYPE
airplane airplane_table Main memory
airplane
airplane
airplane_table
airplane_table
airplane airplane_table Main memory

Main memory

32

Global network of innovation

Buffering References -2

LOOP AT TO airplane_table INTO airplane. *

work with the current instance ENDLOOP.

Main memory airplane_table airplane 2 1
Main memory
airplane_table
airplane
2
1
Global network of innovation Buffering References -2 LOOP AT TO airplane_table INTO airplane. * work with

33

Global network of innovation

Object Reference as Attributes

Global network of innovation Object Reference as Attributes lcl _airplane lcl _wings orientat .: left length:
lcl _airplane lcl _wings orientat .: left length: 15 m name: LH Berlin weight: 30,000 kg
lcl _airplane
lcl _wings
orientat .: left
length:
15 m
name:
LH Berlin
weight: 30,000 kg
left_wing:
right_wing:
orientat .: right
length:
15 m
34

Global network of innovation

External Access to Public Attributes

Instance attribute:

<reference> -><instance_attribute>

Class attribute:

< classname> => <class_attribute>

CLASS lcl _airplane DEFINITION.

PUBLIC SECTION . DATA : name

TYPE string READ-ONLY.

CLASS-DATA : count TYPE I READ-ONLY. ...

ENDCLASS. ... DATA: airplane1 TYPE REF TO lcl _airplane. DATA: airplane_name TYPE STRING, n_o_airplanes TYPE i.
ENDCLASS.
...
DATA: airplane1 TYPE REF TO lcl _airplane.
DATA: airplane_name TYPE STRING,
n_o_airplanes TYPE i.
name: LH Berlin
...
airplane_name =
airplane1->name .
n_o_airplanes = lcl _airplane=>count .
Global network of innovation External Access to Public Attributes Instance attribute: <reference> -> <instance_attribute> Class attribute:

35

Global network of innovation

Global network of innovation Calling Methods call method O2->Do_it Run Do_it Data Data O1 O2 36
Calling Methods call method O2->Do_it Run Do_it Data Data O1 O2 36
Calling Methods
call method O2->Do_it
Run
Do_it
Data
Data
O1
O2
36

Global network of innovation

Calling Methods : Syntax

Instance methods:

Static methods:

CALL METHOD <instance> -> <instance_method> EXPORTING < im _ var > = <variable> IMPORTING <ex_ var > = <variable> CHANGING < ch _ var > = <variable> RECEIVING <re_ var > = <variable> EXCEPTIONS <exception> = < nr >.

CALL METHOD < classname > => <class_method>

EXPORTING ...

.

DATA: airplane TYPE REF TO lcl _airplane. DATA: name TYPE string. DATA: count_planes TYPE I.

CREATE OBJECT airplane.

CALL METHOD airplane->set_name EXPORTING im _name = name. CALL METHOD l cl _airplane=>get_count RECEIVING re_count = count_planes.

Global network of innovation Calling Methods : Syntax CALL METHOD <instance> -> <instance_method> EXPORTING < im

37

Global network of innovation

Functional Methods

When defining:

RETURNING parameters

Only IMPORTING parameters and exceptions are also possible

When calling:

RECEIVING parameters, or ... Various forms of direct call possible:

...

MOVE, CASE, LOOP Logical expressions (IF, ELSEIF, WHILE, CHECK, WAIT) Arithmetic expressions and bit expressions (COMPUTE)

Global network of innovation Functional Methods When defining: RETURNING parameters Only IMPORTING parameters and exceptions are

38

Global network of innovation

Functional Methods : Example

CLASS lcl _airplane DEFINITION. PUBLIC SECTION. METHODS: estimated_fuel_consumption IMPORTING im _distance

TYPE ty _distance

RETURNING VALUE(re_fuel) TYPE ty _fuel, CLASS-METHODS: get_count RETURNING VALUE(re_count) TYPE i. ENDCLASS.

DATA: plane1

plane2

TYPE REF TO lcl _airplane, TYPE REF TO lcl _airplane,

fuel_consumption TYPE ty _fuel,

count_planes

TYPE i.

* Instantiation omitted

* CALL METHOD plane1->get_count RECEIVING re_count = count_planes. count_planes = lcl _airplane=>get_count( ).

fuel_consumption =

plane1->estimated_fuel_consumption( 1000 )

+ plane2->estimated_fuel_consumption( im _distance = 1500 ).

Global network of innovation Functional Methods : Example CLASS lcl _airplane DEFINITION. PUBLIC SECTION. METHODS: estimated_fuel_consumption

39

Global network of innovation

Constructor

lcl _airplane

name

weight

count

constructor

 

Special method for creating

objects with defined initial

state

Only has IMPORTING

parameters and

EXCEPTIONS

Global network of innovation Constructor lcl _airplane name weight count constructor Special method for creating objects

Exactly one constructor is

 

defined per class (explicitly

or implicitly)

Is executed exactly once per

instance

METHODS METHODS CONSTRUCTOR CONSTRUCTOR IMPORTING IMPORTING < < im im _parameter> _parameter>

 

EXCEPTIONS EXCEPTIONS <exception>. <exception>.

CREATE OBJECT

name: LH Berlin weight: 30,000 kg
name:
LH Berlin
weight: 30,000 kg
Global network of innovation Constructor lcl _airplane name weight count constructor Special method for creating objects

40

Global network of innovation

Constructor : Example

CLASS lcl _airplane DEFINITION. PUBLIC SECTION.

METHODS CONSTRUCTOR IMPORTING im _name

TYPE string

im _weight TYPE I.

PRIVATE SECTION.

DATA: name

TYPE string, weight TYPE I.

CLASS-DATA count TYPE I. ENDCLASS.

CLASS lcl _airplane IMPLEMENTATION.

METHOD CONSTRUCTOR.

name

= im _name.

weight = im _weight. count = count + 1.

ENDMETHOD.

ENDCLASS.

DATA airplane TYPE REF TO lcl _airplane. ... CREATE OBJECT airplane name: LH Berlin weight: 30,000
DATA airplane TYPE REF TO lcl _airplane.
...
CREATE OBJECT airplane
name:
LH Berlin
weight: 30,000 kg
EXPORTING im _name
= `LH Berlin`
im _weight = 30000.
Global network of innovation Constructor : Example CLASS lcl _airplane DEFINITION. PUBLIC SECTION. METHODS CONSTRUCTOR IMPORTING

41

Global network of innovation

Static Constructor

CLASS <classname > DEFINITION.

PUBLIC SECTION.

ENDCLASS.

CLASS <classname > IMPLEMENTATION.

...

ENDMETHOD.

ENDCLASS.

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.

CLASS-METHODS:

CLASS_CONSTRUCTOR,

get_count RETURNING

VALUE(re_count) TYPE I.

CLASS-DATA: count TYPE I.

ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

METHOD CLASS_CONSTRUCTOR .

...

ENDMETHOD.

...

ENDCLASS.

Global network of innovation Static Constructor CLASS <classname > DEFINITION. PUBLIC SECTION. ENDCLASS. CLASS <classname >

42

Global network of innovation

Call To Static Constructor

Special static method

Automatically called before the class is first accessed

Only executed once per program

* Example 1:

DATA airplane TYPE REF TO cl _airplane.

CREATE OBJECT airplane.

* Example 2:

DATA class_id TYPE string.

class_id = lcl_airplane=>count .

* Example 3:

DATA count_airplane TYPE I.

CALL METHOD lcl_airplane=>get_count RECEIVING re_count = count_airplane.

Global network of innovation Call To Static Constructor Special static method Automatically called before the class

43

Global network of innovation

Principles Overview -7

Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation, Instantiation, Garbage Garbage Collector Collector Working Working
Objects
Objects
Classes
Classes
Attributes
Attributes
Methods
Methods
Instantiation,
Instantiation, Garbage
Garbage Collector
Collector
Working
Working with
with Objects
Objects
Further
Further Principles
Principles
Global network of innovation Principles Overview -7 Objects Objects Classes Classes Attributes Attributes Methods Methods Instantiation,

44

Global network of innovation

Encapsulation

Class as capsule for functions Defined responsibilities within a capsule (class) Defined interfaces using

Public components of class (PUBLIC SECTION) Interfaces

Implementation of component remains hidden through limited visibility (PRIVATE SECTION)

Global network of innovation Encapsulation Class as capsule for functions Defined responsibilities within a capsule (class)

45

Global network of innovation

Client Server Behavior

Classes behave toward each other as client/server systems.

Classes normally play both roles. Responsibilities between the classes must be established.

Run Data
Run
Data
Do_it Data
Do_it
Data

CALL METHOD server->Do_it

Client

Server

Global network of innovation Client Server Behavior Classes behave toward each other as client/server systems. Classes

46

Global network of innovation

The Delegation Principle

 

lcl _airplane

 

lcl _tank

lcl _client

lcl _client tank : lcl _tank fuel_max : i fuel : i

tank : lcl _tank

lcl _client tank : lcl _tank fuel_max : i fuel : i

fuel_max : i

fuel : i

 
 

get_fuel_level () : re_level

 

get_fuel_level () : re_level

lcl _airplane lcl _tank lcl _client tank : lcl _tank fuel_max : i fuel : i
lcl _airplane lcl _tank lcl _client tank : lcl _tank fuel_max : i fuel : i
lcl _airplane lcl _tank lcl _client tank : lcl _tank fuel_max : i fuel : i

re_level = tank->get_fuel_level ( ).

re_level = fuel / fuel_max * 100.

Global network of innovation The Delegation Principle lcl _airplane lcl _tank lcl _client tank : lcl

47

Global network of innovation

Delegation : Sequence Diagram

pilot : lcl _client

airbus : lcl _airplane

tank : lcl _tank

re_level 2: get_fuel_level ( ) re_level 1: get_fuel_level ( )
re_level
2: get_fuel_level ( )
re_level
1: get_fuel_level ( )
Global network of innovation Delegation : Sequence Diagram pilot : lcl _client airbus : lcl _airplane

48

Global network of innovation

Namespaces within a Class

The same namespace for

Attribute names Method names Event names Type names Constant names ALIAS names

There is a local namespace within methods

Global network of innovation Namespaces within a Class The same namespace for  Attribute names 

49

Global network of innovation

Namespace : Example

CLASS lcl _airplane DEFINITION. PUBLIC SECTION. METHODS CONSTRUCTOR IMPORTING im _name TYPE string im _weight TYPE I.

PRIVATE SECTION.

DATA name

TYPE string.

DATA weight TYPE I.

ENDCLASS.

CLASS cl _airplane IMPLEMENTATION. METHOD CONSTRUCTOR. DATA name TYPE string VALUE `-airplane`.

CONCATENATE im _name name INTO ME->name .

weight = im _weight. ENDMETHOD. ENDCLASS.

Global network of innovation Namespace : Example CLASS lcl _airplane DEFINITION. PUBLIC SECTION. METHODS CONSTRUCTOR IMPORTING

50

Global network of innovation

Questions ?

Global network of innovation Questions ? © Copyright Siemens Business Services

© Copyright Siemens Business Services