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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Math .NET may be will be interesting for you. May 16, 2026 at 3:34 pm
  • Editorial Team
    Editorial Team added an answer Fixed it by extends SoapClient and overrides __doRequest() method where… May 16, 2026 at 3:34 pm
  • Editorial Team
    Editorial Team added an answer Your task doesn't know which application's factories.yml to load -… May 16, 2026 at 3:34 pm

Trending Tags

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

Top Members

Related Questions

Some background, this application is a printing application that runs within REvit Structure, an
Some web applications, like Google Docs, store data generated by the users. Data that
For some reason, after submitting a string like this Jack’s Spindle from a text
I have just tried to save a simple *.rtf file with some websites and
I have a JSP page retrieving data and when single or double quotes are
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Some solution could probably be applicable to Windows, however I am not familiar with
Some time ago we needed a solution for Single Sign On authentication between multiple
Some of the applications running on Windows 7 (Internet Explorer, Google Chrome, in example)
Some people have mentioned RockScroll and MetaScroll in This Question , but those only

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.