Does “variables should live in the smallest scope as possible” include the case “variables should not...
1
According to https://softwareengineering.stackexchange.com/a/388055/248528, variables should live in the smallest scope as possible, simplify the problem into my interpretation, it means we should refactor this kind of code: public class Main{ private A a; private B b; public ABResult getResult(){ getA(); getB(); return ABFactory.mix(a,b); } private getA(){ a=SomeFactory.getA(); } private getB(){ b=SomeFactory.getB(); } } into something like this: public class Main{ public ABResult getResult(){ A a=getA(); B b=getB(); return ABFactory.mix(a,b); } private getA(){ a=SomeFactory.getA(); } private getB(){ b=SomeFactory.getB(); } } but according to the...