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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:08:38+00:00 2026-05-27T00:08:38+00:00

I believe I do not understand the full purpose of the interfaces. Therefore, I

  • 0

I believe I do not understand the full purpose of the interfaces. Therefore, I am asking an advice on this matter.

I have several tables on my database. Few are: Languages, FrontEndMenus, BackEndMenus…
These tables have different columns, so the C# objects have also different properties (even the FrontEnd and BackEnd menu objects have several different fields)

For performance purposes, they are held on RAM in SINGLETON classes named (LanguageCollection, FrontEndMenuCollection, BackEndMenuCollection)

First of all, all of these objects have definitely 3 methods which are “IsValid”, “Save” and “Remove”.
Normally they are used like:

LanguageItem item1 = new LanguageItem();
item1.IsValid();
item1.Save();
item1.Remove();

FrontEndMenuItem item2 = new FrontEndMenuItem();
item2.IsValid();
item2.Save();
item2.Remove();

//And Same as BackEndMenus class too.. 

And when I want to get one of the objects in the singleton collections, I call them like:

FrontEndMenuItem item = GetInstance.FilterSingleOrDefault(new FrontEndMenuItemArgs{ Id = 14 });

And here is my question:

According to my understanding, in order to make a flexible structre I should use an Interface implementation on these objects classes (FrontEndMenuItem, LanguageItem, BackEndMenuItem)

I did something like:

    public interface IBusinessItem
    {
        bool IsValid();
        OperationResult Remove();
        OperationResult Remove(bool isCommitOnDatabase);
        OperationResult Save();
        OperationResult Save(bool isCommitOnDatabase);
    }

But I’m not sure how I can use it…

Could you give me a little direction on this approach? I’d extremely happy if you could help me by writing very simple codes.


I added as a comment but since it is very important, I’d like to add this part to my existing question as well:

When an update is necessary or insert, the object itself is updated by its fields and then saved. Its like this:

FrontEndMenuItem item2 = new FrontEndMenuItem();
item2.Title = "Some title";
item2.ModuleId = 5;
item2.LinkTypeId = 2;
item2.Save(); //Since its a new item its gonna be saved as new that means INSERT.

Save methods can understand whether its new or not once it has been called from the object itself like item2.Save() so this method will also work when its called by the IBusinessItem interface.

But, what about the fields? In BackEndMenuItem there is no ModuleId field or LinkTypeId

Could there be IBusinessItem.ModuleId = 5 ? If this is the case, should I use an interface, if not, in what situation could I use interfaces on this problem?

Thank you very much,

  • 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-27T00:08:38+00:00Added an answer on May 27, 2026 at 12:08 am

    Basically, the use of an interface is to prevent consuming code from having to know which of these two specific implementations (LanguageItem and FrontEndMenuItem) it is dealing with if it doesn’t have to. All it has to know is that any implementation of IBusinessItem has the list of methods you define.

    Interfaces thus provide “loose coupling”; you don’t have to know what an object IS, you just have to know what it DOES, or more accurately, what you can do to/with it.

    Now, if you somehow must know that a FrontEndMenuItem is a FrontEndMenuItem in your usage, then being able to treat it as an IBusinessItem isn’t going to gain you much. However, I would then question your usage; it looks like both implementations work exactly the same way, so why couldn’t LanguageItem be used in place of a FrontEndMenuItem? There are some good reasons, but there are also some very bad reasons to set it up this way.

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

Sidebar

Related Questions

First of all, I do not believe this belongs on Superuser. This belongs here
Despite working on EE for about 3 weeks now, believe it or not, this
I Believe I'm doing this correctly but it is not getting the stored cookie
Probably not. But still would be nice to have it. Kinda hard to believe
I cannot believe this question has not been asked before! Maybe I do not
I usually do not have difficulty to read JavaScript code but for this one
I know this is not supported in UIData and I understand why, but this
I'm working on a web applications where - believe it or not- the users
I believe it is related to CORBA in some way (I'm not sure). I'm
Not used set_intersection before, but I believe it will work with maps. I wrote

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.