Conditional on WebClient
- by CarryFlag
Given:
thin client (JS)
model
services
client use services. services use model.
Model consists of (for sample):
Rect
Circle
...
Ellipse
services:
class CanvasProviger {
public Canvas getCanvas() {
return new Canvas();
}
}
model:
class Canvas ... {
private List < Figure > figures = new List < Figure >;
...
}
class Circle extends Figure {
private int x, y, r;
}
class Rect extends Figure {
private x, y, w, h;
}
client:
...
var figure = MyJSRPCImpl.getCanvas().nextFigure();
if(figure == JSLocalModel.Rect) {
drawRect(figure);
} else
if(figure == JSLocalModel.Circle) {
drawCircle(figure);
}
...
How else can do way conditional?
In rich client I used pattern Visitor.
// my bad english, I know =(