Tag Info

New answers tagged

26

For example, imagine an initialisation method split into a series of small ones: in the context of method itself, you clearly know that object's state is still invalid, but in an ordinary private method you probably go from assumption that object is already initialised and is in a valid state. The only solution I've seen for this is... Your concern is ...


6

Many languages let you nest functions like Haskell. Java/C#/C++ are actually relative outliers in that regard. Unfortunately, they are so popular that people come to think, "It has to be a bad idea, otherwise my favorite 'mainstream' language would allow it." Java/C#/C++ basically think a class should be the only grouping of methods you ever need. If you ...


0

I don't think it's a big issue, but I agree it's troublesome. Usually I just place the helper immediately after its beneficiary and add a "Helper" suffix. That plus the private access specifier should make its role clear. If there's some invariant that doesn't hold when the helper is called, I add a comment in the helper. This solution does have the ...


4

I think the answer in most cases is context. As a developer writing code, you should assume your code is going to be changed in the future. A class might be integrated with another class, might replace it's internal algorithm, or might be split off to several class in order to create abstraction. Those are things beginner developers usually don't take into ...


12

I often see this, and agree that it is a problem. Usually I resolve it by creating a method object: a new specialized class whose members are the local variables from the original, too-large method. The new class tends to have a name like 'Exporter' or 'Tabulation', and it gets passed whatever information is necessary to do that particular task from the ...



Top 50 recent answers are included