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

The Archive Base Latest Questions

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

I’m currently struggling to understand how I should organize/structure a class which I have

  • 0

I’m currently struggling to understand how I should organize/structure a class which I have already created. The class does the following:

  1. As its input in the constructor, it takes a collection of logs
  2. In the constructor it validates and filters the logs through a series of algorithms implementing my business logic
  3. After all filtering and validation is complete, it returns a collection (a List) of the valid and filtered logs which can be presented to the user graphically in a UI.

Here is some simplified code describing what I’m doing:

class FilteredCollection
{
  public FilteredCollection( SpecialArray<MyLog> myLog)
  {   
  // validate inputs
  // filter and validate logs in collection
  // in end, FilteredLogs is ready for access
  }
  Public List<MyLog> FilteredLogs{ get; private set;}

}

However, in order to access this collection, I have to do the following:

var filteredCollection = new FilteredCollection( specialArrayInput );
//Example of accessing data
filteredCollection.FilteredLogs[5].MyLogData;

Other key pieces of input:

  1. I foresee only one of these filtered collections existing in the application (therefore should I make it a static class? Or perhaps a singleton?)
  2. Testability and flexibility in creation of the object is important (Perhaps therefore I should keep this an instanced class for testability?)
  3. I’d prefer to simplify the dereferencing of the logs if at all possible, as the actual variable names are quite long and it takes some 60-80 characters to just get to the actual data.
  4. My attempt in keeping this class simple is that the only purpose of the class is to create this collection of validated data.

I know that there may be no “perfect” solution here, but I’m really trying to improve my skills with this design and I would greatly appreciate advice to do that. Thanks in advance.


EDIT:

Thanks to all the answerers, both Dynami Le-Savard and Heinzi identified the approach I ended up using – Extension Methods. I ended up creating a MyLogsFilter static class

namespace MyNamespace.BusinessLogic.Filtering
{
    public static class MyLogsFilter
    {
        public static IList<MyLog> Filter(this SpecialArray<MyLog> array)
        {
            // filter and validate logs in collection
            // in end, return filtered logs, as an enumerable
        }
    }
}

and I can create a read only collection of this in code by doing

IList<MyLog> filteredLogs = specialArrayInput.Filter(); 
ReadOnlyCollection<MyLog> readOnlyFilteredLogs = new ReadOnlyCollection<MyLog>(filteredLogs);
  • 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-15T07:11:58+00:00Added an answer on May 15, 2026 at 7:11 am

    The way I see it, you are looking at a method that returns a collection of filtered log, rather than a collection class wrapping your business logic. Like so:

    class SpecialArray<T>
    {
         [...]
    
         public IEnumerable<T> Filter()
         {   
             // validate inputs
             // filter and validate logs in collection
             // in end, return filtered logs, as an enumerable
         }
    
         [...]
    }
    

    However, it does look like what you really wish is actually to separate the business logic in charge of filtering the logs from the SpecialArray class, perhaps because you feel like the logic touches many things that do not really concern SpecialArray, or because Filter does not apply to all generic cases of SpecialArray.

    In that case my suggestion would be to isolate your business logic in another namespace, perhaps one that uses and/or requires other components in order to apply said business logic, and offer your functionality as an extension method, concretly :

    namespace MyNamespace.Collections
    {
        public class SpecialArray<T>
        {
            // Shenanigans
        }
    }
    
    namespace MyNamespace.BusinessLogic.Filtering
    {
        public static class SpecialArrayExtensions
        {
            public static IEnumerable<T> Filter<T>(this SpecialArray<T> array)
            {
                // validate inputs
                // filter and validate logs in collection
                // in end, return filtered logs, as an enumerable
            }
        }
    }
    

    And when you need to use that business logic, it would look like this :

    using MyNamespace.Collections; // to use SpecialArray
    using MyNamespace.BusinessLogic.Filtering; // to use custom log filtering business logic
    namespace MyNamespace
    {
        public static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main2()
            {
                SpecialArray<Logs> logs;
                var filteredLogs = logs.Filter();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I have a JSP page retrieving data and when single or double quotes are
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.