Coding standard and Readability: Verbose/Redundant statements vs Short/Compressed I have the following 3 different versions of code.
Version 1 is overly verbose and contains redundancy but on the other hand seems easier to read. Version 2 is somewhere in the middle, and Version 3 is shortened and straight to the point.

Their all equivalent in terms of functionality. I am not sure about readability. 
According to best practices which is the best? Please add actual pros-cons based on theory.
Is there a chance situations like these are also determined by programming style and hence are opinion based as opposed to having black/white clear guidelines?

Version 1:

for (int i = 0; i &lt; resultsSize; i++)
            {   
                bundle = ja.getJSONObject(i).getString(SOLR_BUNDLEID_FIELD);
                app = DataStore.applicationsCache.get(bundle);
                if (app!=null)
                {

                    if(catalogRequest.filter.query_pub==null)
                    {
                        addApp(DataStore.applicationsCache.get(bundle),preparedApps);
                        continue;
                    }

                    if(app.vendor.equalsIgnoreCase(catalogRequest.filter.query_pub))
                        addApp(DataStore.applicationsCache.get(bundle),preparedApps);   
                }

            }


Version 2:

for (int i = 0; i &lt; resultsSize; i++)
            {   
                bundle = ja.getJSONObject(i).getString(SOLR_BUNDLEID_FIELD);
                app = DataStore.applicationsCache.get(bundle);
                if (app!=null)
                {
                    if(catalogRequest.filter.query_pub==null || app.vendor.equalsIgnoreCase(catalogRequest.filter.query_pub))
                    addApp(DataStore.applicationsCache.get(bundle),preparedApps);
                }

            }


Version 3:

for (int i = 0; i &lt; resultsSize; i++) {
                if ((app = DataStore.applicationsCache.get(ja.getJSONObject(i)
                        .getString(SOLR_BUNDLEID_FIELD))) != null
                        &amp;&amp; (catalogRequest.filter.query_pub == null || app.vendor
                                .equalsIgnoreCase(catalogRequest.filter.query_pub)))
                    addApp(app, preparedApps);
            }
Version 1 has code duplication for one seemingly very important line:

addApp(DataStore.applicationsCache.get(bundle), preparedApps);


Duplicating this line is not a good idea if it can be easily avoided.



Version 3 is using &amp;&amp; and || mixed in the same condition which makes it a lot harder to understand. Try to avoid mixing those two together, instead extract conditions into variables, as palacsint has done with boolean emptyQueryPub.



Version 2 is the one I like the best, but with some modifications.

Java Coding Conventions about braces is that they should be on the same line as the condition/loop and not on it's own line.

Adding a few spaces makes the code more readable.

Most IDEs has an Auto-format key-shortcut. Ctrl + Shift + F in Eclipse and Alt + Shift + F in NetBeans. I recommend using it.

The results of the above mentioned fixes:

for (int i = 0; i &lt; resultsSize; i++) {
    bundle = ja.getJSONObject(i).getString(SOLR_BUNDLEID_FIELD);
    app = DataStore.applicationsCache.get(bundle);
    if (app != null) {
        if (catalogRequest.filter.query_pub == null ||
                app.vendor.equalsIgnoreCase(catalogRequest.filter.query_pub)) {
            addApp(DataStore.applicationsCache.get(bundle), preparedApps);
        }
    }
}