About Me

My photo
Related, I keep most of my code here https://github.com/rdammkoehler

Tuesday, March 17, 2015

Stability?



So in the past two years I have seen several friends and associates leave their jobs as consultants. These are great consultants and good people. I've called each one of them and asked what their motivations for leaving were. I find two reoccurring themes in these conversations.

First I hear the common refrain that they want to be home with their families more often. I get that. I don't have it, but I get it. To be honest, the day that traveling for work becomes a problem for me or my family I will make a hasty exit. So no harm, no foul on wanting to be home with family.

The other common reason I hear is that they wanted more stability. This one I don't get. I keep hearing that changing clients, projects, and work locations is somehow unstable. I don't get that; that is the part that thrills me. Granted, I spend more time at most client locations than many people I know, but changing locations, projects, and clients every two years is what keeps things fresh in my world. I love that aspect of my role as a consultant.

That said, I recognize that there is a lot of anxiety inducing activity in changing engagements frequently. Meeting new people, learning new processes, and finding a good lunch buddy are all problems we face when we start a new engagement. 

So I wonder if the issue is that consulting firms don't do a good enough job of preparing a landing spot for us. There is something to be said for creating camaraderie through shared suffering. But is it that we aren't doing enough to help our consultants settle in, or is it that our consultants aren't prepared for the difficulties they will face with each new engagement?

Conway's Game of Life

I Love this Exercise. Here is a video of me doing the exercise in Java. There are other ways to solve this but this one is simple enough for demonstrating straight forward TDD using Java, JUnit, and Hamcrest.

I have not had time to do a voice over for this yet. What you will see though is me progressively building up the the Rules for Conway's Game of Life through TDD.

If you'd like to learn more about Conway's Game of Life, check this out.

Enjoy.



Thanks to Magnus Stahre () for git-crawl and making this video easier.

Monday, March 16, 2015

What Is a Good Tech Lead?

What Is a Good Tech Lead?

Tech Lead is a role frequently seen on development teams filled by a wide variety of people. Many times the Tech Lead is the most senior person of a technical nature on the team. By senior I mean the person who has the longest tenure. This is frequently a good choice, but not always the right one.

Most often, with age comes wisdom, but this isn't always the case.A long term employee of the same company with limited exposure to external environments is operating in an echo chamber. They lack a diverse experience to use as a sounding board for their ideas or the ideas of the people around them.

So to begin with I think a key characteristic of a Tech Lead is a breadth of experience. The more projects, situations, languages, products and managers a Tech Lead has had, the more likely they are to be good at what they do.

Tech Leads need to be calm and rational people. For any number of reasons projects can get crazy; people shout and threaten and cajole when things aren't going as planned. A good Tech Lead knows that nothing goes as planned and can calmly address issues knowing that most problems are solvable as long as you don't lose your head.

Tech Leads make lots of choices throughout the course of a project. Some have little or no consequences, some have major repercussions. A good Tech Lead knows the difference between these kinds of choices and therefore how much effort to invest in making them. In all cases, a Tech Lead should make those choices with confidence. Where they cannot make those choices confidently a good Tech Lead is open to suggestion and experimentation. In any case the Tech Lead understands the risks and costs associated with making a choice and can weigh the decision appropriately.

Tech Leads need to remain focused. It is important to have good technical depth and breadth, but it is also important to understand when you are out of your depth and have the humility to ask others for help. A Tech Lead should always be willing to delegate to others in order to remain focused on the primary goal of the project: delivering value to the business.

In order to remain focused it is important for a Tech Lead to be passionate. Not just about the objective of a project, but about the technology itself. A Tech Lead should strive for technical excellence in the solution. It isn't just about doing the Right Thing(tm) but also about doing it well.

In order to make this work a Tech Lead needs to have the right disposition. A Tech Lead needs to be simultaneously likable and aloof. Take a hard line on issues that are critical to success while remaining pliable on everything else. Logical and rational without becoming cold and unapproachable. A good Tech Lead should push a team to exceed its own expectations in the quality of their work without breaking their spirit at the same time.

