1290

A long time ago I have read an article (I believe a blog entry) which put me on the "right" track on naming objects: Be very very scrupulous about naming things in your program.

For example if my application was (as a typical business app) handling users, companies and addresses I'd have a User, a Company and an Address domain class - and probably somewhere a UserManager, a CompanyManager and an AddressManager would pop up that handles those things.

So can you tell what those UserManager, CompanyManager and AddressManager do? No, because Manager is a very very generic term that fits to anything you can do with your domain objects.

The article I read recommended using very specific names. If it was a C++ application and the UserManager's job was allocating and freeing users from the heap it would not manage the users but guard their birth and death. Hmm, maybe we could call this a UserShepherd.

Or maybe the UserManager's job is to examine each User object's data and sign the data cryptographically. Then we'd have a UserRecordsClerk.

Now that this idea stuck with me I try to apply it. And find this simple idea amazingly hard.

I can describe what the classes do and (as long as I don't slip into quick & dirty coding) the classes I write do exactly one thing. What I miss to go from that description to the names is a kind of catalogue of names, a vocabulary that maps the concepts to names.

Ultimately I'd like to have something like a pattern catalogue in my mind (frequently design patterns easily provide the object names, e.g. a factory)

  • Factory - Creates other objects (naming taken from the design pattern)
  • Shepherd - A shepherd handles the lifetime of objects, their creation and shutdown
  • Synchronizer - Copies data between two or more objects (or object hierarchies)
  • Nanny - Helps objects reach "usable" state after creation - for example by wiring to other objects

  • etc etc.

So, how do you handle that issue? Do you have a fixed vocabulary, do you invent new names on the fly or do you consider naming things not-so-important or wrong?

P.S.: I'm also interested in links to articles and blogs discussing the issue. As a start, here is the original article that got me thinking about it: Naming Java Classes without a 'Manager'


Update: Summary of answers

Here's a little summary of what I learned from this question in the meantime.

  • Try not to create new metaphors (Nanny)
  • Have a look at what other frameworks do

Further articles/books on this topic:

And a current list of name prefixes/suffixes I collected (subjectively!) from the answers:

  • Coordinator
  • Builder
  • Writer
  • Reader
  • Handler
  • Container
  • Protocol
  • Target
  • Converter
  • Controller
  • View
  • Factory
  • Entity
  • Bucket

And a good tip for the road:

Don't get naming paralysis. Yes, names are very important but they're not important enough to waste huge amounts of time on. If you can't think up a good name in 10 minutes, move on.

Community
  • 1
  • 1
froh42
  • 5,040
  • 6
  • 28
  • 42
  • 14
    It belongs in the community wiki because there is no one "best" answer. It's a discussion. – DOK Dec 08 '09 at 13:01
  • 17
    That is counter intuitive. Shouldn't they call it a forum? I would think a wiki would be for a collection of facts, not opinions. – AaronLS Dec 08 '09 at 13:07
  • 1
    If you need a 'Nanny' object then that implies its possible to break your classes invariants - better redesign your class imho – jk. Dec 08 '09 at 13:09
  • 1
    I agree with the CW suggestion. It's a good question, but there really is no single "right" answer. As Lazarus observed below, naming conventions can (and should) be modified as appropriate for the specific application domain and/or company. – Richard J Foster Dec 08 '09 at 13:09
  • @DOK: I don't think CW means there is "no one 'best' answer". If that were the case then the answers wouldn't receive scores at all and it wouldn't be possible to accept one as the best answer. But oh well, this discussion doesn't belong here ... – Frank Jan 15 '10 at 14:37
  • 93
    Thanks for keeping this updated - but ugh, that last tip is terrible advice! If you can't think of a good name in 10 minutes, there's probably something wrong with your class. (With the standard caveats: 1) perfect is the enemy of good, 2) Shipping is a feature - just remember that you're incurring technical debt.) – Jeff Sternal Jan 15 '10 at 14:55
  • Is it OK to list prefix/suffix names you should avoid? I'm thinking of `Processor` here, it's ambiguous and could be anything that takes an input and produces an output. Also in similar sense, `SubSomething` should be avoided too. – Esko Jan 16 '10 at 17:48
  • see this topics : http://stackoverflow.com/questions/1274577/class-naming-chaos http://stackoverflow.com/questions/38019/whats-the-best-approach-to-naming-classes – Peter Dec 08 '09 at 13:26
  • @anton1980 See the [first comment](http://stackoverflow.com/questions/1866794/naming-classes-how-to-avoid-calling-everything-a-whatevermanager#comment1763620_1866794), this is why it's not constructive. I'm not reopening it, but feel free to bring it up on [Meta] if you want the community view. – casperOne Feb 11 '13 at 21:59
  • 15
    If you can't think up a good name in 10 minutes then ask your colleague for help. Don't just give up. –  Jan 16 '14 at 17:28
  • A few years late to this, but I started going with a "Clerk" suffix. Probably just as "bad" as manager, but Clerks IRL are only able to perform functions according to a strict set of business rules. The "Clerk" indicates to the consumer this object type only has these sort of functions available. If you can't find what you need, the clerk needs to be expanded, or a new clerk created to do the work you need. – WhiskerBiscuit Jul 19 '14 at 00:28
  • @JamesM., I was just thinking this same thing. In this case a closure ***is*** the ultimate upvote, and while it doesn't fit the question and answer format, there really should be an allowance made for something akin to "Not strictly Q&A, but very clear and useful, therefore allowed." –  Mar 28 '15 at 00:53
  • @JamesM. While this sort of information is useful, wouldn't Programmers.SE be more appropriate? – All Workers Are Essential May 12 '15 at 18:38
  • good list. a couple more I have used in the past: Driver, Arbitrator, Declaration, Instance. – Dominic Birmingham Feb 10 '16 at 12:18
  • 12
    If you can't think up a good name in 10 minutes, try explaining it to your colleagues; they _might_ think of a good name (user338195), but trying to explain it will probably help you discover what's wrong with it ([Jeff](http://stackoverflow.com/users/47886/jeff-sternal)). – WillC Feb 12 '16 at 07:35
  • I use SomeEngine to replace Manager. – Please_Dont_Bully_Me_SO_Lords May 02 '17 at 17:07
  • 2
    If you can't think up a good name in 10 minutes, the problem is not that you won't have a good name. The problem is that you will most likely have bad design. In other words, the inability to find a clear name isn't a issue in and of itself - but an indication of design flaws that run deeper than that. – Konrad Morawski Jan 22 '18 at 15:17
  • You would call them Manager classes when they do nothing ;) [pun intended] - I have seen same pattern in case of *Util *Helper - when in doubt people will call it helper and live happily ever after. It is hard to think about right names and most developer would give low importance to it therefore they just pick the easiest route. These are common issues that I try to point out during code reviews. – software.wikipedia Apr 25 '18 at 20:14
  • 2
    Add Parser & Formatter to the list if you will – nitsas Sep 20 '18 at 12:00
  • I like the idea of specific naming, but I don't like the approach to use names of human professions as this distracts from the topic – Nicolas Oct 29 '18 at 08:36
  • Anybody interested may want to read **[Execution in the Kingdom of Nouns](https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html)** – sampathsris Jan 31 '19 at 09:11
  • I think class names are roughly divided into two groups: 1, classes that *process data*; 2, classes as *result of some process/conversion*. I would suffix the first class names with a verb and the second class, a noun. For example, `UserDataProcessor`, `DateFormatter`, `MonetaryConvertor`, `UtilityHelper`, `ApplicationLauncher`, `ExceptionHandler`, `URLEncoder`, `InputValidator`, `ObjectMapper`, `PatternChecker` for class 1, and `ProviderResponse`, `UserIDNameCompositeKey`, `ConnectionClient`, `LocalizedMessage` for class 2. – WesternGun Jun 03 '19 at 12:55
  • But, I also think this is very subjective, like `XxxService` or `Utils` are also good names for me (classes processing data but with a noun name). Convention is important; but the most important, readability. – WesternGun Jun 03 '19 at 12:58
  • 2
    A class for a user, then a class to create the user, then another class to manage the user's memory allocation - going down that road, you'll find yourself with a code base containing 3 times the classes you actually need to get the job done, where everything is separated to it's own little thingy class that does exactly one thing because Bob's your uncle. I mean, SOLID is nice but man, don't overdo it! – Zohar Peled Jun 20 '19 at 10:35
  • 1
    The guy is right, if you can't think of a name in 10 minutes (I'd make it 1 minute myself) move on. Because you are using TDD (you are, aren't you?) you're going to be re-factoring the code as you go and either the design will evolve and the name will become clear after a refactor, or you will come up with a name as you work. – Richard Moore Sep 26 '19 at 13:20

12 Answers12

229

I asked a similar question, but where possible I try to copy the names already in the .NET framework, and I look for ideas in the Java and Android frameworks.

It seems Helper, Manager, and Util are the unavoidable nouns you attach for coordinating classes that contain no state and are generally procedural and static. An alternative is Coordinator.

You could get particularly purple prosey with the names and go for things like Minder, Overseer, Supervisor, Administrator, and Master, but as I said I prefer keeping it like the framework names you're used to.


Some other common suffixes (if that is the correct term) you also find in the .NET framework are:

  • Builder
  • Writer
  • Reader
  • Handler
  • Container
Arsen Khachaturyan
  • 6,472
  • 4
  • 32
  • 36
Chris S
  • 62,476
  • 49
  • 214
  • 238
  • 5
    I like these a lot. They do not fall into the trap of bad or unknown metaphors because they are already in use by the .NET Framework. It might be interesting to look at other libraries (Java), too for more input of what is commonly used. – froh42 Jan 15 '10 at 14:17
  • I would like to suggest `Conductor`, like the conductor of a musical orchestra. It's surely an important role, depending on the nature of collaborations you need to "conduct" (other objects being very specialized actors that should respond to centralized command and don't worry too much about every other collaborator). – heltonbiker Dec 07 '15 at 12:43
  • 1
    I do not believe the solution to -er classes is to come up with a different name. As I've read in many other posts and I've trying to learn the answer, is that you need to change the architecture, not just the name used. – Michael Ozeryansky Nov 03 '19 at 01:24
  • It's very easy to overthink the names to use, this is an anti-pattern. – John Stock Nov 24 '20 at 23:31
131

You can take a look at source-code-wordle.de, I have analyzed there the most frequently used suffixes of class names of the .NET framework and some other libraries.

The top 20 are:

  • attribute
  • type
  • helper
  • collection
  • converter
  • handler
  • info
  • provider
  • exception
  • service
  • element
  • manager
  • node
  • option
  • factory
  • context
  • item
  • designer
  • base
  • editor
Markus Meyer
  • 180
  • 1
  • 6
  • 13
  • 164
    In one particular company long ago, I knew an engineer so fed up with the absurd and growing plethora of suffix rules plaguing the company that he defiantly ended every class with `Thingy`. –  Mar 28 '15 at 00:56
  • 9
    This list of names by itself is not so useful without the context of which suffix should be applied. – Fred Aug 16 '18 at 12:40
68

I'm all for good names, and I often write about the importance of taking great care when choosing names for things. For this very same reason, I am wary of metaphors when naming things. In the original question, "factory" and "synchronizer" look like good names for what they seem to mean. However, "shepherd" and "nanny" are not, because they are based on metaphors. A class in your code can't be literally a nanny; you call it a nanny because it looks after some other things very much like a real-life nanny looks after babies or kids. That's OK in informal speech, but not OK (in my opinion) for naming classes in code that will have to be maintained by who knows whom who knows when.

Why? Because metaphors are culture dependent and often individual dependent as well. To you, naming a class "nanny" can be very clear, but maybe it's not that clear to somebody else. We shouldn't rely on that, unless you're writing code that is only for personal use.

In any case, convention can make or break a metaphor. The use of "factory" itself is based on a metaphor, but one that has been around for quite a while and is currently fairly well known in the programming world, so I would say it's safe to use. However, "nanny" and "shepherd" are unacceptable.

CesarGon
  • 14,525
  • 6
  • 53
  • 81
  • 12
    This argument really breaks down in that obviously Factory itself is a metaphor. Often metaphors will really clear up what an object might be good at, whereas being vague or generic automatically ensures that the only way to figure out what the code does is by reading it fully! The worst case scenario. – Kzqai Apr 03 '17 at 22:23
  • 1
    +1 for avoiding ‘cute’ names. I think it’s great to be as direct with language as you can be. (Of course, it’s not always easy being direct, succinct, precise _and_ unambiguous all at the same time…) – andrewf Jul 23 '18 at 13:51
  • 1
    An inventive choice of verb + "er" is usually going to be clearer for concrete classes than a colorful analogy will. New abstractions, on the other hand -- stuff that's a new concept, a new "kind of thing" rather than just a new "thing" -- often do work well as metaphors (Java's "beans", Haskell's "lenses", GUI "windows", many languages' "promises"). Most codebases won't have any genuine inventions like that, though. – Malnormalulo May 03 '19 at 15:42
  • Metaphors can be great when the chosen word is frequently used, or used as name for a central entity in your application. We once used "DNA" as suffix for a class of entities that both uniquely identify something and carry some additional meta data. The only reason why the name worked is because nothing else is called "DNA", so everyone always immediately knew what the entity was meant to do. A generic suffix like "ID" could never accomplish that, with ID being used by so many other things. Of course, new developers had no immediate understanding of the term and what it was meant to convey. – enzi Jan 08 '21 at 20:18
