Over the years I’ve enjoyed answering questions on StackOverflow and related sites, and feel it’s a decent way to get to know my knowledge, writing style, and development philosophy.
As of March 2021, I am in StackOverflow’s top 2000 contributors or top 0.25% (by reputation points). I am one of four silver badge contributors to dagger-2, and I am the sole gold badge contributor on the topics of guice and mockito. Based on pageviews to my highly-ranked answers, StackOverflow has estimated my total impact as reaching ~5.5 million people.
In this question, an API-level-specific Android runtime bug caused some confusing behavior. A quick comment on the question wound up solving the mystery and saving some tricky debugging time for the developer.
This question expands on a quick answer—a missing XML label—to cover best-practices regarding lightweight Application subclasses. The answer also alludes to the diagnosis; some of the fun in StackOverflow is in using incomplete or imprecise information to debug the problem remotely.
This question presents a seemingly-nonsensical error message:
RoboApplication cannot be cast to RoboApplication. However, the error message
is useful, since PowerMock and Robolectric each use their own class-modifying
classloaders. This answer discusses the root cause along with some testing
Dagger / Guice
This question is a basic overview, but shows how I try to make long-lived documentation through well-strucured writing. StackOverflow answers provide a great opportunity to practice answering questions that can adapt to a wide range of levels of expertise.
This is a question about Guice basics, but one where things accidentally appear to work. Clarifying these basics can make all the difference when learning complex frameworks.
This is a closed question: The community decided that this kind of question is difficult to answer in an unbiased way. I’m flattered with the reception the question has received since then, and I’d like to think a little insight into DI history would help readers make informed framework choices.
Guice modules are an unusual mix of declarative configuration and procedural code. One of my well-appreciated answers turns a well-intentioned antipattern into a cookbook of clean alternatives.
@Reusable annotation provides a pragmatic approach to
instance reuse. The difference is small, but that nuance allows for powerful
options—especially on Android.
Deliberately written with ES5 features and syntax for maximum reuse.
This collaborative answer solves the initial problem, including a clarification about promises vs promise factories.
TypeScript has some impressive hidden utility types within its standard library.
ReturnType<T> allow can help to make flexible
definitions with a minimum of repetition.
This is a self-answered question: I had seen several questions before about how Mockito’s syntax can trip up reasonable-looking usage, and wanted to write one clear and easy-to-find answer to put into a community-curated place. Despite the larger scope, this question and answer have each received hundreds of positive votes, and over 100,000 views.
I happened to see this question right as it was posted, and could very quickly point out how Java’s anonymous inner class syntax and Mockito’s clever subclassing could combine to cause some counterintuitive test behavior. “I would never have found that in a million years,” question asker Jon O. replied.
Before Java 8 brought lambda syntax to Java,
were difficult to get right, and tools like ExpectedException were popular
alternatives. This answer explains how ExpectedException works behind the
scenes and shows where a tried-and-true Java idiom still provides