[bt-devel] Programming Techniques

David White bt-devel@crosswire.org
09 Mar 2002 16:24:25 +1100


On Sat, 2002-03-09 at 15:01, Matt Andrews wrote:
> Welcome, and thanks for helping us.

hi there, no problem. Thanks for your welcome.

[snip me going on about something or another]

> Oh hey, that's cool. I wish my professors would teach
> stuff like that.

yeah, most (computer|software) (science|engineering) courses really
don't teach proper software development practices at all. My university
didn't teach us C++ *at all*, and I didn't learn real development
practices until much later.

If you want some good articles on exceptions, there are some at
http://www.gotw.ca/gotw/065.htm and http://www.gotw.ca/gotw/082.htm - in
fact, everything at http://www.gotw.ca/gotw contains great stuff about
C++ in general.

> 
> /*
>  * Stuff about exceptions
>  */
> Exceptions good. 
> 
> /*
>  * A whole bunch of stuff my brain is still trying to
> dissect
>  */
> Umm, ok.
> 
> > 
> > One minor point, I have put all this in the
> > namespace util. So you have
> > to go util::scoped_resource etc. I notice that
> > BibleTime doesn't use
> > namespaces at the moment, but I suggest we consider
> > changing this.
> > namespaces are a cool feature that allows much
> > better division of code.
> What are ways we would use namespace is this instance?
> Would we use Sword::CClass instead of CSwordClass?

Well, any time you have a whole lot of classes (or other identifiers),
that share a common prefix, it is an indication that they should be
placed in a namespace, and drop their prefixes. So yes, CSwordBackend,
CSwordBibleModuleInfo, CSwordKey, etc etc could become CBackend,
CBibleModuleInfo, CKey and put in a Sword namespace. (although
personally I'm not a great fan of prefixing classes with 'C', but lots
of people do it and I can live with it).

It would be much cleaner, for example, if the developers of QT had put
all their classes in a QT namespace, instead of having QList, QArray and
so on and so forth. (Although to be fair to the QT developers, I suspect
the namespace feature was in an infantile state when they began
developing their product). Following the convention that the language's
standard library uses is a way of ensuring that you will almost never go
wrong.

Blessings,

David.

> 
> 
> =====
> "To them God has chosen to make known among the Gentiles the glorious riches of this mystery, which is Christ in you, the hope of Glory" - Colossians 1:27
> 
> __________________________________________________
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free email!
> http://mail.yahoo.com/