50

We could do without any xxxFactory, xxxManager or xxxRepository classes if we modeled the real world correctly:

Universe.Instance.Galaxies["Milky Way"].SolarSystems["Sol"]
        .Planets["Earth"].Inhabitants.OfType<Human>().WorkingFor["Initech, USA"]
        .OfType<User>().CreateNew("John Doe");

;-)

herzmeister
  • 10,651
  • 2
  • 38
  • 50
  • 14
    How would you get to parallel universes and alternate dimensions? – tster Jan 15 '10 at 15:31
  • 26
    That's easy: Omniverse.Instance.Dimensions["Ours"].Universes["Ours"].Galaxies... ... okay okay I admit this would require a recompilation. ;-) – herzmeister Jan 15 '10 at 15:41
  • 79
    **Update:** this was added in .NET 4.0: `Universe.Instance.ToParallel()` ;) – Connell Jul 04 '13 at 13:36
  • 2
    Breaks demeter's law though! – Jonas G. Drange Feb 14 '17 at 09:20
  • 14
    Those are Objects and Members, not Class names – Harry Berry Apr 11 '17 at 11:47
  • I chuckled, but I can't help but nag. For one @HarryBerry is spot on. For another, "modeled the real world correctly" and `.WorkingFor["Initech, USA"]` don't really play together. `/*...*/.WorkingFor(Universe./*...*/.Planets["Earth"].Continents["North America"].Countries["USA"].Companies["Initech"])./*...*/` would at least be consistent. And why the choice of container type for named entities? And why the choice of key? What if I call `.CreateNew("John Doe");` a second time? Throw an exception? What's the key, then? `"John Doe 2"`? Whitespaces in keys? – Johannes Pille May 03 '19 at 23:08
  • 1
    In addition to Harry Berry: what would be the name of the class that creates the `User` (to which class does `CreateNew` belong). Your answer doesn´t scope that at all, making your statement "We could do without any xxxFactory, xxxManager or xxxRepository classes if we modeled the real world correctly:" insufficient. You assume all our code is about pure **data**, which it often is not. It´s also about different strategies to handle that data - which is what we call the **business**-layer. – HimBromBeere Jul 01 '19 at 09:36
  • 1
    "Breaks demeter's law though!": Also I left out checks for `null` back then, arguably for brevity. ;) ———— "Those are Objects and Members, not Class names": `Planets` is a collection/list of objects of a type `Planet`, I would've thought it was self-explanatory. ;) ——— "And why the choice of key?": That was just for illustration purposes, could also be a `Guid`. – herzmeister Aug 31 '19 at 00:04
  • "What would be the name of the class that creates the `User`": Yeah indeed good point, looks I had an extension method in mind back then, but this definitely doesn't look very clean. I guess LINQ was all new and shiny back then and I over-estimated the magic it could do. So following Johannes' proposal I nowadays would just do ...`.Countries["USA"].Companies["Initech"].Users.Add(new User("John Doe"));`. And of course you have one of those magic ORM frameworks that track such changes. – herzmeister Aug 31 '19 at 00:07
  • Problem: In case of `universe...user.store(universe...database)` the user object has to know how to store itself in every kind of data store. In case of `universe...database.store(universe...user)` the database object has to know how to store every kind of object. That is why you always need something like managers. – Toxiro Feb 02 '20 at 12:35
