When declaring a FactoryMethod put identifying parameters first.
For example, instead of this:
public Contact createContact(Country countryToBeCovered, String contactName);
do this:
public Contract createContact(String contactName, Country countryToBeCovered);
This is mostly for test code, where you may well be creating several different instances of the same object as part of a test fixture. Placing identifying parameters first helps to distinguish them visually a lot better than if they are at the end (or, worse, buried somewhere in the middle).
Like this:
Like Loading...
Related
Author: Robert Watkins
My name is Robert Watkins. I am a software developer and have been for over 20 years now. I currently work for people, but my opinions here are in no way endorsed by them (which is cool; their opinions aren’t endorsed by me either). My main professional interests are in Java development, using Agile methods, with a historical focus on building web based applications. I’m also a Mac-fan and love my iPhone, which I’m currently learning how to code for.
I live and work in Brisbane, Australia, but I grew up in the Northern Territory, and still find Brisbane too cold (after 22 years here). I’m married, with two children and one cat. My politics are socialist in tendency, my religious affiliation is atheist (aka “none of the above”), my attitude is condescending and my moral standing is lying down.
View all posts by Robert Watkins
Hm… makes perfect sense! Why not submit it to Martin Fowler as a new refactoring? Sure, it is trivial, but so are the tqo refactorings I’ve sent to him!
http://www.refactoring.com