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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:37:27+00:00 2026-05-15T14:37:27+00:00

Semi-unimportant background: I’m working on a page with two sets of collapsable panels. (using

  • 0

Semi-unimportant background:
I’m working on a page with two sets of collapsable panels. (using nHibernate) I get category objects with a list of items in them, and for each category generate a left panel and right panel. In both panels, there is a ListBox. Items are pre-populated to the left list box and the user can select and move items into the right list box (under the corresponding category.)

As I’ve built and worked on it, I ended up with a lot of generic methods like buildPanel(side,categoryID) and then ended up with a lot of repeated if statements inside them to differentiate between the two sides

if type=PanelType.Left then 
    set these 5 id strings to access components
else
    ...

The code got messy, so I moved a lot of the logic and static builder strings for the component ids into a private helper class in order to make other parts of the main class easier to read and follow. The problem I see is that the private class is extremely dependant on specific structures in the parent class. There’s a very minimal amount of encapsulation going on and I’m possibly making the logic harder to follow even if the individual components in the code are easier to read.

My question is: When you’re using a private class like this, is it acceptable to have it tightly integrated with the parent class (since it’s private and implemented in the same file), am I better to refactor again and find a way of either simplifying my original code to be as short as possible without the helper class (stick all category/panel functions in one spot and hide them in their own region when I’m not using them), or should I move towards putting more of the logic in the helper class and simply mapping my events directly to the subclass.

After typing all this out, I’m leaning towards the last option, but I’m still torn/confused about the whole thing…

  • 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-15T14:37:28+00:00Added an answer on May 15, 2026 at 2:37 pm

    Pages are classes and as any class they can grow unwieldy. When you come to the stage where code is heavily coupled, it kind-of depends on how this coupling shows whether or not you should refactor. If the code is clear, concise and easy to follow, it’s ok to leave it as it is. But if its hard to follow, if you cannot explain it to a co-worker in a few minutes or you think you won’t understand it yourself in half a year than it’s eligible for refactoring.

    The Law of Demeter (light coupling) shouldn’t only be applied in inter-class relationships, but also in inter-method relationships. This is often overlooked or underestimated. But sometimes too much refactoring leads to another extreme: too little coupling can become unreadable, too (just as having too many small methods or too many big ones).

    I usually ask myself the question: does the code read like a book with clear chapters and storyline, or do I have to read each paragraph twice, or worse, turn back pages to understand it?

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

Sidebar

Related Questions

I'm a recent semi-convert to Eclipse after 20 years of using vi and gvim.
I'm writing a semi-generic form plugin using jQuery in order to speed up the
I noticed this semi weirdish-behavior in one of my projects using Scheme and lists.
A semi colon character was expected. Error processing resource '... <key>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CNXT_MODEM_PCI_VEN_8086&DEV How can I
I'm writing some semi-portable code and want to be able to detect when I'm
We have a semi-weird issue for our site. Consistently, from 1 anonymous* user the
I have a semi-large web application that we run locally and I need to
How can I use semi-transparent png images in IE6?
I guess, the following is a standard problem on every school or university: It

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.