42

It sounds like a slippery slope to something that'd be posted on thedailywtf.com, "ManagerOfPeopleWhoHaveMortgages", etc.

I suppose it's right that one monolithic Manager class is not good design, but using 'Manager' is not bad. Instead of UserManager we might break it down to UserAccountManager, UserProfileManager, UserSecurityManager, etc.

'Manager' is a good word because it clearly shows a class is not representing a real-world 'thing'. 'AccountsClerk' - how am I supposed to tell if that's a class which manages user data, or represents someone who is an Accounts Clerk for their job?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Mr. Boy
  • 52,885
  • 84
  • 282
  • 517
  • 8
    What about UserAccounter, UserProfiler and UserSecurer? If you get rid of Manager, you are forced to come up with the specific definition, which I think is a good thing. – Didier A. Sep 23 '13 at 16:47
  • 11
    What about UserAccount, UserProfile, UserSecurity oO? – clime Dec 07 '13 at 14:28
  • 3
    I would name it "MortageOwnersManager" – volter9 Dec 02 '14 at 22:48
  • Sometimes the domain have specific names. Like "MortageHolder" that may be better that "MortageOwner" – borjab Oct 13 '16 at 11:21
  • Manager is not bad at all, it's worked fine in software engineering for decades. – John Stock Nov 24 '20 at 23:33
  • Manager is great for many cases, but in more complicated situations it's lacking. What if there are 3 types of "manager" for a certain entity? (and a single, monolithic manager doesn't work). That's when generic names like Manager, Utility, Handler or Helper fail, because nobody knows whether method X is in the MortgageManager or the MortgageHandler or it just might be in the MortgageHelper too. – enzi Jan 08 '21 at 20:25
