lundi 29 avril 2019

The way to design structure of classes

I have very simple structure of classes. Class B and C inheriting from A. The functionality is similar in the case of some functions and properties. Class B and C has different processing of the data but the classes have the same output (the function creating the output is inside the A class). Example of the structure: enter image description here

Now I need to extend the functionality. I need to add the option for a little differences in processing and the outputting of the data (class X). This option is managed by configuration file so I want keep the old way of the downloading, processing and outputting the data, e.g.:

  1. option 1 - download the data without threads using the old way processing and output
  2. option 2 - download the data without threads using the new way processing and output
  3. option 3 - download the data with threads using the old way processing and output
  4. option 4 - download the data without threads using the new way processing and output

I am not sure how to implement combination of the new processing and outputting the data. I need combination of Class B and X (BX) and Class C and X (CX). I think about these options:

  1. The easiest way but the worst - duplicating some functions in the class B and class A.
  2. Keep the classes A and B and add the combination of BX and AX classes.
  3. Rewrite the classes A and B only for downloading the data. Then add classes for processing the data and then add classes for outputting the data. All classes will sharing the objects. Looks like the best option but with the most work to do.

Is there any better option (e.g. design pattern or something like this) how to extend the classes with the cleanest way?

Aucun commentaire:

Enregistrer un commentaire