I'm not sure if this is an OCD trait or not, but I find that sometimes I get completely blocked unable to continue what I am doing when naming a class (or function, or namespace etc) that I believe is to be used outside of a given project. An API for example. Or a utility class library.If the naming isn't exactly right (in my mind) I just can't continue...I get stuck trying to come up with the right name. I've tried writing little apps that would use it to see what the names look like but that doesn't seem to help...I know it shouldn't matter, and it's against any programming mindset to assume you'd get it perfect first go...I just feel powerless to it...Any tips/ideas would be greatly appreciated...
Naming classes becomes debilitating
naming;behavior
To my mind the problem you have is not just finding a better way to come up with good names, but dealing with the compulsion to do so. If I'm honest, I recognise a similar trait in myself. Names are important, after all, and I do like a good name for the concepts I'm working on. However, they are not always the most important thing.Here are some of the methods I use to overcome this kind of thing:Recognise that there is no perfect solution, only solutions that are better than others.Put first things first. It is more important to complete a programming assignment than to do it perfectly.Ask other people. We all have our areas where we bog down, but fortunately different people bog down in different places. Perhaps someone else will come up with a good name, or tell you that it really doesn't matter.Set a time limit. Give yourself x minutes to do the thing you get hung up on, then move on.Promise yourself that you'll come back later. Keep a log of things you want to come back to. Lots of these kinds of problems become clearer when you leave them alone for a bit. Either you'll come up with a better name later, or you'll recognise that it really doesn't matter.Recognise that in 100 years time, nobody will care anyway.Do the opposite. Give a class a really bad name, and see what happens. This will either confirm the need to spend time on better names, or show you how little it really matters. Also, this will help you break out of the obsessive mind set.Pray. This often works for me.Value yourself apart from what you do. Break away from the idea that your own value comes from delivering perfection. When we recognise that we have intrinsic worth, quite apart from our jobs, we feel less shame when we don't measure up to our own standards.Make up new words and use them to name your classes, or just re-purpose old ones. Programming is a creative process, and sometimes the ideas we capture are new ideas. New ideas need new names. EmployeeTransmogrifier is a perfectly valid name for a class.Consider that you're trying to solve the wrong problem. For example, it isn't a good idea to write an API without a very clear idea of what the caller's needs are. If you solve this problem, your naming problem might be a lot easier.Have lunch. Lunch is always good.