26

When I find myself thinking about using Manager or Helper in a class name, I consider it a code smell that means I haven't found the right abstraction yet and/or I'm violating the single responsibility principle, so refactoring and putting more effort into design often makes naming much easier.

But even well-designed classes don't (always) name themselves, and your choices partly depend on whether you're creating business model classes or technical infrastructure classes.

Business model classes can be hard, because they're different for every domain. There are some terms I use a lot, like Policy for strategy classes within a domain (e.g., LateRentalPolicy), but these usually flow from trying to create a "ubiquitous language" that you can share with business users, designing and naming classes so they model real-world ideas, objects, actions, and events.

Technical infrastructure classes are a bit easier, because they describe domains we know really well. I prefer to incorporate design pattern names into the class names, like InsertUserCommand, CustomerRepository, or SapAdapter. I understand the concern about communicating implementation instead of intent, but design patterns marry these two aspects of class design - at least when you're dealing with infrastructure, where you want the implementation design to be transparent even while you're hiding the details.

Jeff Sternal
  • 45,522
  • 6
  • 87
  • 118
  • 1
    I really like the idea of using the `Policy` suffix for classes containing business logic – jtate Jun 21 '17 at 15:16
  • +1 for mentioning the code smell associated with names like "Manager" and "Helper". I find that if I have no clear names for things, it usually stems at least in part from some fuzziness in my understanding of the domain, whether business or technical. Almost equivalently, it could mean I'm just reactively breaking up classes because they "got too big" - which to me is also a sign of inadequate modeling. This should be the top voted answer. – nclark Dec 28 '19 at 14:42
