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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:41:50+00:00 2026-06-02T02:41:50+00:00

I am writing a library and I want to have an interface public interface

  • 0

I am writing a library and I want to have an interface

public interface ISkeleton
{
    IEnumerable<IBone> Bones { get; }
    void Attach(IBone bone);
    void Detach(IBone bone);
}

The Attach() and Detach() implementation actually should be the same for every ISkeleton. Thus, it could essentially be:

public abstract class Skeleton
{
    public IEnumerable<IBone> Bones { get { return _mBones; } }

    public List<IBone> _mBones = new List<IBone>();

    public void Attach(IBone bone)
    {
         bone.Transformation.ToLocal(this);
         _mBones.add();
    }

    public void Detach(IBone bone)
    {
        bone.Transformation.ToWorld(this);
         _mBones.Remove(bone);
    }
}

But C# doesn’t allow multiple inheritance. So among various issues, users have to remember to inherit from Skeleton every time they want to implement Skeleton.

I could use extension methods

public static class Skeleton
{   
    public static void Attach(this ISkeleton skeleton, IBone bone)
    {
         bone.Transformation.ToLocal(skeleton);
         skeleton.Bones.add(bone);
    }

    public static void Detach(this ISkeleton skeleton, IBone bone)
    {
        bone.Transformation.ToWorld(this);
         skeleton.Bones.Remove(bone);
    }
}

But then I need to have

public interface ISkeleton
{   
    ICollection<IBone> Bones { get; }
}

Which I do not want, because it is not covariant and users can bypass the Attach() and Detach() methods.

Question: Must I really use an abstract Skeleton class or are there any or tricks and methods?

  • 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-02T02:41:51+00:00Added an answer on June 2, 2026 at 2:41 am

    I would make bones a special type that implements IEnumerable<T>. That way it doesn’t violate the single responsibility principle.

    public interface ISkeleton
    {
        AttachableEnumerable<IBone> Bones { get; }
    }
    
    public class AttachableEnumerable<T> : IEnumerable<T>
    {
        // implementation needed.
        void Attach(T item);
        void Detach(T item);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing a library for my project (for now I am using
I am writing a library that will provide a collection of public types to
I'm writing a bignum library, and I want to use efficient data types to
I'm writing a library that needs to have some code if a particular library
I'm developing an app in C++/CLI and have a csv file writing library in
I want to have an application writing out information at the same time that
I'm writing a library that contains some hash functions. I want one of the
I'm writing a class library that will offer some asynchronous processing, and want to
as stated in the title, I want to have my old C++ library working
I'm writing a game in c++ using boost.python library as script system. I have

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.