From 56f8f2b0e3cff72c655ea5e1de4629ebc57b5b9e Mon Sep 17 00:00:00 2001 From: levine Date: Wed, 19 Nov 1997 15:41:28 +0000 Subject: avoid unnecessary parens --- etc/ACE-guidelines.html | 82 +++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'etc') diff --git a/etc/ACE-guidelines.html b/etc/ACE-guidelines.html index 4e239fc986b..db333c7d112 100644 --- a/etc/ACE-guidelines.html +++ b/etc/ACE-guidelines.html @@ -148,6 +148,8 @@ to Graham for providing the OSE tools!

a space after the ``if'', and no spaces just after the opening parenthesis and just before the closing parenthesis.

+

  • Avoid unnecessary parenthesis. We're not writing Lisp :-)

    +

  • Put inline member functions in a .i file. That file is conditionally included by both the .h file, for example:

    @@ -233,53 +235,34 @@ to Graham for providing the OSE tools!

    machines. ACE_UINT32 is always 4 bytes, and ACE_hrtime_t is always 8 bytes. (We should/may/will add an ACE_UINT64, soon.)

    -

  • Constructor initializers must appear in the same order as - the data members are declared in the class header. This avoids - subtle errors, because initialization takes place in the order - of member declaration.

    - -

  • Initialization is usually cleaner than assignment, especially - in a conditional. So, instead of writing code like this: - -
    -       ssize_t n_bytes;
    -
    -       // Send multicast of one byte, enough to wake up server.
    -       if ((n_bytes = multicast.send ((char *) &reply_port, sizeof reply_port)) == -1)
    -       
    +
  • Constructor initializers must appear in the same order as + the data members are declared in the class header. This avoids + subtle errors, because initialization takes place in the order + of member declaration.

    - Write it like this: +

  • Initialization is usually cleaner than assignment, especially + in a conditional. So, instead of writing code like this: -
    -       ssize_t n_bytes = multicast.send ((char *) &reply_port, sizeof reply_port)
    -
    -       // Send multicast of one byte, enough to wake up server.
    -       if (n_bytes == -1)
    -       

    +

    +        ssize_t n_bytes;
     
    -       But, beware if the initialization is of a static variable.
    -       A static variable is only initialized the first time its
    -       declaration is seen.  Of course, we should avoid using
    -       static variables at all.

    + // Send multicast of one byte, enough to wake up server. + if ((n_bytes = multicast.send ((char *) &reply_port, sizeof reply_port)) == -1) +

    -
  • Because ACE does not use exception handling, dealing with - failures requires a bit of care. This is especially true - in constructors. Consider the following approach: + Write it like this: -
    -       ACE_NEW_RETURN (this->name_space_, LOCAL_NAME_SPACE, -1);
    +        
    +        ssize_t n_bytes = multicast.send ((char *) &reply_port, sizeof reply_port)
     
    -       if (ACE_LOG_MSG->op_status () != 0)
    -       ....
    -       
    + // Send multicast of one byte, enough to wake up server. + if (n_bytes == -1) +

    - This snip of code is from - ACE_Naming_Context. - All failed constructors in ACE (should) call ACE_ERROR. This sets - the thread specific op_status, which can be checked - by the caller. This mechanism allows the caller to check for a failed - constructor without the requiring the constructor to throw - exceptions.

    + But, beware if the initialization is of a static variable. + A static variable is only initialized the first time its + declaration is seen. Of course, we should avoid using + static variables at all.

  • I/O

    @@ -330,6 +313,25 @@ to Graham for providing the OSE tools!

  • Do not use exception handling. Some platforms do not support it. And, it imposes an execution speed penalty.

    +

  • Because ACE does not use exception handling, dealing with + failures requires a bit of care. This is especially true + in constructors. Consider the following approach: + +
    +      ACE_NEW_RETURN (this->name_space_, LOCAL_NAME_SPACE, -1);
    +
    +      if (ACE_LOG_MSG->op_status () != 0)
    +      ....
    +      
    + + This snip of code is from + ACE_Naming_Context. + All failed constructors in ACE (should) call ACE_ERROR. This sets + the thread specific op_status, which can be checked + by the caller. This mechanism allows the caller to check for a failed + constructor without the requiring the constructor to throw + exceptions.

    +

  • Avoid using the C++ Standard Template Library (STL) in our applications. Some platforms do not support it yet.

    -- cgit v1.2.1