Java: Cohesion

Each function should do only one thing. This should be done so that the conceptual unit can be understood easily. Sometimes it will be convenient to do two things in a function because you're working on the same data. Try to resist this temptation. Make two functions if you reasonably can.

For example, if you write a function to read a file of numbers into a vector (eg, readVector(v)), that's all the function should do. If you know that you also need the sum of the numbers, Here are three ways to solve the problem of reading a vector and summing the elements.