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

  • SEARCH
  • Home
  • 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 8026145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:23:34+00:00 2026-06-04T23:23:34+00:00

Trying to create a simple noddy example so that I can build my next

  • 0

Trying to create a simple noddy example so that I can build my next project using fluent interfaces.
I need to provide the user of my dll with an intuitive step by step way of building a class.

Question.
I would like the user only to see Initialise when the first start then step1 then step2
and then end?How can I do it?

This is my attempt which As soon as you put the “.” you see everything,then they hide.

class Program
{
    static void Main(string[] args)
    {
        IEnd builder = new StepBuilder()
            .Initialize()
            .LoadStuff()
            .Validate()
            .End();

    }
}
 public class StepBuilder : IInitialize,
                              IStep1,
                              IStep2,
                              IStep3,
                              IEnd
 {
     public IStep1 Initialize()
     {
         return this;
     }

     public IStep2 LoadStuff()
     {
         return this; ;
     }

     public IStep3 Validate()
     {
         return this;
     }

     public IEnd End()
     {
         return this;
     }

     public bool Save()
     {
         return true;
     }
 }

public class Step
{
    public string Name { get; set; }
    public string Category { get; set; }
    public decimal Price { get; set; }
}

public interface IInitialize
{
    IStep1 Initialize();
}

public interface IStep1 
{
    IStep2 LoadStuff();
}

public interface IStep2 
{
    IStep3 Validate ();
}

public interface IStep3
{
    IEnd End();
}
public interface IEnd 
{
    bool Save();
}

}

any suggestions or good link on building progressive fluent interfaces?

  • 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-04T23:23:36+00:00Added an answer on June 4, 2026 at 11:23 pm

    You could turn Initialize() into a static factory method, and make the constructor private. Then your creation code would look like:

        IEnd builder = StepBuilder.Initialize()
             .LoadStuff()
             .Validate()
             .End(); 
    

    A second idea, would be to make the interface implementations explicit. Then you’d only see the methods for the interface you’re dealing with at the time.

    Update

    Here’s example code for both methods. The interfaces are exactly the same as in your question.

    Example with factory method:

    class Program
    {
        static void Main(string[] args)
        {
            IEnd builder = StepBuilder
                .Initialize()
                .LoadStuff()
                .Validate()
                .End();
    
        }
    }
    
    public class StepBuilder : IInitialize,
                                 IStep1,
                                 IStep2,
                                 IStep3,
                                 IEnd
    {
        private StepBuilder()
        {
        }
    
        public static IStep1 Initialize()
        {
            var builder = new StepBuilder();
            //do initialisation stuff
            return builder;
        }
    
        public IStep2 LoadStuff()
        {
            return this; 
        }
    
        public IStep3 Validate()
        {
            return this;
        }
    
        public IEnd End()
        {
            return this;
        }
    
        public bool Save()
        {
            return true;
        }
    }
    

    Example with explicit interface implementations:

    class Program
    {
        static void Main(string[] args)
        {
            IEnd builder = new StepBuilder()
                .Initialize()
                .LoadStuff()
                .Validate()
                .End();
    
        }
    }
    
    public class StepBuilder : IInitialize,
                                 IStep1,
                                 IStep2,
                                 IStep3,
                                 IEnd
    {
        public IStep1 Initialize()
        {
            return this;
        }
    
        public IStep2 IStep1.LoadStuff()
        {
            return this; 
        }
    
        public IStep3 IStep2.Validate()
        {
            return this;
        }
    
        public IEnd IStep3.End()
        {
            return this;
        }
    
        public bool IEnd.Save()
        {
            return true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple custom validator for my project, and I can't
I am trying to create a simple MongooseJS example program that gets a list
Trying to create a simple regular expression that can extract numbers(between 7 - 14)
trying to create a simple slider for an input. Using a survey gem that
I'm studying webrat and cucumber and trying to create simple example. Here is my
Im trying to create a simple pan and zoom app using silverlight 4, but
I'm trying to create a simple example of an editable gridview, and for some
I am trying to create a simple Automator droplet that will take the style.less
Just trying to create a simple method that counts up 1 on the tally
Im trying to create a simple loop that creates 50 buttons, adds them to

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.