.net - Should i use Static/Shared Methods for readability: -
i have been tought avoid using static methods. i've been tought try keep code readable , short possible.
i have list of proxies , of them should perform 5 different validation.
for me these validation different don't feel putting them in 1 big validation class. if validation extended class grow large.
now in case can write validator class way:
public class myvalidator1 public shared sub validate(proxy serviceclient, year integer) dim args = new arguments() args.year= year try console.writeline("test") console.writeline("--------------") dim result = proxy.generatreport(args) console.writeline("no errors") catch ex exception console.writeline(ex.message) console.writeline() end try end sub end class
this how implemented:
for each proxy in _proxies console.writeline(proxy.endpoint.address.uri.host) console.writeline("------------------------") myvalidator1.validate(proxy.value, jaar) myvalidator2.validate(proxy.value, jaar) myvalidator3.validate(proxy.value, jaar) myvalidator4.validate(proxy.value, jaar) myvalidator5.validate(proxy.value, jaar) next
i can offcourse make methods non-static/shared require me create instance of every validator.
what pro , cons of each choice. me easyer read static implementations.
1)if methods not dependent on instancevariable can make them static, , in case since looking towards making them static, static class
maybe of interest.
2)if methods not logically grouped better have them in seperate classes, if class growing , becoming less managable can consider thinking of partial class same.
Comments
Post a Comment