11

Being au fait with patterns as defined by (say) the GOF book, and naming objects after these gets me a long way in naming classes, organising them and communicating intent. Most people will understand this nomenclature (or at least a major part of it).

Brian Agnew
  • 254,044
  • 36
  • 316
  • 423
  • Fowler is a good reference for me but the GOF is a great recommendation. – Lazarus Dec 08 '09 at 13:04
  • Forgive my ignorance. Which Fowler book are you referring to ? – Brian Agnew Dec 08 '09 at 13:08
  • http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420 – Jim Ferrans Dec 08 '09 at 13:11
  • My bad, meant to put the link in! Doh! – Lazarus Dec 08 '09 at 14:07
  • 20
    Hmm, sometimes this works (for example like a Factory or a Strategy) but in other times I feel that this does communicate the way of implementation (I used a pattern!) more than the intent and job of the class. For example a Singleton's most important thing it what it represents - and not that it is a Singleton. So strict naming after the patterns used feels like strict naming after the types used. For example Hungarian notation as mis-applied by the Windows Systems group (describing the C data type instead of "intent type") – froh42 Dec 08 '09 at 17:02
  • @froh42 - that's a good point re. exposing implementation. Some care certainly needs to be taken. – Brian Agnew Dec 08 '09 at 17:17
  • 1
    For technical infrastructure classes, it's usually desirable to make the implementation transparent - and most of the canonical design pattern names communicate both implementation and intent. Domain model classes are another matter, though. – Jeff Sternal Jan 15 '10 at 14:34
10

If I cannot come up with a more concrete name for my class than XyzManager this would be a point for me to reconsider whether this is really functionality that belongs together in a class, i.e. an architectural 'code smell'.

Jasper van den Bosch
  • 3,112
  • 2
  • 29
  • 53
9

