If a few lines of comments are bothering you that much, perhaps you need
to tone down the colour scheme for comments in Eclipse!

Nevertheless I've extracted the whole thing into a method
"writeIfComplete".  I think that works better than a method just to
check a condition (and to hold some comments).

On 2013-08-01 14:32, David Mason wrote:
> In zanata-war/src/main/java/org/zanata/rest/service/TMXStreamingOutput.java:
> 
>>  
>>        while (iter.hasNext())
>>        {
>> -         SourceContents tu = iter.next();
>> -         net.sf.okapi.common.LocaleId sourceLocale = OkapiUtil.toOkapiLocale(tu.getLocale());
>> -         exportTUStrategy.exportTranslationUnit(tmxWriter, tu, sourceLocale);
>> -         if (writer.checkError())
>> +         TU tu = iter.next();
>> +         Optional<Element> textUnit = exportStrategy.buildTU(tu);
>> +         // If there aren't any translations for this TU, we shouldn't include it.
>> +         // From the TMX spec: "Logically, a complete translation-memory
>> +         // database will contain at least two <tuv> elements in each translation
>> +         // unit."
>> +         if (textUnit.isPresent() && textUnit.get().getChildElements("tuv").size() >= 2)
> 
> The condition isn't the only thing interfering with readability - there
> are 4 lines of comment to wade through as well, when all that really
> matters at this point is the simple concept of whether or not we have a
> text unit with translations. If the comment is necessary then there's
> too much information to cram in this loop.
> 
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/zanata/zanata-server/pull/78/files#r5522272>.
> 


-- 
Sean Flanigan

Senior Software Engineer
Engineering - Internationalisation
Red Hat