Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Practice Question: Many parameters, different methods.

Status
Not open for further replies.

MrDataGuy

Programmer
Oct 18, 2010
231
US
I have a situation where two different methods are getting the same list of parameters. (Specifically Adding and updating a row in a grid: Me.grdInfo.Rows(I).SetValues(A,B,C…) and Me.grdInfo.Rows.Add(A,B,C…) ) Now I am thinking to myself: Self when I add a new column or need to change a parameter will I remember to make the needed change in both places? BTW there are 16 parameters being passed and I get uncomfortable with more than 3. I come from the OOP school that >80% of the methods in a Class should have no parameters, <15% one, <5% two, <1 % three and <<1% more than three)

Anyhow this is not a critical issue, and many (Most?) developers would say this is not an issue at all but I am trying to see if there is a better/more elegant solution. Now if this was my methods calling another of my methods I would just pass the information via a structure, e.g. a single parameter object.

Wait now that I am typing this I have an Idea. Why not create a structure that contains all of the ‘parameters’ plus one more element which is a ‘flag’ that says if this is an add or update. Send that to a method that calls the correct grid method. Hmmm I think I will try this.

Other suggestions, ideas, better solutions? Am I drinking too much OOP cool-aid?


Lion Crest Software Services
Anthony L. Testi
President
 
Hi
I do exaclty this. Stuctures. Also when i need to pass variables (unknown number) of the same type or not i use Arraylist or List (OF T).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top