Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I am working on a ASP.NET web application and there was recently a need to dynamically generate columns.

I created a static class ColumnBuilder.cs, which takes in an entity and returns an appropriate control such as DropdownList, TextBox, Checkboxes, etc. All of the methods are static and work fine.

  1. Will there be any performance impact if I use static methods?
  2. Will there be any unexpected behavior for using static methods?

For example: if the ColumnBuilder is being used by a lot of people (> 10000). If yes, how do I go about solving this?

public static class ColumnBuilder
{
     public static WebControl BuildColumn(ColumnEntity columnObject)
     {
          switch(columnObject.DataType)
          {
              case "TextBox"://return a new textbox
                        break;
              case "DropdownList"://return a new DropdownList
                        break;
          }
     }
}
share|improve this question
 
Is there any relevant code for this to show us? –  Jamal Sep 30 at 6:27
3  
This question appears to be off-topic because it is has no code for us to review. –  Nik Sep 30 at 6:34

closed as off-topic by Nik, 200_success, palacsint, dreza, svick Sep 30 at 9:13

  • This question does not appear to be a code review request within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

1. Will there be any performance impact if I use static methods?

Only profiling can determine this exactly, but I I do not expect a big change in performance. It may be a little faster, if the VM or the compiler detects that the method can be inlined.

2. Will there be any unexpected behavior for using static methods?

The method do no t access any data except its parameter therefore there is no unexpected behavior to be worried about.

share|improve this answer
 
Are you sure there is a final in .net???? I believe that's a Java construct and the OP tagged their post asp.net –  dreza Sep 30 at 8:40
 
@dreza: You may be right, but the essential of the answer is still valid for .net (but you should use sealed for inherited methods. (see: [C# - is it possible to mark overriden method as final] (stackoverflow.com/questions/797530/… –  MrSmith42 Sep 30 at 9:03
 
With these static methods rendering controls like RadComboBox etc some of them have event handlers to them like the ItemsRequested this event gets added as a static event . There is no manipilation of data only a GET is done is this too fine ? –  user581157 Oct 1 at 13:13

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