Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm working on a legacy VB.Net code base. There are very few functions that return values, most of the code is in subs/void methods. The general strategy seems to be to pass everything in by reference, mutate it, and then observe the mutated state.

There are some methods that have as many as a dozen parameters that are mutated in this fashion.

I find it very difficult to reason about the code written in this way. It's also rather difficult to write tests to aid in refactoring.

I'd like to know if there's a name for this, mainly in the hopes that I can find better ways of moving the application towards a better structure.

EDIT

I probably should have mentioned that calls tend to be limited to within their own multi-thousand line class files.

Based on the answer below it looks like I need to use extract method to make the methods have meaningful names and to deal with the optional parameters. Once I've done this I can start using extract class to separate out functional unit.

Fun times.

share|improve this question
4  
there is a name for this, but it's impolite to say it publicly –  Steven A. Lowe Aug 6 '13 at 4:57
add comment

1 Answer

up vote 3 down vote accepted

Sounds like Data Envy, where a routine mostly or completely uses a different object.

What you should do is move the routine to the class whose data is being changed.

If you have long routines that take a dozen parameters, you may need to extract the method before moving it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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