« "De"-testable design - lovely | Main | Reducing the size of Checkstyle logs »

Coding Convention: Put identifying parameters first

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).

Comments (1)

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

Post a comment


About

This page contains a single entry from the blog posted on March 10, 2005 10:16 AM.

The previous post in this blog was "De"-testable design - lovely.

The next post in this blog is Reducing the size of Checkstyle logs.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.35