###Questions:
Questions:
###The Code:
The Code:
###Questions:
###The Code:
Questions:
The Code:
Coding on Point interfaces/superclasses notinstead of implementations
###Questions:
- Should I be using
Point2DAdvanced
orPoint2D.Double
in the the methods ofMedianPoint
(like JavaRDD<>, the 2 private methods, the variables)? Same goes forFlagPointPairProducer
. - Should I be using
MedianPoint
orPoint2D.Double
in theFlagPointPairProducer
class? - Should I store the
MedianPoint
from the static method in aMedianPoint
orPoint2D.Double
?
###The Code:
First off I have a MedianPoint
class which extends Point2D.Double
. This class is responsible for outputting a median point out of a collection of points (for now only an RDD).
The code review I need now is this:
- Should I be using
Point2DAdvanced
orPoint2D.Double
in the the methods ofMedianPoint
(like JavaRDD<>, the 2 private methods, the variables)? Same goes forFlagPointPairProducer
. - Should I be using
MedianPoint
orPoint2D.Double
in theFlagPointPairProducer
class? - Should I store the
MedianPoint
from the static method in aMedianPoint
orPoint2D.Double
?
Coding on interfaces/superclasses not implementations
First off I have a MedianPoint
class which extends Point2D.Double
. This class is responsible for outputting a median point out of a collection of points (for now only an RDD).
The code review I need now is this:
- Should I be using
Point2DAdvanced
orPoint2D.Double
in the the methods ofMedianPoint
(like JavaRDD<>, the 2 private methods, the variables)? Same goes forFlagPointPairProducer
. - Should I be using
MedianPoint
orPoint2D.Double
in theFlagPointPairProducer
class? - Should I store the
MedianPoint
from the static method in aMedianPoint
orPoint2D.Double
?
Coding on Point interfaces/superclasses instead of implementations
###Questions:
- Should I be using
Point2DAdvanced
orPoint2D.Double
in the the methods ofMedianPoint
(like JavaRDD<>, the 2 private methods, the variables)? Same goes forFlagPointPairProducer
. - Should I be using
MedianPoint
orPoint2D.Double
in theFlagPointPairProducer
class? - Should I store the
MedianPoint
from the static method in aMedianPoint
orPoint2D.Double
?
###The Code:
First off I have a MedianPoint
class which extends Point2D.Double
. This class is responsible for outputting a median point out of a collection of points (for now only an RDD).
Code requested for Point2DAdvanced
:
public class Point2DAdvanced extends Point2D.Double implements Serializable {
public Point2DAdvanced(double x, double y) {
super(x, y);
}
public boolean dominates(Point2D.Double point) {
return (x <= point.getX() && y < point.getY())
|| (y <= point.getY() && x < point.getX());
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append('(').append(x).append(", ").append(y).append(')');
return builder.toString();
}
public static Point2DAdvanced fromTextLine(String textLine, String delimiter) {
textLine = textLine.trim();
String[] lineArray = textLine.split(delimiter);
double x = java.lang.Double.parseDouble(lineArray[0]);
double y = java.lang.Double.parseDouble(lineArray[1]);
return new Point2DAdvanced(x, y);
}
}
Code requested for Point2DAdvanced
:
public class Point2DAdvanced extends Point2D.Double implements Serializable {
public Point2DAdvanced(double x, double y) {
super(x, y);
}
public boolean dominates(Point2D.Double point) {
return (x <= point.getX() && y < point.getY())
|| (y <= point.getY() && x < point.getX());
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append('(').append(x).append(", ").append(y).append(')');
return builder.toString();
}
public static Point2DAdvanced fromTextLine(String textLine, String delimiter) {
textLine = textLine.trim();
String[] lineArray = textLine.split(delimiter);
double x = java.lang.Double.parseDouble(lineArray[0]);
double y = java.lang.Double.parseDouble(lineArray[1]);
return new Point2DAdvanced(x, y);
}
}