Right or Wrong Way To Do This?
From: Carl Revell (no.spam_at_no.spam.com)
Date: 10/16/03
- Next message: Boogie El Aceitoso: "Trouble with factory pattern"
- Previous message: Steve Haigh: "Re: One-to-many but also many-to-one"
- Next in thread: Doc O'Leary: "Re: Right or Wrong Way To Do This?"
- Reply: Doc O'Leary: "Re: Right or Wrong Way To Do This?"
- Reply: Martin Fowler: "Re: Right or Wrong Way To Do This?"
- Reply: H. S. Lahman: "Re: Right or Wrong Way To Do This?"
- Reply: Uncle Bob (Robert C. Martin): "Re: Right or Wrong Way To Do This?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 16 Oct 2003 10:49:45 +0100
I have a simple business object representing a manufactured item. It has an
identifying member variable from which I need to provide currently two
different representations but maybe more at a later date.
For example.
- m_ProductId: 1234ABC999
+ GetId() returns 1234ABC
+ GetId() returns 999
Later, GetId() might need to return 1234DDMMYYYY (where DDMMYYYY are day,
month and year)
Is it best to create a single public method GetId() say, which accepts
several parameters (maybe from an enumerated list) like this...
Enum IdType (idt7Digit, idt3Digit, idt4PlusDate)
And then call GetId(idt7Digit) or GetId(idt4PlusDate) and so on to return
the required formatted Id?
OR
Create different methods for each type of formatted Id, thus
Get7DigitId()
Get3DigitId()
Get4PlusDateId()
I figure separate methods would be required if the return type was different
for some returned Id formats, but assuming a string-type is always returned
is one way better than another or is there a third, preferred option?
Thanks,
Carl
- Next message: Boogie El Aceitoso: "Trouble with factory pattern"
- Previous message: Steve Haigh: "Re: One-to-many but also many-to-one"
- Next in thread: Doc O'Leary: "Re: Right or Wrong Way To Do This?"
- Reply: Doc O'Leary: "Re: Right or Wrong Way To Do This?"
- Reply: Martin Fowler: "Re: Right or Wrong Way To Do This?"
- Reply: H. S. Lahman: "Re: Right or Wrong Way To Do This?"
- Reply: Uncle Bob (Robert C. Martin): "Re: Right or Wrong Way To Do This?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]