OnePlus phone and Notification issues

I recently acquired the OnePlus phone, and immediately started digging into customizations. One of the features is Quiet Hours.

I didn’t realize it at the time, but Quiet Hours in CyanogenMod 11 u38+ breaks notifications on the OnePlus.

After some Googling, finally found the right post with directions that worked for me (and based on comments, many others). Read the comment by Jake on Oct. 21, 2014 at 8:13 AM.

Here’s a summary:

  • Turn Quiet Hours on
  • Remove the Quiet Hours
  • Restart phone
  • Add Quiet Hours tile back
  • Turn Quiet Hours off using the tile

You may safely remove the Quiet Hours tile after this and until this defect is corrected, don’t turn quiet hours on again.

Floobits: Pair Programming Remotely

Just got the Jetbrains newsletter, and one of the plugins they mentioned is Floobits:

Floobits allows for remote sharing of code either through its own built-in editor, or through supported editors. They currently support vim, emacs, Sublime Text and IDEA.

They have a podcast which quickly shows it in action and it looks quite impressive.

If you’re looking to do pair programming with someone, and you’re not in the same place, worth checking out.

Beyond Functional Testing: Web Consistency Testing

Functional testing done correctly is very powerful, but it is limited. It verifies that the system is functioning correctly (a very important attribute), but it doesn’t do any verification of usability or appearance.

Enter Web Consistency Testing. The video on the main page gives a very good view into the approach.

Currently, most developer’s develop in their favourite browser until the site looks the expected way. Once that is complete, the site will be checked against another browser and any discrepancies corrected. Continue this process across supported browsers (or wait until someone else notices an issue).

Needless to say this process is very time consuming, prone to errors, and not as thorough as it could be.

Web Consistency Testing is about automating this process. Attempts have been made to do this using image comparison, but depending on site changes (think rotating ads, carousels, browser differences), image comparison can be very fragile. The BBC has written a framework for image comparison that works well for them, but it does require a number of servers, and compares two environments, highlighting differences.

Some problems with this approach include false negatives and difficulty narrowing down the actual discrepancy.

Web Consistency Testing uses the DOM for comparisons. It will parse the DOM, determine locations of items, and use that for comparison. It will also use offsets so that if an item higher in the DOM is out of position, all items below will be offset accordingly so that they are less likely to produce an issue. This really assists in finding an actual discrepancy.

A specific implementation is available at Mogotest. Mogotest leverages a number of open source projects, as well as Cloud servers to evaluate across various browsers, including mobile. It attempts to mimic the developer workflow by using one browser’s rendering as the reference, and then reporting on discrepancies from one run to the next, as well as discrepancies across browsers.

Because it’s leveraging Cloud, it is also able to support many browser/OS combinations, including mobile.

One could duplicate Mogotest’s functionality as it’s primarily built using open source technologies, and readily available Cloud Services.

A very interesting approach to visual verification of a site, and one I will be investigating further.

Java: Optional.isPresent() is not the best usage of Optional

Using the Optional class from Guava or JDK8?

The TL;DR: If you’re using isPresent(), you’re not taking full advantage of Optional.

Optional allows one to explicitly state that a variable may not have a value rather than relying on comments/code convention and null values.

It provides a number of helpers for constructing Optional items. Optionals are basically a wrapper around an object, and can either be ‘absent’ or ‘present’.

Optional provides an ‘isPresent’ method, but if you’re using it, you aren’t taking full advantage of Optional. Using isPresent isn’t really any different than using {var} != null from a coding perspective.

The Guava Optional provides several methods for retrieving items. If you know it will always have a value (likely due to previous checks), you can use get().

If you’re not sure if it will have a value or not, and want the default returned to be null, use orNull(). There is also an or(defaultValue) that will return defaultValue if it isn’t defined and an or that will return a different Optional value.

The JDK8 version of this is more powerful, but this at least gets one started. Here’s a great post about the JDK8 Optional: