Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you should design this by interface contract.</p> <p>I would make your walls, robots and sensors be implementations of various 'things' the UI needs to know about. Only those interfaces should be shared between the UI and your Model.</p> <p>For example, Robot, Sensor should implement an interface called Printable:</p> <pre><code>public interface Printable { Shap getShape(); } </code></pre> <p>Wall should implement an extended interface PrintableTexture</p> <pre><code>public interface PrintableTexture extends Printable { Texture getTexture(); } </code></pre> <p>You could also create and implement data provider type interfaces for angle, direction, etc.</p> <p>For example:</p> <pre><code>public interface RangeProvider { Range getRange(); } public interface DirectionProvider { Direction getDirection(); } public interface SensorProvider { Sensor[] getSensors(); } </code></pre> <p>The main point is that the 'printing' code would then check for what interfaces are implemented by the Printable object (or list of Printable objects) that has been passed to the it and react appropriately.</p> <p>Looking at your comments, I think that PrintableRobot, PrintableWall, etc is a misunderstanding of the fundamental concept of what an interface is. An interface should be more about 'what something provides or how you can use it' versus a concrete implementation of how this is achieved. By putting Robot, Wall, etc in Printable you are giving an indication of implementation.</p> <p>This aside, have you considered the <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow">Visitor Pattern</a>?? You could have each entity implement the accept part of the visitor pattern and have your printing code be a special implementation that only takes what it needs out of a deeper knowledge of what each entity does.... It's not what I would do, but it may suit you...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload