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 875931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:21:11+00:00 2026-05-15T11:21:11+00:00

Lets say i have the following set of interfaces…. public interface IStart { void

  • 0

Lets say i have the following set of interfaces….

 public interface IStart
        {
            void M1();
            bool IsWorking { get; }
        }

    public interface IStartStop : IStart
        {
            void M2();
                   event EventHandler DoM1;
            event EventHandler DoM2;
        }
    public interface IPreferencesReader : IStartStop, IDisposable
        {
            string CustomColumnDefinition       {get;}
                bool UsePricelevelDetection  {get;}
            void InitializePreferences();
        }

Now, if i want to implement IPreferencesReader my class would look like below. This is an example of a fat interface, where i
will have to provide implementation of methods that i may not need in all scenarious.

public class PreferencesReaderBase : IPreferencesReader
    {
        public void M1()
        {
            throw new NotImplementedException();
        }

        public bool IsWorking
        {
            get { throw new NotImplementedException(); }
        }

        public void M2()
        {
            throw new NotImplementedException();
        }

        public event EventHandler DoM1;
        public event EventHandler DoM2;

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        public string CustomColumnDefinition
        {
            get { throw new NotImplementedException(); }
        }

        public bool UsePricelevelDetection
        {
            get { throw new NotImplementedException(); }
        }

        public void InitializePreferences()
        {
            DoSomeInitialization();
        }
    }

Can i apply any pattern for this scenario so as to refactor it?

EDIT: I can not do without this hierarchy, as in can not remove any of the interfaces.

Thanks for your interest.

  • 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-05-15T11:21:11+00:00Added an answer on May 15, 2026 at 11:21 am

    Use an “Adapter” pattern – not the one that wikipedia identifies, so maybe my terminology is non-standard – but like Java’s MouseAdapter:

    An abstract adapter class for
    receiving mouse events. The methods in
    this class are empty. This class
    exists as convenience for creating
    listener objects.

    …

    Extend this class to create a
    MouseEvent listener and override the
    methods for the events of interest.
    (If you implement the MouseListener
    interface, you have to define all of
    the methods in it. This abstract class
    defines null methods for them all, so
    you can only have to define methods
    for events you care about.)

    Just write an abstract class that holds empty implementations of all the necessary interfaces; subclass it and override the methods that are relevant to your needs.

    The full fat interface still exists; it’s still implemented (via inheritance) by your class – but the code of your class will only include what’s important.

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

Sidebar

Related Questions

Lets say i have the following code private Func<T> _method; public void SetExecutableMethod<T>(Func<T> methodParam)
Lets say I have the following class: public class Provider { ... public sealed
Let's say I have 2 interfaces defined like so: public interface ISkuItem { public
lets say I have the following public class A { private string _someField; public
Lets say I have query that gets following List Item Objects with Set of
Lets say I have the following class structure in my data access layer: interface
Lets say we have the following set of numbers representing values over time 1
Lets say we have the following document structure: class BlogPost { [MongoIdentifier] public Guid
Lets say I have the following: public class MyObject { [Bindable] public var foo:int
Lets say I have the following class public class Test { public int prop1

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.