ABAP--ABAP语言对象编程的一些样例代码连接收集 (thanks to jack wu)

 1)ABAP语言对象编程

Why Use ABAP Objects

Why Use ABAP Objects Exercise

Eight Reasons Why Every ABAP Developer Should Give ABAP Objects a Second Look

An Insider's Guide to Writing Robust, Understandable, Maintainable State of the Art ABAP Programs, Part 1 - Fundamental Rules and Formal Criteria

An Insider's Guide to Writing Robust, Understandable, Maintainable State of the Art ABAP Programs, Part 2 - Best Practices

ABAP Objects for Java Developers

Obsolete ABAP Language Constructs

ABAP Shared Objects - Shared Memory Programming Made Easy

Shared Objects in ABAP - Exercises

2)关于ABAP语言对象的析构函数

Currently, ABAP Objects does not provide a destructor on the ABAP level, i.e. where ABAP statements would be executed. This note gives the rationale for this decision and the adopted solution.

These are some of the issues regarding instance destructors in ABAP, i.e. destructors that are called when an object (instance) is reclaimed by the garbage collector:

  • ABAP Objects comes with automatic storage management ('garbage collection') and thus fulfills the most important task that destructors have in other OO languages, namely to release other objects. As a result, destructors should only  be needed for releasing global/external resources!
  • Destructors consume runtime and constitute a risk for performance! While the entire roll area could previously be released in one step at the end of a program / roll area, it is now necessary to execute destructors before the roll area can be released. But why should destructors reset variables where the whole process memory will be thrown away right afterwards?
  • Because of the problem of 'destructors at the end of a program', we then thought of introducing two types of destructors, those that are executed always (within and at the end of a mode/program), and those that are only executed if you are not at the end of a mode/roll area. However, this results in complicated models that reduce only the performance risk without solving the other problems.
  • The time when a destructor is called, that is, when storage management recognizes that a specific object can be released, is completely undefined, and subject to change. New optimizations of the garbage collector or a slight variation in context will cause the destructors to run at a different time  or not at all.
  • When the destructor is being executed, you generally can no longer assume anything about the 'environment' of the object, in particular, you cannot assume if the destructors of other objects have already been executed. This means that in a destructor you can basically only do things that can exclusively be done by this object, for example, release an external resource uniquely assigned to this object. Programming 'safe' destructors is one of the harder challenges and a cause of many subtle error conditions that are generally impossible to reproduce.
  • For many applications such as GUI control proxies, the destructor is not even the right place to 'close' external resources. Consider an object that allows you to talk to a word processor instance on the client desktop. To 'close' the word processor is an active act of the application under whose control the client application is, generally triggered by a user action such as a 'close button'. There you can't just delete a reference and wait for the garbage collector to come around. Thus, not all kinds of external resources can be controlled by the ill-defined execution times of the garbage collector.
  • Finally, you may want to run destructors in case of a ABAP runtime error, i.e. after a so-called 'RABAX'. In that case the mode/program will also be closed and external resources should be freed. This however is especially unreliable, since you cannot make assumptions on how bad a state the ABAP processor is, i.e. how bad the runtime error was. After many errors, there is no way to safely execute ABAP statements anymore, thus it cannot be guaranteed that the destructor can be run at all in error cases. In a transactional environment, external resources are handled at a much lower level, e.g. at the RFC connection level. When the RFC connection is closed for whatever reason, all resources on both sides are freed by the kernel. This is the only safe place to guarantee resource management.

In light of all these problems, the designers of ABAP Objects decided no not provide an ABAP Destructor at this time. Instead, there is a provision for a 'C-destructor' that can however only be used by SAP kernel developers.

3)ABAP语言对象编程初学者参考样例代码

ABAP Objects - Creating your First Local Class - Defining Components

ABAP Objects - Creating your First Local Class - Defining the Visibility

ABAP Objects - Creating your First Local Class - Inheriting Class

ABAP Objects - Creating your First Local Class - Using Events

ABAP Objects - Creating your First Local Class - Using Instance Constructor

ABAP Objects - Creating your First Local Class - Using self-reference In INHERITING

ABAP Objects - Creating your First Local Class - Using Static Constructor

 4)ABAP语言对象中级编程参考样例代码

ABAP Objects - ALV Model - Sorting Table

ABAP Objects - ALV Model With Events - Using Link Click

ABAP Objects - ALV Model With Events - Using Link Click, Double Click & Button

ABAP Objects - Creating your First Local Class - Working With Anonymous Data Object

 

5)ABAP语言对象高级编程参考样例代码

ABAP Objects Advanced Examples ABAP Objects - ALV Model - Using Header and Footer

ABAP Objects - Defining a Class-based exceptions

ABAP Objects - Defining a Local Class as FRIENDS

ABAP Objects - Defining a Local Interface as FRIENDS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值