A good Tech Lead should be the team's staunchest defender and biggest cheerleader; A mentor, guide, and leader who approaches every situation with calm rationality and a minimum of ego.

Wednesday, December 1, 2010

Guice, Guice Servlet, Jersey, and the Request Scoped Dependancy

On my current project I've been working with Matt Foy to improve the tests around a rather large application. The original developers chose to use Guice with Guice Servlet and Jersey services to create their application. One of the things that we ran into this week was that we had no tests around the Guice configuration. So while everything seemed OK on the CI server, as soon as we actually deployed the application we discovered that the Jersey servlets would not function because various Request Scoped dependancies had not actually been injected. Basically our Module configurations were a mess and we didn't know it.

So, we created a simple sandbox representation of this problem and then discovered a way to effectively test that the Guice configuration was correct. We must give credit to the authors of Guice for making their test available, this is how we figured it out.

First let us show you the classes that I want to test, note this is highly contrived for the purpose of clarity;

The following servlet is simply in place to allow us to have a servlet with a Request Scoped dependency in a Jersey service.

The Dependancy is simply an implementation of an interface, neither of which contain any methods;

And we have a custom module for creating the Dependency. Note that the Dependancy.class is scoped as @RequestScoped;

And finally, the GuiceServletContextListener that would be used by the Servlet container to do the actual injections at runtime;

Now that you have the context, here's how we solved the problem. The GuiceFilter used by Guice Servlet support conducts the injection activity for the servlet when a request is executed. If you attempt to get, from the injector, any injected instance that is RequestScoped you will get an exception from the Injector indicating that you've requested a resource outside the scope of a Request. It's your own fault really :-).

So, by contriving a filter chain of assertions you can determine if Guice has actually injected the dependencies correctly. Here's how;

First we created this Assertion class;

The assertProvisioningType method allows you to assert that an instance is provided for any type request and that the provided instance is of the appropriate type.

The assertInstantiablity method allows you to assert that an instance is provided for a requested type.

The applyFilterChainAssertion method executes the given FilterChain using the GuiceFilter as the head of the chain. JMock is used in this case to support our current project configuration (Note: We'll be rewriting this with Mockito soon enough.) When you call this method with a FilterChain full of assertions they will have access to the Injector and will be within the Request scope, so you can easily make assertions about them without getting the nasty exception pictured here;

The expose method allows you to directly fetch a Request Scoped instance from the injector for additional testing.

Here is the test suite from our contrived example;

Hope this helps someone.


Sunday, December 27, 2009

An interesting discovery today. I upg...

An interesting discovery today. I upgraded my development environment to Eclipse Galileo/Cocoa-64 yesterday. This caused a class-path issue that was unexpected. As it turns out Galileo packages Junit 4.5, and Junit 4.5 uses a signed version of hamcrest. This conflicts with JMock 2.2.0's hamcrest libraries and causes my tests where mocks are used to break with a java security exception. It looks sort of like this;

java.lang.SecurityException: class "org.hamcrest.TypeSafeMatcher"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:851)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:566)
at java.lang.ClassLoader.defineClass(ClassLoader.java:692)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

So, the first thing I did was update JMock to the newest version thinking this was simply an issue with JDK versions or something. That didn't work, but it's helpful to have the 'latest and greatest' I guess, so no harm done. 
After some quick googling about I discovered the issue was multiple hamcrest libraries and simply changed my class-path order to place Junit at the end of the classpath (after JMock) and voila, problem solved.