I think the most important thing to keep in mind is: is the name descriptive enough? Can you tell by looking at the name what the Class is supposed to do? Using words like "Manager", "Service" or "Handler" in your class names can be considered too generic, but since a lot of programmers use them it also helps understanding what the class is for.

I myself have been using the facade-pattern a lot (at least, I think that's what it is called). I could have a User class that describes just one user, and a Users class that keeps track of my "collection of users". I don't call the class a UserManager because I don't like managers in real-life and I don't want to be reminded of them :) Simply using the plural form helps me understand what the class does.

Droozle
  • 139
  • 1
  • 5
  • I also really like this approach because it eases off the idea of top down management of objects. A group of users is more likely to imply that work is done between users instead of from the UserManager down. Also, having a User own a reference to Users does not feel as strange as owning UserManager. It's more open to relative thinking, rather than strictly OOP. – Seph Reed Feb 18 '19 at 21:02
  • 1
    The problem with this approach is that becomes really hard to search your code for `Users`, especially if you pass around the manager object. `this.users = new Users()` But then invariably somewhere else in your code `users` will refer to an array of `User`s. – Snowman Feb 20 '20 at 02:10
  • As you say Users indeed implies a "collection of users" - a collection of entities which is stateful. But SRP would mean you wouldn't want to bundle user management (functionality and business logic) with user data (state). Not saying you're wrong, just that UserManager is appropriate if the class is responsible for managing users and not just storing their state and basic CRUD. – Richard Moore May 15 '20 at 10:51
5

Specific to C#, I found "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" to have lots of good information on the logic of naming.

As far as finding those more specific words though, I often use a thesaurus and jump through related words to try and find a good one. I try not to spend to much time with it though, as I progress through development I come up with better names, or sometimes realize that SuchAndSuchManager should really be broken up into multiple classes, and then the name of that deprecated class becomes a non-issue.

alx9r
  • 3,105
  • 2
  • 21
  • 48
AaronLS
  • 34,709
  • 17
  • 135
  • 191
3

I believe the critical thing here is to be consistent within the sphere of your code's visibility, i.e. as long as everyone who needs to look at/work on your code understands your naming convention then that should be fine, even if you decide to call them 'CompanyThingamabob' and 'UserDoohickey'. The first stop, if you work for a company, is to see if there is a company convention for naming. If there isn't or you don't work for a company then create your own using terms that make sense to you, pass it around a few trusted colleagues/friends who at least code casually, and incorporate any feedback that makes sense.

Applying someone else's convention, even when it's widely accepted, if it doesn't leap off the page at you is a bit of a mistake in my book. First and foremost I need to understand my code without reference to other documentation but at the same time it needs to be generic enough that it's no incomprehensible to someone else in the same field in the same industry.

Jim Ferrans
  • 29,162
  • 12
  • 52
  • 83
Lazarus
  • 38,221
  • 4
  • 39
  • 53
  • 1
    Still, a consistent if slightly unintuitive convention is better than just starting your own convention. People working on a project will learn any consistent convention very fast and soon forget that the functionality isn't quite what might be expected on first glance. – Mr. Boy Dec 08 '09 at 13:29
  • @John, that's exactly what I said. The convention needs to be accepted by the group and if you are working in a company then see if there is a company convention. For company I'm thinking of any group, be it an open source project team or a loose collection of programmers. If everyone just took what was available that almost fit their requirements then I think we'd be sorely lacking in innovation. – Lazarus Jan 08 '10 at 09:17
2

I'd consider the patterns you are using for your system, the naming conventions / cataloguing / grouping of classes of tends to be defined by the pattern used. Personally, I stick to these naming conventions as they are the most likely way for another person to be able to pick up my code and run with it.

For example UserRecordsClerk might be better explained as extending a generic RecordsClerk interface that both UserRecordsClerk and CompanyRecordsClerk implement and then specialise on, meaning one can look at the methods in the interface to see what the its subclasses do / are generally for.

See a book such as Design Patterns for info, it's an excellent book and might help you clear up where you're aiming to be with your code - if you aren't already using it! ;o)

I reckon so long as your pattern is well chosen and used as far as is appropriate, then pretty uninventive straightforward class names should suffice!

Caroline
  • 1,460
  • 3
  • 14
  • 28
  • I have commented on that on Brian Agnew's answer. I don't feel the pattern names make good class names only in some cases (Factory, Strategy) but not in others (Singleton). I want the names to reflect the job of the class not the way how I implemented it. – froh42 Dec 08 '09 at 17:06