Conditional on WebClient

Posted by CarryFlag on Stack Overflow See other posts from Stack Overflow or by CarryFlag
Published on 2012-03-25T17:25:46Z Indexed on 2012/03/25 17:29 UTC
Read the original article Hit count: 146

Filed under:
|
|
|

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 =(

© Stack Overflow or respective owner

Related posts about design

Related posts about conditional