if the error code is valid
determine the processing method
if doing interactive processing
print the error message interactively and declare success
else doing batch processing
if the batch message file opens properly
log the error message to the batch file,
close the file, and declare success
else the message code is not valid
notify the user that an internal error has been detected
这时是指出接口假设的好时机。在本例中,接口变量ErrorCode 和Status 是简明的,并且
根据其特定用途排序,不含任何隐蔽信息。
把PDL 转变成高层次注释。利用Pascal 中的Begin 和End,或者C 中的“{”和“}”,可
以把PDL变成注释,以下是把前述的PDL变成了Pascal语言:
procedure RecordErrorMessage
(
Errorcode:ErrorCode_t;
var Status:Status_t
);
{ This routine outputs an error message based on an error code
Supplied by the calling routine. The way it outputs the message
depends on the current processing state, which it retrieves
on its own. It returns a variable indicating success or failure.}
begin
{ set the default status }
{ look up the message based on the error code }
{ if the error code is valid}
{ determine the processing method }
{ if doing interactive processing}
{ print the error message interactively and declare success}
{ else doing batch processing }
{ if the batch message file opens properly}
{log the error message to the batch file,
close the file. and declare success}
{else the message code is not valid}
{ notify the user that an internal error has been detected}
end; { RecordErrorMessage() }
这时,子程序的特点已经非常明显了,设计工作已经结束了,没看见任何代码,但已经知
道子程序如何工作了。把PDL转换成程序语言代码是一件机械、自然、容易的工作。如果你不