lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Toward a consistent naming convention [Was: Code review: product e


From: Greg Chicares
Subject: [lmi] Toward a consistent naming convention [Was: Code review: product editor]
Date: Sat, 24 Mar 2007 00:06:23 +0000
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

On 2007-3-21 17:36 UTC, Evgeniy Tarassov wrote:
> 
> Now looking at it -- the class DatabaseTreeItemData should be moved
> from databae_view_editor.hpp to database_view.cpp, and it methods
> should follow lmi naming convention.
> 
> BTW I wanted to ask you before if you want me to rename product_editor
> related classes from SomeName to some_name. I should have done that
> before :S, but better late than never..

Let's defer that. We have a lot of code with ThisNamingStyle and a
lot of other code with this_naming_style (and some that mixes both).
This problem is so widespread that nothing we're doing really makes
it worse. It's a global problem that needs a global solution.

Do you have any thoughts on what convention would be best? I'm not
really sure, but let me try thinking out loud.

 - Following the Myers and Abrahams guidelines is rarely a mistake.
   They of course suggest following the standard_library_convention:
   all lowercase for almost everything, and MACROS_LIKE_THIS.

 - Hardly anyone uses upper case in C++ file names. These enter
   code via #include statements. It's nice to have, e.g.,
     #include <boost/shared_ptr.hpp>
     boost::shared_ptr<Ledger const> composite_ledger_;
   because grepping for 'shared_ptr' shows every occurence of
   the class or its header: another advantage of lower_case_names.
   It's too painful to grep for '[Ss]hared_*[Pp]tr]'.

 - ThisName is one character shorter than this_name. That's an
   advantage for MixedCaseNames, but not a big enough advantage
   to have convinced boost to write SharedPtr.

 - We're going to have a mixture of styles for wx-derived classes:
     class ViewEx
         :public wxView                      // wxMixedCase
         ,virtual private boost::noncopyable // lower_case
     {
     virtual wxIcon Icon() const = 0;        // wxMixedCase
   I don't think it reasonable to try to force consistency here
   ['typedef wxView wx_view;'? No!]. But this class also has:
     wxFrame& FrameWindow() const;
     std::string base_filename() const;
   and wouldn't it be better to pick one style for both? If so,
   which seems better? Let me suggest:

     class view_lmi // 'lmi' seems better than 'ex' [1]
         :public wxView
         ,virtual private boost::noncopyable
     {
     ...
     virtual wxIcon Icon() const = 0;
     wxFrame& frame_window() const;
     std::string base_filename() const;

What we've already done can be renamed later, by a careful and
conscientious person who need not be a C++ expert. If we can
establish a guideline today for new code we add later, that's
a big step forward. I don't want to do that without asking for
your thoughts first--I could be overlooking some major problem.

---------

[1] I'd rename 'ViewEx' (with -'Ex' as in 'MessageBoxEx') to
'view_lmi' in the example above, to distinguish it from wxView,
and because 'view' alone may be too short. I am not suggesting
an -'lmi' suffix for every class. The historical reason for wx
to use a 'wx'- prefix doesn't apply to us: we can change lmi
radically without breaking a million users' code.

I'd also like to lose little scraps of other libraries' naming
styles, like the borland 'T'- prefix for a few ancient classes.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]