Jump to content
  • Advertisement
Sign in to follow this  
Nicholas Kong

Critique my Java Class Names

This topic is 1789 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 just want to know if the Java Class Names are appropriate so that when someone sees the class they will know what the class does based off the name. The game is a "match the word to the displayed image" type game.

 

JavaClasses_zpsad033fab.png

Edited by warnexus

Share this post


Link to post
Share on other sites
Advertisement

Naming is kind of a subjective thing but your naming is fine. At least, it conforms to what's normally expected in a Java project, and your classes are CamelCase, don't use any IWeirdImpl notation, and are descriptive (as far as we can tell - for all we know, your WordGenerator might be your main loop :)).

 

Are you building for J2ME? Anything else and I'd use package names, for convenience and convention.

Share this post


Link to post
Share on other sites

You should start to put things up in separate packages. For now you can see everything in a single list, but that wont last long. Besides, separating functionality in packages kinda enforces some decoupling, or at least makes you think how your classes are really coupled.

Share this post


Link to post
Share on other sites

Naming is kind of a subjective thing but your naming is fine. At least, it conforms to what's normally expected in a Java project, and your classes are CamelCase, don't use any IWeirdImpl notation, and are descriptive (as far as we can tell - for all we know, your WordGenerator might be your main loop smile.png).

 

Are you building for J2ME? Anything else and I'd use package names, for convenience and convention.

I am using Java SE(Standard Edition). Thanks for the feedback. It is nice to know the names are great.

 

Actually the main loop is in the Main.java. The Game loop is in Game.java.

 

Actually, an instance of WordGenerator class is created inside the Game class because the game needs to generate a new word whether the user got the word right or wrong.

 

Okay I will try to use packages too.

Edited by warnexus

Share this post


Link to post
Share on other sites

Depending on what i'm doing, i'll do it as you do. If I am working on a project with which I have a clear name for, i'll use a precursor of every function and class. Kind of like how OpenGL's functions have gl such as glScalef, though I don't care much for the data type indicator at the end. One of my recent projects I have been using clu and Clu; cluFunction and CluClass.

Share this post


Link to post
Share on other sites

You should start to put things up in separate packages. For now you can see everything in a single list, but that wont last long. Besides, separating functionality in packages kinda enforces some decoupling, or at least makes you think how your classes are really coupled.

Thanks TheChubu. Yeah I will need to use packages now. biggrin.png

Share this post


Link to post
Share on other sites

Depending on what i'm doing, i'll do it as you do. If I am working on a project with which I have a clear name for, i'll use a precursor of every function and class. Kind of like how OpenGL's functions have gl such as glScalef, though I don't care much for the data type indicator at the end. One of my recent projects I have been using clu and Clu; cluFunction and CluClass.

What do you mean by a precursor like a common prefix? So gl, clu and Clu will be your precursors in your case?

Edited by warnexus

Share this post


Link to post
Share on other sites

The reason why OpenGL functions have types at the end is because C doesn't supports function overloading. Thus every function has to have a different name, no matter if the parameters are different among functions with the same name. I wouldn't suggest doing the same if your programming language of choice does supports overloading, and the IDE is nice enough to tell apart between different functions.

Share this post


Link to post
Share on other sites

Since there are classes and packages in Java to "partition the namespace", in a sense, there is IMHO no good reason to use a common prefix for all classes in your project.

 

On J2ME projects putting all classes into the default package was an optimization once but on J2SE projects you should generally use packages. Note that they conventionally go like tld.yourdomain.yourproject.maybeyoursubproject.yourpackage.yoursubpackagesetc in order to avoid conflicts globally but you are not limited to this, you can of course use any package names you want.

Share this post


Link to post
Share on other sites

Since there are classes and packages in Java to "partition the namespace", in a sense, there is IMHO no good reason to use a common prefix for all classes in your project.

 

On J2ME projects putting all classes into the default package was an optimization once but on J2SE projects you should generally use packages. Note that they conventionally go like tld.yourdomain.yourproject.maybeyoursubproject.yourpackage.yoursubpackagesetc in order to avoid conflicts globally but you are not limited to this, you can of course use any package names you want.

Thanks! I use packages too.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!