Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:54:47+00:00 2026-06-07T06:54:47+00:00

I have builder: public abstract class ScriptBuilder { public void buildScript() { this.commandList =

  • 0

I have builder:

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<String> getScript() {
        return commandList;
    }
}

Implementation:

public class StandardScriptBuilder extends ScriptBuilder{
…
}

I need to construct a new builder, which implements the new interface. This new interface is based on the interface ScriptBuilder:

class NewScriptBuilder extends StandardScriptBuilder{
    public void buildNewCommand(TouchPoint startTouchPoint, TouchPoint endTouchPoint) {
        buildTouchDownCommand(startTouchPoint);
        buildSynchronizationCommand();
        buildTouchDownCommand(endTouchPoint);
    }
    …
}

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:

ScriptBuilder builder = new NewScriptBuilder();
…
builder.buildNewCommand;

If there is no solution, it is normal to use?:

((NewScriptBuilder)builder).buildNewCommand;

Thx.


I mean: For example, we can use Decorator pattern:

public abstract class Decorator extends ScriptBuilder {...} ...

public class OahDecorator extends Decorator {
...
    public void buildNewCommand() {
    ...
    }
}

it is a normal organization of code, or choose a different pattern is?
task – adding new methods in builder.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:54:48+00:00Added an answer on June 7, 2026 at 6:54 am

    If you want a class to implement multiple behaviors, you should have it implement multiple interfaces. It’s generally bad practice to code against classes – you sould instead code against interfaces. The difference is subtle, but still quite relevatn and real.

    When you find yourself casting explicitly, it usually means that your interfaces are not quite suitable for the task. The goal is to have the client code know as little as possible about the actual type of the objects that it is processing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this builder that runs a buildClass method which should be public,
I have something like this public class Person { public Country {get; set;} }
I have an interesting problem. Consider this class hierachy: class Base { public: virtual
I'm trying to have an abstract base class for some builder classes so I
I have the following two routines in Flash Builder: public function getData():void { httpService
I am new to this, I have this: public Builder id (String val) {
I have a class which I can write like this: class FileNameLoader { public:
I have a form builder class which inherits from AbstractType and I need to
currently i have a module builder. in this condensed version of the script, a
I have the following code: builder = gtk.Builder() builder.add_from_file(glade_file) builder.get_object(windowMain).show() socket = gtk.Socket() socket.add_id(long(OpenGLWindowID))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.