Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilder pattern. Expansion interface
    primarykey
    data
    text
    <p>I have builder:</p> <pre><code>public abstract class ScriptBuilder { public void buildScript() { this.commandList = Lists.newArrayList(); } public abstract void buildSleepCommand(long time); public abstract void buildSynchronizationCommand(); public abstract void buildTouchDownCommand(TouchPoint touchPoint); public abstract void buildTouchUpCommand(); public List&lt;String&gt; getScript() { return commandList; } } </code></pre> <p>Implementation:</p> <pre><code>public class StandardScriptBuilder extends ScriptBuilder{ … } </code></pre> <p>I need to construct a new builder, which implements the new interface. This new interface is based on the interface ScriptBuilder:</p> <pre><code>class NewScriptBuilder extends StandardScriptBuilder{ public void buildNewCommand(TouchPoint startTouchPoint, TouchPoint endTouchPoint) { buildTouchDownCommand(startTouchPoint); buildSynchronizationCommand(); buildTouchDownCommand(endTouchPoint); } … } </code></pre> <p>Is there any pattern that will extend the existing builder interface and keep builder advantage? I mean, if we extend the interface, we can not do:</p> <pre><code>ScriptBuilder builder = new NewScriptBuilder(); … builder.buildNewCommand; </code></pre> <p>If there is no solution, it is normal to use?:</p> <pre><code>((NewScriptBuilder)builder).buildNewCommand; </code></pre> <p>Thx.</p> <hr> <p>I mean: For example, we can use Decorator pattern:</p> <pre><code>public abstract class Decorator extends ScriptBuilder {...} ... public class OahDecorator extends Decorator { ... public void buildNewCommand() { ... } } </code></pre> <p>it is a normal organization of code, or choose a different pattern is? task - adding new methods in builder.</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. 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