• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Clean Code A Handbook of Agile Software Craftsmanship - Meaningful Names

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about such class names like "ThreadSafetyAdministratorHibernateDAO", is it good? Sometimes there is really problem
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frankly, I'm undecided on the length of the name. But besides that, I'd think that the name might better be

ThreadSafeHibernateAdministratorDAO
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be careful with a name like that unless you can back it up (with tests) to prove that it is ThreadSafe.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.)
 
Author
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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....
 
Author
Posts: 3473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As long as a consistent approach is used for naming I am happy.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


;-) 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
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heh Nice discussion but i wrote this class name only for example as a very long name. Probably i could use name "BlebleAbrakadabraSomethingClassName"
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic