Java’s Collections.unmodifiableCollection doesn’t pass equals and hashCode to the backing collection. I’m surprised I haven’t come across this before!
The user-select CSS property allows you to prevent selection of certain content. As the link explains, it’s useful for preventing accidental selection of icons next to buttons. A certain well known UK high street electronics shop’s website also uses it to prevent text selection, presumably to prevent you copying product names into price comparison sites. It’s not reliable or widely supported though. The same effect can be had by doing a preventDefault (or return false) in the “onselectstart” event handler (again doesn’t seem to be standard).
Continuing on the theme of text selection, I find the auto highlighting of library URLs on hover on the cdnjs website quite useful. It’s achieved using the Selection capabilities of the DOM, which allows you to get or set the current selected text.
- https://www.youtube.com/watch?v=UMnZiTL0tUc – The Secret to Safe Continuous Deployment: how a team at Google uses “perceptual diffs” of screenshots of their web application to detect things that usual forms of automated tests won’t
I have a few more interesting things queued, they’ll have to wait until next time though as I haven’t had time to read them properly and/or play with them.
When sizing a cache such as Ehcache, back-of-envelope calculations is what’s often done. While it may well give the right answer, the envelope never seems to be kept so when someone comes along needing to modify/tweak the caching behaviour of the application they are faced with an ehcache.xml config file full of various numbers with no indication of why they were chosen.
This is often the case with many config files, but I’ve seen that ehcache.xmls are particularly prone to this (not anything to do with Ehcache, more the people who maintain them).
So I think it’s good to do what we did in a recent project, and document the choices of various settings with comments, and the calculations in a spreadsheet checked in to source control.
Some resources I found useful while calculating cache sizes:
I’d forgotten about this one until it caught me out again recently. I can see why it can’t be fixed though: putting an element with a null value is what you do to release the lock. Thankfully it’s easy to work around by using a plain object as a “null marker”. That does cause some boilerplate in methods that use the method though, so it might make sense to create a decorator that deals with this if you have a lot of it.
Next time I need some in memory caching though, I’ll be considering the Guava caches as quite often the capabilities of Ehcache aren’t required in applications that use it. I particularly like the fact that a self populating cache can bulk load using the CacheLoader.loadAll method, unlike Ehcache’s SelfPopulatingCache.
Dustin Marx shows how Java 7’s MethodHandles lookup functionality can be used to name loggers. Much less error prone than putting the class name in the code.
When new versions of the IDE are released, I’ve often updated my install and carried on without paying much attention to what’s new other than what I happen to run into. So here I’ve trawled some “what’s new” and “new and noteworthy” documentation for things I found useful – some of them surprisingly old!
To improve the presentation of the Debug perspective, the common debug control commands (Stop, Resume, etc.) have been moved out of the Debug view and into the global toolbar.
The global toolbar can be customized with the Window > Customize Perspective… action to add or remove debugging commands, or to show/hide the debug toolbar completely.
Old toolbar behavior can be restored by first toggling the Show Debug Toolbar option in the Debug view’s menu, then by disabling the Debug toolbar from the Customize Perspective dialog. (source)
A second addition in the same section of the compiler preferences, Switch is missing ‘default’ case, controls whether the JDT will flag switch statements with a missing default case, because such a switch statement will be skipped entirely at runtime if an unexpected value occurs. (source)
Package names in Java views can now be abbreviated with custom rules. The abbreviation rules can be configured on the Java > Appearance preference page. (source)
Unsorted views like the Outline view and the Members view in the Java browsing perspective can now be used to rearrange members by drag and drop. (source)