Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few (view) classes.

Table, Tree, PagingColumn, SelectionColumn, SparkLineColumn, TimeColumn.

currently they're flat under app/view like this:


I thought about restructuring it, because the Trees and Tables use the columns, but there are some columns, which only work in a tree, some who work in trees and tables and in the future there are probably some who only work in tables, I don't know.

My first idea was like this:



But since the SelectionColumn is explicitly for trees, I have the fear that future developers could get the idea of missuse them.

But how to restructure it probably?

Like this:




Or like this:



share|improve this question
up vote 1 down vote accepted

Without going too much into detail regarding to your specific scenario, here are a couple of guidelines when structuring classes.

  • Usually your file structure should follow the namespaces of your classes, so this question doesn't really relate as much to file structure as you make it seem, but rather to how to organize classes and about creating the proper abstractions.
  • Place classes in the least specific namespace possible. When you created a class for a certain class within a specific namespace, this doesn't necessarily mean it's the most logical place to place it. It might be relevant to place it higher up the hierarchy.
  • When creating proper abstractions, classes become reusable in a wide set of scenarios, and the namespace should reflect that. Instead of placing a class in a specific application namespace, you could move it to e.g. a common user control namespace.
  • Following the cohesion principle, place logically related classes together. E.g. when a set of classes are logically related it might be worthwhile creating a specific namespace and grouping them together within this namespace.

Applying this to your specific scenario the first thing that comes to mind is:

  • Common/Layout/Columns/AbstractColumn
  • Common/Layout/Columns/PagingColumn
  • Common/Layout/Columns/SparkLineColumn
  • Common/Layout/Columns/TimeColumn
  • Common/Layout/Table
  • Common/Layout/Tree
  • Common/Layout/Tree/SelectionColumn (could be an inner class)
share|improve this answer

I'd recommend your first idea, with the an additional partial class "BaseColumn" from the various column classes can inherit from. This would allow you to define the common methods and properties within the "BaseColumn" and implement the differences in the Paging, Selection, Spark and Time column classes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.