I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS and at the client we have Javascript widgets. The client x server requests are done through ajax calls.

I have lots (100+) of server objects, that can be shown into 10 different formats in the browser though different graphical widgets.

So, basically we have the following structure:

enter image description here

So, for every server object I need, at nnnWidgetDataGetter objects, to do some data transformation to widget data format to be sent to the client. Every widget can request data from all objects of the server.

Using a normal approach, I would have to write tons of methods, one for each server basic class times each datagetter class.

To avoid writing hundred of methods with similar behaviour, we decided to use a dynamic approach at the DataGetter classes (static classes), where the business object is evaluated at runtime, data is gathered from this object, formatted and sent to the client.

The problem is that using dynamic object creation and invokation we loose the Intellisense, so the code is turning very big and difficult to understand and maintain.

After a while we found out that we´re not using the correct approach and started thinking about sw patters that would help us solve this.

So we are looking for the correct pattern to solve this issue that would keep a typed structure where Intellisense could work and that avoid us to write hundred of different methods.

We appreciate very much any kind of help.

  • Can you describe a bit more the process of conversion inside those XXXDataGetter objects? Commented Jun 20, 2014 at 6:37
  • Basically nnnGetterData gets removes unused fields from the original object in order not to send them through ajax (it uses a configuration dictionary to do so). It also convert data to ajax to be sent to client.
    – Mendez
    Commented Jun 20, 2014 at 6:40
  • Do these widgets have a similar pattern? or are they completely different from each other? Commented Jun 20, 2014 at 6:43
  • The widgets are very different... Ex: one is a dropbox, another one is a full grid (with paging, configurable columns, etc.), the other is a graph plot, etc... But the Server objects has a pattern - objects with no methods and different properties (each pattern is a db field). xxxDataGetter will mostly return lists of them...
    – Mendez
    Commented Jun 20, 2014 at 6:50
  • 1
    The biggest problem is that you are lacking a central hub which takes care of querying all of your servers. This hub has to be easily plug-able to new servers and generic enough to answer your query needs of the Widget objects. I would definitely look at the Repository Pattern and possibly the Strategy pattern for deciding which server to query. Commented Jun 20, 2014 at 7:45

1 Answer 1


Patterns could give you a clean design for transforming your server objects into widget data. However they will not prevent you from having to define the strategy for each server object (at best you will remove duplicate code).

May be you could use reflection or attributes to examine your server objects and have a generic generator for populating the desired 'DataGetter'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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