Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This comes from a closed thread at stack overflow, where there are already some useful answers, though a commenter suggested I post here. I hope this is ok!

I'm trying my best to write good readable, code, but often have doubts in my work!

I'm creating some code to check the status of some protected software, and have created a class which has methods to check whether the software in use is licensed (there is a separate Licensing class).

I've named the class 'Protection', which is currently accessed, via the creation of an appProtect object. The methods in the class allow to check a number of things about the application, in order to confirm that it is in fact licensed for use.

Is 'Protection' an acceptable name for such a class?

I read somewhere that if you have to think to long in names of methods, classes, objects etc, then perhaps you may not be coding in an Object Oriented way. I've spent a lot of time thinking about this before making this post, which has lead me to doubt the suitability of the name!

In creating (and proof reading) this post, I'm starting to seriously doubt my work so far. I'm also thinking I should probably rename the object to applicationProtection rather than appProtect (though am open to any comments on this too?). I'm posting non the less, in the hope that I'll learn something from others views/opinions, even if they're simply confirming I've "done it wrong"!

EDIT:

Thanks for all the responses, which have been all been helpful. I think 'Protector' fits the bill perfectly, as the class checks the license, and acts accordingly.

share|improve this question
1  
It's hard to say without knowing more about what this class does, but is it possible that "Protector" would be a better name? –  FrustratedWithFormsDesigner Jul 9 '12 at 15:10
    
Thank you. That's exactly what I was looking for! I'll get the hang of this soon... –  jonny Jul 10 '12 at 8:15
    
OMFG........... –  James Jul 10 '12 at 15:29
add comment

4 Answers

Your class looks like a Singleton Pattern, so SingleLicence.class may interest you

share|improve this answer
add comment

I think you might be overanalyzing this. Be wary of analysis paralysis.

So I suggest you stick with the name for now. You can always change it later. Besides, most entities tends to change name a couple of times while developing, so you don't need to worry.

share|improve this answer
    
+1. Also avoid duplicating the package name in the class name. –  kevin cline Jul 9 '12 at 15:52
    
I am very aware of analysis paralysis, and it's constant attempts to get in my way. Thanks for the input –  jonny Jul 10 '12 at 8:15
add comment

The noun you use to name an object usually comes out of what that object represents. What the object represents is a function of its member variables and its methods. So, what are they? :-)

share|improve this answer
add comment

Protection is too generic ( protection from what? ).

I would try to use a more specific name. Its very hard to say what the name of the class is without knowing what it is intended for. If it is checking a licence, you can use LicenseChecker.

I prefer having real nouns as Class names. There is lot of debate on this so I won't claim I'm 100% right - it is just my preference. Although LicenseChecker is a noun, it feels wrong to me - because it is still emphasizes on the verb ( check ). What I would have is a License object with a isValid() method which checks whether license is valid. Your License object can be obtained from your Licensing class, using Licensing.getLicense()

share|improve this answer
    
Thank you. Not wanting to be pedantic, but I read that you shouldn't use the object name in a method name, which in your above suggestion would change Licensing.getLicense() to Licensing.get(). Can I ask on your opinion of this? I understand the reasoning behind not repeeating object names, but just using 'get()' seems too non-descriptive to me. Source: point 12 of Java Programming Style Guidelines –  jonny Jul 10 '12 at 8:20
    
My interpretation of the Licensing class was that it provides/creates/manages licences but is not the licence itself. That's why it got a instance of License using getLicense(). The link you gave is for object properties. For example, if you have a License object, and want to get expiry date, you should do License.getExpiry() instead of License.getLicenseExpiry(). If Licensing class describes one license, then there is no need to do another Licensing.get(). Just use Licensing class itself. Let me know if you need more clarification. –  Chip Jul 10 '12 at 19:08
    
Thanks for the clarification Chip. –  jonny Jul 11 '12 at 8:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.