BgeeDB / bgee_apps

Source code of the Java Bgee applications
https://www.bgee.org/
Creative Commons Zero v1.0 Universal
2 stars 1 forks source link

Reorganize class inheritance for `GenerateDownloadFile` #10

Open fbastian opened 4 years ago

fbastian commented 4 years ago

In GitLab by @fbastian on Jul 14, 2015, 13:42

The classes in org.bgee.pipeline.expression.downloadfile have a problem of redundancy/inappropriate inheritances.

For instance, classes generating multi-species download files do not provide a list of species IDs to the constructor of GenerateDownloadFile, certainly it should.

The first task to fix this issue is to list all the problems related to these badly designed inheritances.

fbastian commented 4 years ago

In GitLab by @fbastian on Jul 14, 2015, 13:49

List of problems: (to be completed)

fbastian commented 4 years ago

In GitLab by @vrechdelaval on Jul 15, 2015, 16:29

List of problems (next part):

fbastian commented 4 years ago

In GitLab by @fbastian on Jul 16, 2015, 13:15

Updated to priority high, because it doesn't make sense to address other issues using badly designed classes.

Updated to effort high because I have currently no idea how hard it is to refactor these classes :p

fbastian commented 4 years ago

In GitLab by @fbastian on Jul 16, 2015, 13:50

So, the general problem is that we would need double inheritances, which is not possible in Java: there would be a BaselineExpression/DiffExpression inheritance, and a SingleSpecies/MultiSpecies inheritance.

And we would like to have something like:

Actually, from the problems listed in this issue, it seems that only methods not using internal attributes of the classes are affected. So, it seems possible to implement all of them as default methods in interfaces, as we have moved to Java 8. And we could then use the pattern described above.

First, we need to list the default methods that should go in each of the four interfaces:

Parent abstract class of all classes generating download files:

fbastian commented 4 years ago

In GitLab by @fbastian on Jul 16, 2015, 14:13

About redundant fields in Beans, maybe there is nothing we can do. Note that a parent Bean could have fields not used by all the subclasses (and that it is not mandatory for a subclass to use all fields from its parent).

For instance, see org.bgee.pipeline.annotations.SimilarityAnnotation.CuratorAnnotationBean, extending RawAnnotationBean, but actually never using any of the 'label' fields defined in RawAnnotationBean and AnnotationBean.

This is even less of an issue, as we can define CellProcessors making sure that the fields not supposed to be used are never used.

fbastian commented 4 years ago

In GitLab by @fbastian on Oct 14, 2015, 23:09

Changed to priority medium, because I feel like the multi-specis present/absent expression files are going to use a completely different mechanism (based on bgee-core)