I’m working with asp.net and c#
Lets say I have a bunch of drop-downs and I want to bind data from a database, is it better to make a master-bind method that loops each one and gets the parameters to bind them all or make a method for each one of the drop-downs?
Right now the program has the masterbind method that binds all the dropdowns, it does its work, but since I got asked to rebuild that whole form, I wanted to know which one is optimal. I’ve searched the web… some people say that one method is better others say that individual methods are better.
2
It depends on the complexity of the binding operation. If it’s just one line to populate the dropdown, encapsulating that in a method is unnecessary. If it’s a dozen lines of database queries and looping over the result and whatever else, having a populateDropdownA method makes sense.
I think that is not good technique. Method should adhere single responsibility principle. Which means each method should have single responsibility. So it’s better if you go with different method to bind each drop down. That’s really help lot in future.