Scala Stuff
Oct 14th
I’ve been trying to spend a lot of my free time hacking on Scala. I love the language. It’s had a steep learning curve for me, but I’ve really enjoyed the trip. As you get into the language, you appreciate how it’s consistency can make complicated concepts seem simple. Here are some good links that helped me get started:
- Scala training slides: http://github.com/javaBin/scala-training-slides
- Dick Wall’s functional koans: http://github.com/relevance/functional-koans/tree/scala
- Scala for Java refugees: http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
- Java Posse Roundup 2010 – Scala discussion: http://javaposse.com/java_posse_314_roundup_10_scala
Fitting in
Aug 18th
I had a relatively long post put together about writing code and how important it is to be consistent with your teammates. I had a few paragraphs on maintaining style, architecture, and keeping the essence of the code you’re working with. Instead of going through that, I boiled it down to a few basics that I run into often.
Keep the style consistent
If you have a corporate style, follow that. Otherwise, the Snoracle code conventions are mostly your friend. I always have to grit my teeth when someone abuses this. If the project is written in a K&R style, don’t complain when your Allman style classes get reformatted. Checkstyle does a really good job at automating this at check in time, while the major IDEs have very good formatting tools.
Maintain the architecture
If the project you’ve been asked to maintain is straight JSF, don’t slam in your favorite DI framework because that’s all you know. Take the time to look through the code and get to know it. Maintain the architecture whenever possible. When it’s your turn to decide the design, you can do it however you want. Until then, it’s helpful to stick with the groundwork that’s already present. Keeping the architecture clean is a huge advantage when it comes time for refactoring or retrofitting for missed requirements.
Follow the spirit
If a class has only 5-line methods, don’t slam in a 50-line monstrosity. When all the parameters are declared final, take note, and do the same where appropriate. If the class is immutable, don’t add javabean setters. In other words, don’t redecorate your friend’s house when you stop by for a visit. For good or bad, a lot of developers feel strongly about code they initially created. If someone else isn’t considerate of the spirit in which that code was written, feelings can fray and productivity can plummet.
Don’t break things
Before you check your code in, make sure it compiles and passes all of the unit tests. Continuous integration helps this situation, but you can save yourself embarrassment and the wrath of your coworkers by making sure things are ok before committing. If you don’t have unit tests for your stuff, now is the time to write some. No one likes a broken build, but it’s even worse when broken code ends up on your machine straight from source control. Developers have a hard enough time tracking down their own bugs. Adding to that burden and making them fix yours is not appreciated.
Addicted to final
Jun 25th
What can I say? I’m addicted to the final keyword. My code is littered with it. A typical class can end up looking like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | public class SimpleClass { private static final Logger logger = Logger.getLogger("SimpleClass"); private final String foo; private final List<String> bars = new ArrayList<String>(); public SimpleClass(final String foo) { this.foo = foo; } public void addBar(final String bar) { bars.add(bar); } public void printFooBars() { final PrintStream out = System.out; try { out.println(getFoo()); } catch (final Exception e) { logger.info(e.toString()); } for (final String s : bars) { out.println(s); } } protected String getFoo() throws Exception { if (foo == null) { throw new Exception(); } return foo; } } |
Constants, variables, and parameters have final attached to them. I wasn’t always this addicted, but I’ve since learned through painful experience. With the final keyword spread liberally around my code, the compiler does the hard work and tells me when I’m doing something wrong. I can’t accidentally change a value or reassign a variable I didn’t mean to. I know that a lot of people will complain about how verbose this can be and they’re correct. That’s part of the language, though. I’d love to have all variables set as final by default. Until then, I’ll sprinkle it around every chance I get.
Favorite books
May 13th
I love to read. Every developer needs a few of their favorite books sitting on their desk for quick reference or to loan out. It always gives me pause to come across a developer that doesn’t have any books on their desk. One of my favorite interview questions is to ask a candidate to list a book they’ve read recently or to name a favorite author. You can learn a lot about a person based on the books they have read, which gives you more insight into hiring decisions. Recently, someone asked me about books I’d recommend for someone just getting started or in need of a Java/Dev refresher. There are a lot of great books for that situation, but these are some of my favorites:
|
![]() |
|
|
|
|
What job posting phrases really mean
Mar 24th
A bit of humor for the week….
| Challenging: | We fired the person that wrote all this junk and we need you to clean it up. |
| Self starter: | We won’t be giving you any direction, so it’ll be up to you to sink or swim. |
| Ability to prioritize: | You’ll have 6 projects to work on and they all are the most important. |
| Gets the job done: | You may be asked to do things that are immoral or illegal. |
| Team environment: | Everyone else has already formed a clique and you’ll be the outsider who gets the used PC and the crappy desk. |
| Fast paced: | We require a code slinging monkey hopped up on caffeine, which we’ll provide. |
| Flexible schedule: | We don’t mind if you take a long lunch because we expect you to work nights, weekends, and holidays. |
| Company first: | Resistance is futile. |






