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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:09:14+00:00 2026-05-14T23:09:14+00:00

imagine there are two interfaces arranged via composite pattern, one of them has a

  • 0

imagine there are two interfaces arranged via composite pattern, one of them has a dispose method among other methods:

interface IComponent extends ILeaf {
    ...
    function dispose() : void;
}

interface ILeaf {
    ...
}

some implementations have some more things in common (say an id) so there are two more interfaces:

interface ICommonLeaf extends ILeaf {
    function get id() : String;
}

interface ICommonComponent extends ICommonLeaf, IComponent {
}

so far so good. but there is another interface which also has a dispose method:

interface ISomething {
    ...
    function dispose() : void;
}

and ISomething is inherited by ICommonLeaf:

interface ICommonLeaf extends ILeaf, ISomething {
    function get id() : String;
}

As soon as the dispose method is invoked on an instance which implements the ICommonComponent interface, the compiler fails with an ambiguous reference error because ISomething has a method called dispose and ILeaf also has a dispose method, both living in different interfaces (IComponent, ISomething) within the inheritace tree of ICommonComponent.

I wonder how to deal with the situation if

  • the IComponent, the ILeaf and the ISomething can’t change.
  • the composite structure must also work for for the ICommonLeaf & ICommonComponent
  • implementations and the ICommonLeaf & ICommonComponent must conform to the ISomething type.

this might be an actionscript-3 specific issue. i haven’t tested how other languages (for instance java) handle stuff like this.

  • 1 1 Answer
  • 3 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-14T23:09:15+00:00Added an answer on May 14, 2026 at 11:09 pm

    You are searching for a solution to the Diamond Problem. C# has an approach to this but basically I would factor the method “dispose” out of your interfaces and create a new “IDisposable”.

    If the same name like “id” is used twice, it looks like a problem in your code with an ambiguous name. We started to add prefixes to properties and methods. Imagine you have a property “name” that belongs to two different things. Like the “displayName” and the “uniqueName”.

    This also helps with auto completion. If a DisplayObject is an ILayoutObject and yout type displayObject.layout you get everything layout releated.

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

Sidebar

Related Questions

There is one thing that I do not understand... Imagine you have a text
Imagine an object you are working with has a collection of other objects associated
Imagine you've been given two System.Type's and you want to determine if there is
I imagine there are two options: Build a parallel ANT script and bypass the
I imagine there are many of you out there who have developed an application
On C# 3.0 and .NET 3.5, imagine there's an interface: public interface INameable {
Is there any way to check if a particular plugin is available? Imagine that
I have what I imagine to be a pretty standard web-interface. There are 4
Given a fairly complex object with lots of state, is there a pattern for
Imagine a maven project with 3 modules, an interface module and two different implementations

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.