GIScience / GIScience/measures-rest

Proposal for decoupling serving and computing of measures

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
10
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently, the abstract class `Measure` is a representation of a JAX-RS resource. In order to implement a concrete measure, one has to extend `Measure` by a new class `MyMeasure`and to override its `compute` method. Hence a concrete measure is a concrete resource.

In terms of modularity, it would be preferable to decouple the measure computation and its serving as a resource. My proposal is to restructure the implementation as follows:

```java
public interface Measure {
SortedMap compute([...]);
}

public class MeasureResource {
private Measure measure;

public MeasureResource(Measure m, [...]) { ... };

/* optionally */
SortedMap compute([...]) {
return measure.compute([...]);
}
}
```
A concrete measure `MyMeasure` would implement the interface `Measure` and would be bound via the constructor `MeasureResource` to a concrete resource. Optionally, the class `MeasureResource` could implement a method `compute` that just delegates the computation to the computation to the underlying measure.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.