[Solved] Static and Non Static methods [closed]


There in no straightforward answer on whether one should declare methods as static or not. It depends on the context and functionality of your application.

Going with some assumptions for your situation, consider following thoughts on high level –

  • If the validation is related to one particular form only, and not applicable for other forms, declare it within your form class ans private method. If these validations do not require any class instance, you may declare them static.
  • If some validations are common for different form, you may declare them as static. Do take caution and do not pass controls to these methods, instead pass the values that you want to validate for better design.
  • Consider declaring validations in base form only if those are applicable to all or if not most of the forms, and again, if they do not use any instance object, you may mark them as static

A good discussion here.

solved Static and Non Static methods [closed]