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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:36:57+00:00 2026-05-11T15:36:57+00:00

I have a business object collection (representing data from the database) that inherits from

  • 0

I have a business object collection (representing data from the database) that inherits from Collection and has a static method that calls a stored proc and then populates its properties with the data returned.

My question is; is it wrong to inherit from Collection as it doesnt really extend the class? or would it be better to not inherit from anything but instead maintain a private variable that is of type Collection?

  • 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. 2026-05-11T15:36:57+00:00Added an answer on May 11, 2026 at 3:36 pm

    It is hard to give an answer to this without seeing a lot more detail about what you are trying to do. However, I would not normally inherit from Collection as it does not really give enough virtual methods to override. This can make altering the behaviour of your class a little tricky in the future.

    The trouble with inheritance is that if you use it you will be stuck with the Collection base class’s behaviour forever more, or face a complex refactoring. For example, you may want to add filtering, searching and sorting operations at which point you will need to switch to List from Collection. You may even want to do data binding where you will need a BindingList instead of a Collection.

    A different plan would be to inherit from ICollection or better still IList<T> and then delegate to a private Collection member. This gives you maximum control and allows you to alter the internal representation of your class without affecting the public interface. The trouble with this is that it takes longer to develop you classes.

    Therefore, what you are facing is a trade off between faster development and future flexibility, and as I said at the start it is a bit difficult to judge which way to go from the information given in the original post.

    PS: To make an IList<T> implementation read-only, simply return true from IsReadOnly and then throw a NotSupportedException from all the methods that alter the list.

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

Sidebar

Ask A Question

Stats

  • Questions 156k
  • Answers 156k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's a huge topic and you can read articles all… May 12, 2026 at 10:52 am
  • Editorial Team
    Editorial Team added an answer We have been using the QtSql classes for a couple… May 12, 2026 at 10:52 am
  • Editorial Team
    Editorial Team added an answer You can't, sorry. (Depending on exactly what you want to… May 12, 2026 at 10:52 am

Related Questions

I am developing an ASP.NET 2.0 website. I have created data access and business
I have a business object that implements a collection of PropertyObjects. BusinessObject SomeCollection Property1Object
If I have a business object with 50 fields, and I need to populate
I have a DataGrid whose ItemsSource is bound to a changing Observable Collection. Inside

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.