Jump to content
  • Advertisement
Sign in to follow this  
Bbalstrzmj90

Question about style

This topic is 5051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been going through the forums and I've noticed a lot of htings related to specific coding styles in the industry. I am planning on getting into the industry (not specifically game programming) and I did not want to develop any bad styles that might stop me from getting far. (I use C++). I've been reading things like you shouldn't be doing
using namespace std; 
I can change that style of mine, but I don't want to be writing
std::cout << "hi" << std::endl;
std::cin >> i; 
. I don't want to be writing that out constantly. Is there anyway to get around all that and still keep good coding style. Also I read that when declaring classes that most of the industry does:
class CSomething
. Where you put a capital C infront of the class name and capitalize the first letter in the name. Is this a good habit to develop? Any other coding styles/habits you guys think I should use would be appreciated. Thanks. -MJ

Share this post


Link to post
Share on other sites
Advertisement
Not sure about the namespaces, but as for the classes sticking a "C" in front of your classes is generally a good idea. For instance,

class CMyfunc {
}
void Myfunc() {
}

You'll be able to tell what's a class and what's not. Most C++ programmers do this, not just game C++ programmers.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
why is "using" using namespace a bad thing?

all bad coding styles are bad for a reason,
try to find why sonething should or should not be
done before adopting a style,
not only will you knowledge increase but you will not be following a style or practice that is merely the preference, or bad idea at times, of someone else.

Share this post


Link to post
Share on other sites
The thing with "using namespace std" is that in the industry, you won't really be using "cout" or "cin" because you won't be writing console apps. It's really a matter of choice anyways. I hate prefixing everything with "std::". The class thing is totally a matter of choice to. Any company you get a job at will just want to see that you can write cleanly. Use your own judgement there. Companies enforce their own coding style, so when you get a job they'll tell you exactly what style to use.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
for things like naming conventions,
use what make the most sense to you,
but try to get into the habit of being consistent,
because most companies have there own internal
conventions, and they will expect you to be consistent
those.

Share this post


Link to post
Share on other sites
Quote:
Original post by aaroncox1234
The thing with "using namespace std" is that in the industry, you won't really be using "cout" or "cin" because you won't be writing console apps. It's really a matter of choice anyways. I hate prefixing everything with "std::". The class thing is totally a matter of choice to. Any company you get a job at will just want to see that you can write cleanly. Use your own judgement there. Companies enforce their own coding style, so when you get a job they'll tell you exactly what style to use.


I beg to differ. There will be times when one will need to write console apps in the industry. For instance, writing servers. It would take a bit less memory if no GUI were present with the server app.

Share this post


Link to post
Share on other sites
Personally I hate it when people prefix things by what they are. Any half-decent IDE can tell you that when you hover your mouse over your variable. I have started prefixing member variables with m_ to make them stand out more in large functions, but C in front of classes...ugh.

Share this post


Link to post
Share on other sites
thanks guys. I think I'll develop my own style as long as theres nothing wrong with it. And for now I'll still "use" using namespace std. And I'll also start working on the way to declare classes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!