[C++-sig] Questions/Comments about new stuff

David Abrahams david.abrahams at rcn.com
Wed Jul 17 21:09:01 CEST 2002


Some further hints about this piece of code:

1. I'm reluctant to include too much use of std::string since we have
direct access to Python strings in this library.

2. std::strchr() et. al are great for iterating through a dotted name

3. Pulling the real work out of the loop and using "am I at the last name"
as a termination condition helps a lot

4. Tests like:

    if (XXX)
    {
        if (YYY)
        {
            if (ZZZ)
            {
                ...
            }
        }
    }

are easier to read as:

    if (XXX
        && YYY
        && ZZZ
    )
    {
        ...
    }

----- Original Message -----
From: "Dave Hawkes" <daveh at cadlink.com>

> > A few more points:
> >
> > . Coding conventions - please try to follow the coding conventions
> > established throughout the rest of the codebase.
> > class_base::get_context_object() is an example of a function which does
> all
> > kinds of things differently. IOW, not this:
> >
> >     if(expr) {
> >         ...
> >     }
> >
> > but this, please:
> >
> >     if (expr)
> >     {
> >         ...
> >     }
> >
> > Also, this function is much too big, dense, and deeply-nested. Comment
> > lines should in general be preceded by a blank line. Many lines are too
> > long. I wouldn't make such a big deal about this one, but I know I
> > mentioned it as early as
> > http://aspn.activestate.com/ASPN/Mail/Message/1230478.
> >
> Now that the API is in place I plan to revise this code as I should be
able
> to make it a little more compact. I'll tidy the style up at the same
time. I
> did revist the code since that discussion but it was difficult to pull
out
> many helper functions that would use the overall code apart from maybe a
few
> thing that would replicate what was being handle in the python API code.

> > . Variable names like "r" for a type_handle don't say enough about its
> > purpose to help the reader.
> >
> I think that one slipped through when I was changing a few other variable
> names.
>
> > I'm still reformatting and massageing this get_context_object() thing
so I
> > can get a feel for what it's doing...
> >
> It's still only around 30 lines of code excluding the comments and I may
be
> able to par it down further using the API code.








More information about the Cplusplus-sig mailing list