Browse Prior Art Database

Encapsulation Technique of Function in C Language

IP.com Disclosure Number: IPCOM000112980D
Original Publication Date: 1994-Jun-01
Included in the Prior Art Database: 2005-Mar-27
Document File: 2 page(s) / 52K

Publishing Venue

IBM

Related People

Shimizu, T: AUTHOR

Abstract

Disclosed is a programming technique for the encapsulation of C language functions. The technique helps making program components in C language and it is also easy to encapsulate existing C language functions. The program component, which is a function of C language, gets the return code from the previous functions. And it returns this return code without any operations if the passed return code does not equal to zero. The modules composed of such functions make less 'if' statement for the error handling and much easier to understand the process flows.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 53% of the total text.

Encapsulation Technique of Function in C Language

      Disclosed is a programming technique for the encapsulation of C
language functions.  The technique helps making program components in
C language and it is also easy to encapsulate existing C language
functions.  The program component, which is a function of C language,
gets the return code from the previous functions.  And it returns
this return code without any operations if the passed return code
does not equal to zero.  The modules composed of such functions make
less 'if' statement for the error handling and much easier to
understand the process flows.

      The programming technique defines the rules of C language
programming.  When a function is made in C language,

      (1) it must have the return code in the parameters from the
previous return code.

      (2) when the return code in the parameters is not 0, it must
returns this return code.

      (3) when any errors happens in the function, it must returns
the return code, not 0.

      The following source code shows the sample skeletons of the
technique.
 int xxx (int rc)
 {
    /* if any error, no operation.  */
    if (rc!=0) return (rc) ;
    /* do something */
    .....  ;
    .....  ;
    return (rc) ;
 }
 int yyy (int rc, int msg, int method)
 {
    /* if any error, no operation.  */
    if (rc!=0) return (rc) ;
    /* do something */
    .....  ;
    .....  ;
    return (rc) ;
 }

      The next code shows that the technique helps the reconstruction
of the procedure.  The consideration of the error handling makes
troubles when changing the procedure.  Th...