Design question: does the Phone dial the PhoneNumber, or does the PhoneNumber dial itself on the Phone?

admin

Administrator
Staff member
This is re-posted from something I posted on the DDD Yahoo! group.

All things being equal, do you write phone.dial(phoneNumber) or phoneNumber.dialOn(phone)? Keep in mind possible future requirements (account numbers in addition to phone numbers, calculators in addition to phones).

The choice tends to illustrate how the idioms of Information Expert, Single Responsibility Principle, and Tell Don't Ask are at odds with each other.

phoneNumber.dialOn(phone) favors Information Expert and Tell Don't Ask, while phone.dial(phoneNumber) favors Single Responsibility Principle.

If you are familiar with Ken Pugh's work in Prefactoring, this is the <a href="http://moffdub.wordpress.com/2008/09/10/the-spreadsheet-conundrum/" rel="noreferrer">Spreadsheet Conundrum</a>; do you add rows or columns?