I've used code blocks in this style in the past but... (1) It is helpful to add a // comment for each block, otherwise, it feels anonymous and weird to me. (2) Why not refactor and pull-out methods? This then forces you to _name_ the methods, instead of the above (anonymous blocks vs. commented blocks.)
Gary On Wed, Jun 12, 2019 at 9:00 AM Heinrich Bohne <heinrich.bo...@gmx.at> wrote: > I have been asked to request some feedback on this pull request: > https://github.com/apache/commons-numbers/pull/36– specifically, about > the introduction of code blocks in the commit "NUMBERS-100: Reduce scope > of local variables". > > I had the idea with the code blocks when I wanted to add a test to the > method testAdd() but was intimidated by the huge wall of code contained > in the method. When taking a closer look, this code wall is actually > composed of several test cases that are completely independent of each > other, but because the local variables live throughout the whole method > and are re-used in almost every test case, this is not obvious. The more > variables are involved, the closer you have to look to figure out which > sections are independent of the rest. > > I think that, with the code blocks, it is instantly obvious that a > specific section does not depend on anything that happened before it, or > that it does not affect anything that comes after it. So I think that > they are preferable to the previous version of the file. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > >