lundi 26 octobre 2015

Service classes or no service classes?

I am coding a C# WinForms application, and I have a design question in regards to whether I should use Service Classes to generate some output, or if each object should contain all the required functions within each single object, and these functions are called to generate some output.

Either way, the output will be exactly the same. The output is a text file.

Here is the situation:

I have an object that has a lot of user data in the form of multiple custom objects. I am then creating multiple types of output objects. Preview objects, output to directory objects are two examples. Each of these output objects handle the data and place this data in a suitable output form. The data is then finally outputted as a string.

Should I use a service class to create the suitable output, where the service class has multiple functions that create the correct output, or should each of the objects that I am using have their own functions that generate the data in the correct output format?

Is there a design pattern that I should be aware of in making this decision, and if so, can someone please point me in the correct direction for this? Also, I am keen to hear on peoples thoughts of whether it is good practice to use service classes, or nested object functions to generate output.

Thanks.

Aucun commentaire:

Enregistrer un commentaire