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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:24:08+00:00 2026-05-16T02:24:08+00:00

Some I’m reviewing some code within my team’s code base, where we traverse over

  • 0

Some I’m reviewing some code within my team’s code base, where we traverse over one hierarchical data structure and build a new data structure from it. There are no nested loops — every level of the hierarchy has its own dedicated function.

So we have code like this:

public void DoA(A a, Transform transform)
{
    foreach(B b in a)
        DoB(b, transform);
}

public void DoB(B b, Transform transform)
{
    if (b != null && b.IsAvailable)
        return;

    foreach(C c in b)
        DoC(c, transform)
}

public void DoC(C c, Transform transform)
{
    var cAndAHalf = DoCAndAHalf(c.FindAll(x => x.Children > 0);

    foreach(D d in cAndAHalf)
        DoD(d, transform);
}

. . .

public void DoX(X x, Transform transform)
{
    Res res = new Res();
    if (x.Selected)
    {
        res.Selected = true;
        res.ResourceCount = 1;
    }

    transform.Add(res);
}

There are dozens of methods like this, where each method is 3 to 5 lines in length, similarly named, usually contains a trivial null check or filter, and a cursory review of the code shows that no method is really invoked more than once. Methods are public for unit testing purposes.

I personally find it the code very hard to navigate through, because dozens of public methods == dozens of potential entry points into the class guts.

Does this sort of coding pattern have a name? Is it an anti-pattern? Is this style more advantageous than simply nesting the loops in a single function?

  • 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-16T02:24:08+00:00Added an answer on May 16, 2026 at 2:24 am

    Looks like Chain-of-Repsonisbility to me. You just process part of the incoming request and then transfer to next item in the chain.

    Chain-of-responsibility

    In your case it should look like this:

    Action action = new Action;
    action = action.SetNext(DoA);
    action = action.SetNext(DoB);
    action = action.SetNext(DoC);
    
    A a = new A();
    action.Process(a);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some web applications, like Google Docs, store data generated by the users. Data that
Some Eclipse plugins are mandated by your environment. The appropriate source code management plugin,
Some things are easier to implement just by hand (code), but some are easier
Some WPF controls (like the Button ) seem to happily consume all the available
Some API returns me XmlCursor pointing on root of XML Document. I need to
Some things look strange to me: What is the distinction between 0.0.0.0, 127.0.0.1, and
Some e-Marketing tools claim to choose which web page to display based on where
Some programming languages such as Java and C# include encryption packages in their standard
Some files in our repository are individual to each developer. For example some developers
Some context upfront: Imagine a 200+ developers company finally setting up a more or

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.