How much time do you spend thinking of good identifier names?
Sometimes I find myself getting stuck on a project just because I can't think of a good name for a new class which implements some new feature.
How do you deal with this problem? One way I can think of is assigning template names('NewFeature1'). It isn't that big of a problem with modern ide's which provide one click renames.
6 comments
[ 0.23 ms ] story [ 23.4 ms ] threadI will note that I usually find a better name after it sits there for a while and starts to not make sense. Also after hearing complaints from other programmers about "why is this called x when it should be y :)".
Nondescriptive "template names" (your "NewFeature1") are a huge red flag signaling unpreparedness.
While there is pressure to "just code it" that comes from methodologies like Agile or from just having an intense workload, the spontaneity should be happening in the context of professional expertise and good insight.
Do you have a sense of what algorithms are relevant? What traditional patterns? What data is being represented? What transforms are being applied? What libraries and services are being utilized? You don't need an 40 page architecture to start coding, but you'll usually have answers to all those questions somewhere in mind. And your identifiers should usually be pretty obvious when you do.
Also, worrying about the perfect name at the start is extremely premature optimization - often/usually the purpose of things changes, or you realize it wasn't what you thought it was, or you come to understand it better, or it gets split or combined etc.
After that things will be easier and faster.