So, if your moving to Galileo and your tests with mocks suddenly start breaking, the simple fix is to make sure JUnit follows JMock (and it's version of hamcrest) in your classpath.


Friday, January 23, 2009

Dumbness!

The economy goes to pot and suddenly Google Docs can't publish to my blog without hosing my formatting. My apologize to anyone who just got blasted with 12 consecutive updates about a new post on this Blog. I was trying to fix the formatting errors that Google-Docs shoved out there.


Check-Style is Mental Retardation

<vent>

So I've been working on and off with a development team that uses Checkstyle as part of their ANT builds for projects. The check style rules contain all sorts of arcane rules about code style. Just to give you a taste, the following does not pass muster with this rule set;


1: package format.test;
2:
3: import java.lang.*;
4: import format.util.*;
5:
6: abstract public class CheckstyleHatesThisClass {
7:     public final static String regex = "\\(.*";
8:     public final String terminal = ConstantInjector.fetch("hate.terminal");
9:
10:    abstract public String getDataString();
11:
12:    final public String return_parenthetic_part() {
13:        final String target = getDataString();
14:        if ( target.matches(regex) ) {
15:            return SlicerDicer.extract(regex,terminal,target);
16:        } else {
17:            return "";
18:        }
19:    }
20: }

Begets the following list of complaints from check style;

  • line="3" severity="error" message="Using the '.*' form of import should be avoided - java.lang.*." 

  • line="3" column="1" severity="error" message="Redundant import from the java.lang package - java.lang.*." 

  • line="4" severity="error" message="Using the '.*' form of import should be avoided - format.util.*." 

  • line="6" column="10" severity="error" message="'public' modifier out of order with the JLS suggestions." 

  • line="7" column="18" severity="error" message="'static' modifier out of order with the JLS suggestions." 

  • line="7" column="32" severity="error" message="Name 'regex' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'." 

  • line="10" column="14" severity="error" message="'public' modifier out of order with the JLS suggestions." 

  • line="12" column="11" severity="error" message="'public' modifier out of order with the JLS suggestions." 

  • line="12" column="25" severity="error" message="Name 'return_parenthetic_part' must match pattern '^[a-z][a-zA-Z0-9]*_?[a-zA-Z0-9]*$'."

  • line="13" column="22" severity="error" message="Name 'target' must match pattern '^([A-Z0-9]*_?)*$'." 

  • line="14" column="18" severity="error" message="'(' is followed by whitespace."

  • line="14" column="40" severity="error" message="')' is preceded with whitespace."

  • line="15" column="51" severity="error" message="',' is not followed by whitespace."

  • line="15" column="60" severity="error" message="',' is not followed by whitespace."

  • line="16" column="14" severity="error" message="'}' should be alone on a line."


Now I get that people like to have it 'their way' and can be particular about coding standards, but this is just nuts. I'm not a fan of 'import blah.*', but should that be an error? Or how about white-space between the opening parenthesis and the expression in an if statement, I'm mean come-on people. THis is just stilly. 

I'll give you, I combine all the faux pas I could recall to make my example. But it has not been uncommon for me to do a build and then spend upwards of an hour tracking down and correcting these 'check-style errors'. 

Now, before someone goes off an gets all snippety with me about 'coding standards are important', I don't disagree with that. I think code should be formatted in a readable manner that is acceptable to any casual reader. If it has a few peculiarities, that's OK too. But here is where the retardation comes in, check-style is reactively telling me that I'm doing something 'wrong' when in fact I'm doing something that, while obnoxious, isn't actually 'wrong'. There is a grey area here. 

Wrong would be doesn't compile. Wrong would be it's unreadable. Wrong would be offensive or inappropriate. 

Wrong is not visually unappealing. Wrong is not something other than I would have done.

There is no defensible case for these kinds of rules. None what-so-ever. I know, I've tried to make the case.

Here's a great idea, everyone go get a code formatter, or use the one installed in your IDE. And format the code BEFORE you compile it, without complaint, and be done with it. [Did you know that Eclipse can run the formatted every time you save a file, automagically!]

The pragmatic thing is, does the code do what it's supposed to do? Does it solve the businesses problem? It's totally irrelevant if some dried up bean counting sycophant wants to appease the 'code format gods' with some set of archaic rules about where curly braces go. We can make that appeasement, but lets do it with a proactive solution. 

Anyway, this has been making me nuts and wasting a lot of my time for two months. The only upside is, I get paid to make the corrections. But I feel dirty, wrong, and used making these kinds of fixes; as if I'm not a the jock I like to think I am because I can't un-train myself from years of putting a close curly before the word else or not capitalizing final variables inside a method.

<vent/>