idl编程,
https://www.omg.org/cgi-bin/doc?formal/02-06-39
CMU/SEI-2002-TN-015
27
8.2 IDL
A small sample interface specified in OMG’s IDL is shown in Figure 14. This interface is for
an element that manages a bank account. The element provides resources to manage a finan-
cial account with attributes of “balance” and “owner.” The operations provided include
“deposit” and “withdraw.” Although syntax is specified unambiguously in this type of docu-
mentation, semantic information is largely missing. For example, can a user make arbitrary
withdrawals? Withdrawals only up to the current account balance? Up to a daily limit? Up to a
minimum balance? If any of these restrictions is true, what happens if it’s violated? Is the max-
imum permissible amount withdrawn, or is the transaction as a whole canceled?
IDL by itself is inadequate when it comes to fully documenting an interface, primarily because
IDL offers no language constructs for discussing the semantics of an interface; without expres-
sion of the semantics, ambiguities and misunderstandings will abound.
interface Account {
readonly attribute string owner;
readonly attribute float balance;
void deposit (in float amount);
void withdraw (in float amount);
};
interface CheckingAccount: Account {
readonly attribute float overdraft_limit;
void order_new_checks ();
};
interface SavingsAccount: Account {
float annual_interest ();
};
interface Bank {
CheckingAccount open_checking (in string name, in float
starting_balance);
SavingsAccount open_ savings (in string name, float
starting_balance);
};
https://resources.sei.cmu.edu/library/asset-view.cfm?assetid=5939
https://resources.sei.cmu.edu/asset_files/TechnicalNote/2002_004_001_13973.pdf