Results 1 to 11 of 11
Thread: "Printer" abstraction
Sep 5, 2005, 13:57 #1
- Join Date
- Sep 2005
- 0 Post(s)
- 0 Thread(s)
What I'm trying to do is wrap up displaying a persons address. In some cases I might want a single line view, in others I might want it multiline. And in others, I might even wawnt it in a <textarea>, thus the multiline needs \n and not <br />.
I originally looked at an Address class and had a "factory" function which returned the appropriate format, but I read in here that this is potentially a smell.
So, I took it to another level, creating an AddressPrinter class. AddressPrinter, AddresssSingleLinePrinter, AddressMultiLinePrinter etc etc. Each class has a getAddressString(), which returns the formatted text.
At code level, Address->print( new Address????Printer() );
Can anyone pass comment; from an OO development perspective am I hitting on good practise, or have I missed the point of decoupling responsibility?