Re: Managing a project as it scales
- From: David Wilkinson <no-reply@xxxxxxxxxxxx>
- Date: Sat, 17 Dec 2005 11:45:30 -0500
Alexander wrote:
Thank you for taking the time to elaborate on these topics, Joe.
The last few days have been very interesting. I've read a number of the articles on your site as well as others that I've found on the Code Project. I'm still processing all this information, but it is clear that I have made some obvious and not-so-obvious coding mistakes.
One of the problem areas I have is in error handling, which I basically ignored (i.e. exceptions) or dealt with in a rather inconsistent manner. I can address the later but I still have difficulty understanding the appropriate use exceptions. I mean, even CString can throw an exception. If I were to try and catch all feasible exceptions the code would bloat enormously. Or worse, I could implement a "catch-all" and then not be able to spot legitimate errors while in development. So the questions is, when and where is a good idea to acknowledge exceptions? File operations?
Another issue is the manipulation of controls from classes other than its owner (say, a CDialog derived class). I now realize I shouldn't pass pointers to controls or even to "this" and use SendMessage or, if from a thread, use PostMessage. The thing is, how do you identify the control? It seems you should at least have access to a dialog/window handle (hwnd). Is that the appropriate method? Updating a progress bar or a static control from a thread is a fairly common task I implement. What's the correct approach?
I have also been subclassing to deeply and have ended up having to populate the base class with scores of virtual methods. My thinking was that intermediate classes would avoid duplicating code but I can see how they have complicated the implementation a lot. A rewrite is in order.
Documentation is an area where I have to start from scratch. I've looked around and have found some tools (say, Doxygen) but it seems that your commenting style does not follow a format I recognize. do you use a documentation tool? If so, which? If not, am I to understand they are not worth the effort?
Other questions pop to mind but I don't want to tax your patience. Thanks again.
Alexander
Alexander:
Manipulation of Controls from other classes:
Just don't do it! Don't even tell the class containing the control to do it. Rather, tell the other class what happened, and let the other class decide what to do.
Documentation:
I started using Doxygen this year and I love it (and it's free!). I just annotate the header files, using /// for full-line comments before the item, and //< for end-of-line comments after the item. I do not write very much, but I make sure that all the methods have a simple description and a specification of the parameters and return value, and that each member variable has a brief description of what it is (this is where I use //<).
In the implementation file I don't do as much as I should (I just use simple C++ // comments on their own line or at the end of the line). But one of the greatest programming books I ever read is "Refactoring" by Martin Fowler. One thing he says is something like: "If you see a piece of code with a comment, take that code out into its own (private) method and give the method a name that looks like the comment; then the comment becomes superfluous." Basically, if you use short methods with good names, the code is self-describing. The examples in the book are all in Java, but you know C++ you don't need to know Java in order to follow them. Just a fabulous book!
David Wilkinson .
- Follow-Ups:
- Re: Managing a project as it scales
- From: Alexander
- Re: Managing a project as it scales
- References:
- Managing a project as it scales
- From: Alexander
- Re: Managing a project as it scales
- From: BobF
- Re: Managing a project as it scales
- From: Joseph M . Newcomer
- Re: Managing a project as it scales
- From: Alexander
- Managing a project as it scales
- Prev by Date: Re: Managing a project as it scales
- Next by Date: Re: Managing a project as it scales
- Previous by thread: Re: Managing a project as it scales
- Next by thread: Re: Managing a project as it scales
- Index(es):
Relevant Pages
|