“The first law of software quality.” From this Twitter page.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.2, “How to paste and load blocks of code in the Scala REPL.”
You want to experiment with some code in the Scala REPL, and typing it in or trying to paste it into the REPL won’t work.
Personally, I like helpful comments in code (such as to explain a complex algorithm in a function), but I understand that they get as out of date as this “Missing” sign. Image from this Twitter page.
This is a little unusual for me, but I'm putting the following code here so I can remember how I implement a
ViewPager in my current Android application. I want to put this code out here in its current state before it gets more complicated. In fact, I only wish I had copied it out here earlier, before I made it as complicated as it is.
The only things that are important to know are:
Here’s a quick example of how to access an Android
MenuItem in a Java
Fragment class (i.e., in your Java code).
Given a menu named res/menu/menu_landing_page.xml defined like this:
I’m just working through some examples in an excellent Android programming book (Android Programming: The Big Nerd Ranch Guide), and ran across this old Java code. I know things are better in Java 8, but this reminds me of how much goodness Scala has brought into my programming life.
“I hate reading other people’s code.” (This cartoon is making the rounds again.)
“The Joel Test”, from 12 Steps to Better Code.
I love this comment from Martin Odersky, from the image shown, which comes from this link:
“Initially, things were too fluid to invest in tests. I simply did not know whether the design would hold up, had to fit a lot of pieces together first. But now is a good time to put these tests in place.”
So often people talk about “Test First Development” that I think they’re insane, or just regurgitating marketing-speak to sound good. There are times when you’re coding things like SARAH where you don’t know how things are going to shake out that “Test First” just doesn’t make sense. If you know what you’re getting into when you’re coding, Test First sounds good, but when you’re exploring, “Oh, this is how SARAH should work”, or, “I thought an FTP server worked like this but it works like that”, Test First doesn’t make sense. (Once you understand the domain, giddyup, test your heart out.)