This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Agile and Other Processes and the fly likes 	 Clean Code A Handbook of Agile Software Craftsmanship - Meaningful Names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Agile and Other Processes
Bookmark "	 Clean Code A Handbook of Agile Software Craftsmanship - Meaningful Names" Watch "	 Clean Code A Handbook of Agile Software Craftsmanship - Meaningful Names" New topic
Author

Clean Code A Handbook of Agile Software Craftsmanship - Meaningful Names

Tomasz Prus
Ranch Hand

Joined: May 20, 2008
Posts: 73
What about such class names like "ThreadSafetyAdministratorHibernateDAO", is it good? Sometimes there is really problem
J. Nuno
Greenhorn

Joined: Jul 11, 2008
Posts: 13
Hi, I wonder if all classes on each layer (dao, ejb, entity, view, controller) should have common name endings like Tomasz suggested "ThreadSafetyAdministratorHibernateDAO" or be placed in a meaningfull package and drop the ending like com.myapp.server.dao.ThreadSafetyAdministratorHibernate?

Thank you!
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Frankly, I'm undecided on the length of the name. But besides that, I'd think that the name might better be

ThreadSafeHibernateAdministratorDAO


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Travis Scheponik
Greenhorn

Joined: Sep 23, 2008
Posts: 1
In my honest opinion it really comes down to preference. As long as you are not writing a paragraph for a name you should be fine, I have seen some horrible names in my short time in this field example being doThreadFailAB123
not one person in the whole place knew what it did nor were there any other methods that would indicate a <122 it was just a sad, sad day for me.
Paul Croarkin
Ranch Hand

Joined: Sep 30, 2004
Posts: 106
Be careful with a name like that unless you can back it up (with tests) to prove that it is ThreadSafe.


Thanks,<br /> <br />Paul Croarkin<br />SCEA 5, SCWCD, SCJP
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Paul Croarkin:
Be careful with a name like that unless you can back it up (with tests) to prove that it is ThreadSafe.


I agree that you should "prove" it. (Although I hope that you are aware that tests don't actually *prove* a lot.) But even if you don't, the name would at least communicate intent. When maintaining code, knowing what the code was supposed to do often is even more important than knowing what it actually does. (The latter can always be tried out, the former might be lost forever otherwise.)
Robert Martin
Author
Ranch Hand

Joined: Jul 02, 2003
Posts: 76
Originally posted by Tomasz Prus:
What about such class names like "ThreadSafetyAdministratorHibernateDAO", is it good? Sometimes there is really problem


I guess it depends on whether that class is the Hibernate implementation of the DAO that has the CRUD functions for ThreadSafetyAdministrator instances.

If not, then I think that name could probably use a bit of work.


---<br />Uncle Bob.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Robert Martin:


I guess it depends on whether that class is the Hibernate implementation of the DAO that has the CRUD functions for ThreadSafetyAdministrator instances.

If not, then I think that name could probably use a bit of work.


What name would you you give to a thread-safe hibernate implementation of a DAO for Administrator instances?
Robert Martin
Author
Ranch Hand

Joined: Jul 02, 2003
Posts: 76
Originally posted by Ilja Preuss:


What name would you you give to a thread-safe hibernate implementation of a DAO for Administrator instances?


;-) Since all classes should be thread safe, I would simply call it AdministratorDAO. I would put the ThreadUnsafe prefix on it if it wasn't thread safe....
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3219
As long as a consistent approach is used for naming I am happy.


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52

;-) Since all classes should be thread safe, I would simply call it AdministratorDAO. I would put the ThreadUnsafe prefix on it if it wasn't thread safe....


That's very interesting. This make me think harder.

1. Yes we do strive to make class immutable.(Implies it is thread safe)
unless on is exposing the internal implementation to be manipulated outside it.

2. While that is the case, there are place where we use lot of bean classes which have setters and getters, in these places, we don't make them thread safe, but expect a instance of this created and for each operation, and leave it to the client class handle the threading if it is really required.

3. Let us take instance of java's HashMap, we don't need thread safe instance always. If we have all of objects thread safe, will it not lead to performance problem?
We use thread safe version of HashMap only when it is needed.
Isn't that we need to think of the usage, while we decide to make any class thread safe or not?

4. Another note on the class name - If the class name is not clear, all i can conclude is, the coder/developer is not clear of what he is doing or has a very poor coding discipline.
Tomasz Prus
Ranch Hand

Joined: May 20, 2008
Posts: 73
Heh Nice discussion but i wrote this class name only for example as a very long name. Probably i could use name "BlebleAbrakadabraSomethingClassName"
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
Long class names are not a bad practice at all. You just need to make the class name descriptive of what it does, and not make it longer than it should be. If you can name a class clearly using 10 characters, don't use 20. If you need a 100 characters to make it clear, so be it. Don't give it a name of 15 characters because you don't want a long name


Visit my blog: http://jnassef.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Clean Code A Handbook of Agile Software Craftsmanship - Meaningful Names
 
Similar Threads
Getting the value of the select box in a textbox
Post the meaning of your FirstName and LastName
NcNealy steps down...
Company name...
A EL Question