mercredi 6 mai 2015

what pattern to choose here?

Consider the following situation:

A CSV file gets generated from some data with lines like this:

011111;1;1000221;014501;100;343;0;0;0,085;8,5;0;0;0,075;7,5;0;0;0;0

There's a lot more fields and fields are added every once in a while. The code generating each line is a function of 240 lines.

Now I want to refactor this code in a way that each column will get its own object with it's own logic encapsulated in every object. It would make adding new columns easier and the code more readable.

But what pattern to use here? Composite or Decorator?

Decorator because there's a basic line already and it could get "decorated" with extra columns. And composite because every line is "composed" of all columns.

What would be a better choice?

Aucun commentaire:

Enregistrer un commentaire