I am looking for a good naming convention for methods (and variables to a lesser degree). Let's say you have some factory class in a meta programming or reflection framework and the methods are related to java's primitive types.
// dumb example
public class WrapperFactory {
// create byte wrapper
public MyWrapper byte(byte param) { ... }
// create int wrapper
public MyWrapper int(int param) { ... }
}
From a readability point, I'd like to have reasonably short method names. Unlike the example shown, method signatures for different types may be the same, so having just a create(...)-method with a bunch of overloads is impossible.
From the context of the methods (they are in a WrapperFactory after all) its clear that they will produce a Wrapper. So anything like byteWrapper() (or even more verbose createByteWrapper()) seems to be completely redundant.
Any suggestions for short and concise method names?
Edit: The general tendency seems to be that a method with overloads is most common, it would work for most of my factory methods, but there are currently four createXXXWrapper(...) with identical signatures that create wrappers of different behavior (but the same general type). So to be consistent for all types, I currently favor the prefixXXX() naming suggestion. What prefix would be best (wrap is not one of my favorites, there are other factories which create different objects that are not functionally not wrappers). So I'd like to have generic prefix like newX(...), createX(...) or getX(...).
In this case, I'd recommend wrapByte
and wrapInt
, or maybe just overloaded create
methods.