G
Gabriel Lozano-Morán
Assume that you have a Document class that you want to persist. Which
solution would be better and what are the advantages/disadvantages of each
approach?
Document doc = new Document();
1)
doc.Persist(PersistType.CsvDelimited);
2)
CsvPersister persister = new CsvPersister(Document);
persister.Persist();
I would go for solution 1 because the the Persist() operation is a
responsibility of the Document. But several of my coworkers will go for
solution 2 without arguing about it. Personally I find solution 2 a good
solution if you want to use the same persister for several different types
like the XmlSerializer class.
If you go for solution 2 where do you draw the line? I mean you could then
write a class for each public operation of the document?
I appreciate any feedback
Gabriel
solution would be better and what are the advantages/disadvantages of each
approach?
Document doc = new Document();
1)
doc.Persist(PersistType.CsvDelimited);
2)
CsvPersister persister = new CsvPersister(Document);
persister.Persist();
I would go for solution 1 because the the Persist() operation is a
responsibility of the Document. But several of my coworkers will go for
solution 2 without arguing about it. Personally I find solution 2 a good
solution if you want to use the same persister for several different types
like the XmlSerializer class.
If you go for solution 2 where do you draw the line? I mean you could then
write a class for each public operation of the document?
I appreciate any feedback
Gabriel