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!!!
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!!!
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.
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.
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:
You must declare the array like this:Code:int MAX; cin >> MAX; int array[MAX]
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
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.
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.
http://cboard.cprogramming.com/showt...threadid=21673
http://cboard.cprogramming.com/showt...threadid=29219
Pay particular attention to what Prelude says.
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.
ok, thanks
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
hope this helps.Code:#include <cstdlib> #include <ctime>
Later,
WebmasterMattD
WebmasterMattD.NET
what is the difference?
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
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