Alpha Criticism: Part One......

This is a discussion on Alpha Criticism: Part One...... within the C++ Programming forums, part of the General Programming Boards category; Welcome to part one of the alpha critism series. Here, I will post a source code that I made and ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    18

    Alpha Criticism: Part One......

    Welcome to part one of the alpha critism series. Here, I will post a source code that I made and other experience/expert programmers will critism my coding abilities. I like this new concept, it will help me improve my coding style. Here it goes!!!
    Attached Files Attached Files

  2. #2
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    howdy,
    Way, Way too many comments!

    M.R.
    I don't like you very much. Please post a lot less.
    Cheez
    *and then*
    No, I know you were joking. My point still stands.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    18
    You're crazy right?
    Everytime I code I never put comments on my code. I did, however, put comments on alpha sorting to reduce the negative criticism so that someone won't say, "You need more comments"

    I didn't put that many comments on the code.

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Comments are always good. (but // End of if statement is perhaps a little overkill)

    Your program is invalid C++.

    The size of arrays must be known at compile time. This is invalid:
    Code:
    int MAX;
    cin >> MAX;
    int array[MAX]
    You must declare the array like this:
    Code:
    int MAX;
    cin >> MAX;
    int* array = new int[MAX];
    [...]
    delete[] array; //when the array has been used
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Speedy5
    Guest
    It's always best to place more comments than you need than to place less.

    A very good practice is to comment each function and tell what the parameters do. As for the brace ending comments, they're not really needed unless it makes things clearer for you. But you should comment a bit more. Comments should be placed before the line of code, not after and on the same line. That makes things neater.

  6. #6
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Comments are supposed to increase readability... too many comments decrease readability, too little do the same. Try to find a happy medium.

    Design your program in a way that's self documenting. You don't need to comment on what a function like CreateWindow, Sleep, KillThread does; the name is document enough.

    Code comments
    The Art of Writing Comments :: Software Engineering
    Pay particular attention to what Prelude says.

  7. #7
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I mainly just comment at the top of every source file, for some functions, and always for graphics and gameloop stuff. But I don't comment as much as most people do.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    18
    ok, thanks

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    110
    Only thing that I found confusing in your code was the inclusion of the c headers stdlib.h and time.h.
    If you are going to use these headers ( the program that you supplied does not require them ), then you should use the following code
    Code:
    #include <cstdlib>
    #include <ctime>
    hope this helps.

    Later,
    WebmasterMattD
    WebmasterMattD.NET

  10. #10
    Registered User
    Join Date
    Nov 2002
    Posts
    18
    what is the difference?

  11. #11
    Registered User
    Join Date
    Apr 2002
    Posts
    110
    when you are using #include <iostream> and 'using namespace std' you should use the #include <cstdlib> version.
    I am not a hundred percent sure what the exact difference is, though this is what I have been told and found others to do.

    Later,
    WebmasterMattD
    WebmasterMattD.NET

  12. #12
    Back after 2 years Panopticon's Avatar
    Join Date
    Dec 2002
    Posts
    262
    By using the using namespace std; statement you effectively tell the compiler all included files are of the std namespace (or global namespace i forgot/dunno)
    #include <something.h> is the old C style headers and C++ supports it for the sake of backward compatibility. By specifying a filename instead of an identifier, the compiler automatically treats the included files as if it were in the global namespace (because namespaces weren't supported in C) so using namespace std; is redundant.

    But standard C++ encourages the use of identifiers, using namespace std; statements and discourages using .h filenames so I guess its in the spirit of good practice.
    I AM WINNER!!!1!111oneoneomne

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-11-2006, 05:28 AM
  2. Can someone look over my code? part 2
    By brooklyn in forum C++ Programming
    Replies: 10
    Last Post: 04-18-2006, 07:33 AM
  3. Signal Handling - Are they part of ANSI C?
    By Stanley S in forum C Programming
    Replies: 3
    Last Post: 12-21-2005, 07:49 AM
  4. Suspicious Pointer Conversion
    By mr_spanky202 in forum C Programming
    Replies: 35
    Last Post: 04-11-2003, 01:35 PM
  5. a little OT, but, criticism and avice wanted !
    By Shadow in forum C++ Programming
    Replies: 2
    Last Post: 10-01-2001, 09:38 AM

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