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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:23:09+00:00 2026-06-02T06:23:09+00:00

I have a special object which holds a list of objects and a bunch

  • 0

I have a special object which holds a list of objects and a bunch of accompanying properties for the list.

I have a function which injects items into the List portion of my special object. The function depends on properties that accompany the list, so I opted to create a new object which holds both properties and the List.

Question 1: Who is responsible for ensuring the List isn’t null before the function begins injecting items?

  1. Should the caller create a new list and pass it to the function?

  2. Should the callee create a new list and assign it to the object regardless of the state of the object passed in?

  3. Should the function be designed to take in the object and return a new list WITHOUT modifying the object, leaving it to the caller to assign the returned list to its special object?

or… are there other options I haven’t considered?

Related Question 2: Given that my design requires properties that accompany a List, should I have chosen to create a new class which holds both properties and a List, or should I create created a sub-class of List that holds additional properties?

  • 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-02T06:23:12+00:00Added an answer on June 2, 2026 at 6:23 am

    In short, the object containing the list is responsible, conceptually, for having a valid means to store data, meaning it should be responsible for instantiating its list when one is needed.

    If the object is designed to represent a collection of objects, then it is responsible for maintenance of whatever it actually uses internally to store them, unless part of the objective is for the new object to be a “wrapper” for multiple types of collection, allowing for behavior customization based on the type of collection used internally.

    Consider a List. It uses an array internally to store data, and deals with the resizing of said array to store new objects as may be required. You don’t have to know that about a List; conceptually, it is an ordered, indexed collection allowing insertion and removal of elements. It could have been implemented with a linked list, or a red-black tree, or whatever; those would have had performance and complexity implications.

    Back to the case in point. Your object, meant to be a List with additional properties, should hide its internal data structure. Users shouldn’t need to know there’s a List in there holding elements. That means your object should know how to instantiate its own internal data structure, and expose methods that would be used by the caller to inject new elements, which act on the internal list.

    The one exception is that of a “wrapper” which adds new functionality which could apply to any of a subset of other classes, and it is important to allow the user to specify which class the new one should “wrap” in a particular usage. An example is a BlockingCollection. It adds the ability to block a thread that is performing some concurrent operation on the collection until it is valid and safe to perform said operation (for instance, a thread attempting to get an item from the BlockingCollection will be blocked if the collection is empty, until another thread adds something). When created, you can specify that the BlockingCollection uses a specific implementation of the IProducerConsumerCollection interface; most likely that will be one of the built-in “Concurrent” collections in the same namespace, such as ConcurrentBag, ConcurrentQueue or ConcurrentDictionary. Even in this case, there is a “default” option; you can instantiate a BlockingCollection object without specifying the internal Concurrent structure to use, and the object will default to a ConcurrentQueue.

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

Sidebar

Related Questions

I have two tables, one table is the items container, which holds all data
Is there anything special I have to do to a JSON object before I
There are some products for which I would like to have a special checkout
i have to develop a mechanism to check two object properties for changes. All
I have an object of which I am looking to get a piece of
I have a class which encapsulates a StAX Writer for a special business XML
I have a DataGrid , which is bound to a DataTable object. The user
I have an Activity which provides UI for editing entity properties such as name,
I have a custom class that extends List which I am using as a
I have: dojo.xhrGet({ url:/data/js/1/markers.js, handleAs:javascript, load: function(r){ dojo.forEach(placemarks, function(item) { Which works fine in

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.