After two months of c++...

This is a discussion on After two months of c++... within the Windows Programming forums, part of the Platform Specific Boards category; ...and programming as a general, here is what I could come up with . This program is just something I ...

  1. #1
    Loom Weaver the dead tree's Avatar
    Join Date
    Apr 2004
    Posts
    140

    Post After two months of c++...

    ...and programming as a general, here is what I could come up with .
    This program is just something I created while learning windows, and I would like a feedback not on itīs code ( nothing but the most basics ), but on the way I commented it.
    The way I see, my comments seen superficial, unusefull and describing nothing of importance. But at the same time that I tried to give more info, I noticed how hard it is to keep track of the comments if I change anything within the program, and ended up trying to keep them as local as possible.
    I looked at some other people comments ( specially the contest ones ), but I know that perceiving own faults is a difficult task, and I would like to get in the habbit of doing things right while I'm still starting.

    So, if you can spare some time to look at it, I'd really appreciate. If you wish to say anything about the code itself, go for it.

    If you are going to run the code, I'm not done with the program and it still has a few issues. If you run an animation, you must press F4 to regain control of the application. Also, if you mouse click, the cursor disappears/appears.
    By the way, I didnīt make any function const because I'm not so sure exactly where to put the const . Also, I'm aware there is some very ugly functions there, where I duplicated code a lot, but at the moment I am not sure how I will fix it.
    Attached Files Attached Files

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    I haven't compiled it but after a quick glance I don't see any corresponding delete[] for all those allocations with new[] which is not good.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I thought your commenting was generally very good. The only comment I noticed that served no purpose was:
    Code:
         // Creates handle to a window, by succesfully creating a Window!
    We know what CreateWindow does, how about telling us which window you are creating?

    Other than that, don't be afraid of using vertical space. Code formatting like this should be avoided:
    Code:
            if (  starLoc == NULL ){if ( SilenceVar.GetboxTest() == TRUE ) {   SilenceVar.SetboxTest(FALSE);MessageBox(NULL,TEXT("Not enough memory to run this application. The program will now terminate."),TEXT("Error."),MB_OK | MB_ICONWARNING );PostQuitMessage(0);}}
    I can't comment on the actual code as I didn't look that closely.

  4. #4
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Wow, impressive.

  5. #5
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Very cool. Reminds me of the flashing letters in the Matrix.

    As for your code, I think its pretty well-formatted although I do have one gripe. There are a few lines that are too long (one of them is >300 characters long. I suggest you try to keep all lines within 80 characters, as it reduces scrolling horizontally. It will also prove useful whenever you wish to print or publish your code on the internet.

  6. #6
    Loom Weaver the dead tree's Avatar
    Join Date
    Apr 2004
    Posts
    140
    haven't compiled it but after a quick glance I don't see any corresponding delete[] for all those allocations with new[] which is not good.
    I tried to delete them just before a quit message, but I got some errors. I wasnīt sure if I needed to delete them anyway, as you can see below, since the program was exiting. I'll fix that.
    Code:
    if ( quit == IDYES )
    			 {
    			 KillTimer(hwnd,1);
    			 //delete [] animePos;
    			 //delete [] starDist; Do I need to delete?
    			 //delete [] starLoc;   
    			 PostQuitMessage (0);
    			 }
    Annoytmouse, that comment about the window was there because I used to remind me of things while studying. I didnīt comment anything important on WinMain because I thought it wasnīt necessary, and after a while I simply forgot it was there .
    Other than that, don't be afraid of using vertical space.
    There are a few lines that are too long
    And thanks for the tip . I was trying to "hide" the more superfulous code, but I guess that did look ugly.
    Thanks everyone for giving me some feedback.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating and using functions
    By moy18 in forum C Programming
    Replies: 2
    Last Post: 11-01-2007, 05:26 AM
  2. creating and using functions
    By moy18 in forum C Programming
    Replies: 2
    Last Post: 10-31-2007, 10:09 PM
  3. summing number of days between 2 months
    By duff_johnny in forum C Programming
    Replies: 5
    Last Post: 11-03-2005, 02:36 PM
  4. a program to create months in a year newbie question
    By robasc in forum C Programming
    Replies: 2
    Last Post: 03-05-2005, 05:41 PM
  5. See you in 15 months!
    By Sang-drax in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 01-20-2003, 07:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21