Sergey Shishkin

on agile software development

This Blog Is Moving

I decided to move away from WordPress.com and created an Octopress blog. The new URL is http://shishkin.org. I won’t migrate any content from the old blog, it all stays here for the record in the read-only mode.

Subscribe to my feed if you haven’t done so yet. The feed is powered by FeedBurner and should remain stable.

Written by Sergey Shishkin

02.06.2012 at 10:55

Posted in Uncategorized

My Revised REST Talk at OOP 2012

Last week I attended and have spoken at OOP 2012 in Munich. It was overall great experience and unfortunately, as at each top conference, I often had hard times deciding which session to attend. I learned a lot from thought leaders like Johanna Rothman, Diana Larsen, David J Anderson, Jurgen AppeloMatthias Bohlen, Stefan Tilkov and many more and probably missed some really great sessions and discussions as well. I also used the chance and met my friends in Munich – it was a great time.

My session was titled “REST: you’re doing it wrong” or “REST, du machst das falsch” in German. It was a significantly revised version of the talk I gave at NRWConf 2011 in Wuppertal. This time I enhanced the story a little bit as well as overhauled the whole presentation. I used imress.js framework to create an HTML5 presentation to be shown in browser – no special slideware needed. I very much like the result, though I gathered somewhat mixed experience achieving it. It was particularly troublesome to arrange all the presentation steps on the canvas while working in pixel units. Maybe some layout plugin or template language would help. The presentation also doesn’t work well in all browsers. From the presenter’s standpoint it ok: it works smoothly in Safari on a Mac, but for publishing online it’s a major drawback: Chrome on a Mac has performance and rendering issues while current stable Firefox is not supported altogether. Anyway these issues will be ironed out sooner or later and I’ll probably stay away of any PowerPoint-inspired slideware from now on.

I started the talk with the ironic tale of the ice-cream maker written by Sebastien Lambla. After that I continued with fundamental architectural decisions made by the creators of the Web and upon which REST as an architectural style is based.

Then I moved to common misinterpretation of REST, like claiming that not using SOAP or using JSON for serialization is already RESTful. After that I introduced Richardson REST Maturity Model and started moving the story towards a RESTful system.

First, I talked about resources and their identifiers. It was also important to mention the distinction between resources and representations. It was then obvious that using URI is inappropriate way of specifying a representation (like the API version or language being part of the URI).

I then mentioned the importance of understanding HTTP mechanisms and assumptions it makes against different methods. The most common pitfall in RESTful systems design is from my perspective to stop on that stage and build a CRUD (Create Read Update Delete) service. Though CRUD certainly has its application domain, nonetheless it’s inappropriate for most of the business systems, as the application logic remains outside of the application – like an Excel spreadsheet, where the user just edits raw data instead of fulfilling business tasks.

The natural step from a system designed out of HTTP methods is a system designed out of resources, where each business task is a resource. This is almost the same principle we use for ages building web applications. Such a system can leverage well-known mechanics of hyperlinks and forms to provide a truly RESTful API.

The HTML5 presentation is available on GitHub pages. You can also be interested in the previous PowerPoint version with speaker notes over at Slideshare.

Update: There is also a ~5.8 megapixel poster of the overview slide in PNG format if the impress.js version doesn’t happen to work for you.

Written by Sergey Shishkin

01.02.2012 at 17:51

Posted in Presentations

Upcoming Events

Quite busy time is approaching me and I really look forward to it. Here are some of the upcoming community activities from my agenda:

31.08.2011—.NET Coding Dojo at DNUGRR

As a good tradition every other month .NET User Group Rhine/Ruhr organizes a coding dojo in Ratingen. This time we get more interactive and learn TDD as if you meant it altogether in pairs. If you are around and want to join us, you’re welcome!

1–3.09.2011—Software Craftsmanship and Testing

New European software craftsmanship community is emerging and I’m very glad to participate in this two day-long intense community fusion:

This event is about the sustainable creation of useful software in a responsible way.

It consists of two days of highly collaborative interactions, including Lightning Talks (on Thursday evening), scheduled sessions (on Friday), and a self-organized Open Space (on Saturday).

The event will be much like a retreat. We will be there for 48 hours to collaborate and share ideas.

I will present practical experience with Specification by Example, I gathered working with an agile team back in 2010. Gojko Adzic has written THE book about Specification by Example, which I highly recommend. Want to discuss this topic? Register for SoCraTes 2011!

9.9.2011—NRWConf in Wuppertal

It is a great honor for me to be part of this year’s line up of speakers at NRWConf. My session on REST is focused on why is true REST so much different than WS-* and CRUD POX services. Want to avoid common mistakes and leverage the web platform, join me in Wuppertal.

16.09.2011—Professional .NET in Wien

Austrian .NET community hijacked Greg Young for a day to speak about all things CQRS. I just can’t miss such an opportunity to see hilarious Greg speaking, neither should you! As part of the event I will be speaking about NOSQL and why it is becoming even more attractive for separated read and write data models.

2-3.11.2011—prio.conference 2011 in Nuremberg


This year’s prio.conference is focused on cross-platform development and I think that the web platform is currently the closest realization of that vision. That’s why I was so excited, that my talk proposal about “getting REST done right” was accepted. In contrast to my NRWConf REST talk, this one is focused more on concrete examples of how to get things done following the REST way, rather than pointing at failures and pitfalls.

So, next months are going to be tough, but I look forward to meet bunch of interesting people and be inspired and energized by the community!

Written by Sergey Shishkin

19.08.2011 at 21:25

Posted in Uncategorized

Code Retreat Düsseldorf

…or how I learned to stop worrying and love deleting the code.

Yesterday I had a great opportunity to participate in a very enlightening and thought-provoking activity, named Code Retreat, in Düsseldorf! It was smoothly conducted by Daniel Temme and Adrian Bolboaca and hosted by codecentric AG. The idea of the code retreat is very simple: use TDD and Pair Programming technics to automate Conway’s Game of Life in sessions of 45 minutes …but delete all of your code after each session!

What?! Delete code?! But how am I supposed to get the job done?

The point is not to get something done, but to exercise the technics of test-first development and simple design. This looks silly and pointless at first and is indeed really hard.

But it all look pretty simple at first. In the first session my pair and I haven’t even come to the game rules. We started with some examples, that we represented as strings. Then we were writing a parser, that would take string representation of the game grid and provide a two-dimensional array with Boolean flags, indicating life, so that we could feed our examples into the game engine. It seemed a logical top-down approach to me at first, but proved itself meaningless.

After the session we all together discussed any findings and ideas that we got out of the session. Adrian was provoking us with questions like: Why do you need an array? Where this Cell class came from? etc.

So the next session we changed pairs (this is a rule of Code Retreat) and started all over again. This time we focused on game rules, test naming and abstractions, but were still unable to make very small baby steps with our design. Abstractions just spawned out of nowhere (out of our head, actually) and made it right into the code. We discussed it after the session and decided to treat the imaginary design obsession syndrome with a very restrictive diet…

TDD As If You Meant It

Gojko Adzic described this brilliant exercise originally proposed by Keith Braithwaite back in 2009. It’s very simple:

    1. write exactly ONE failing test
    2. make the test from (1) pass by first writing implementation code IN THE TEST
    3. create a new implementation method/function by:
      1. doing extract method on implementation code created as per (2), or
      2. moving implementation code as per (2) into an existing implementation method
    4. only ever create new methods IN THE TEST CLASS
    5. only ever create implementation classes to provide a destination for extracting a method created as per (4).
    6. populate implementation classes by doing move method from a test class into them
    7. refactor as required
    8. go to (1)

Despite of the simplicity of the rules, it’s very hard to follow them. But it works. Design gets in fact much simpler and it really gets derived from tests.

Conclusion

We did 6 sessions during the day. I programmed 3 times in Java, 2 times in C# and one time in Ruby. Switching languages is great exercise in itself. No matter what language, testing framework or IDE/Editor we used – the most important concern was to understand the problem domain, codify it in tests, and let simple design solve it.

Throwing out code is not only useful as an exercise. I can imagine a Code Retreat workshop as a way to understand a very complex core domain (in DDD sense) in productive development.

After the event I felt exhausted and energized at the same time. I realized that I barely did any TDD before, but I learned where to start and how to proceed my learning. All in all it was the densest coding activity I ever had. Really look forward to participate in another Code Retreat soon and will do my best to organize the next one in Düsseldorf!

Written by Sergey Shishkin

19.06.2011 at 19:41

Posted in Uncategorized

Coding Dojo @ .NET User Group Rhine/Ruhr

Last month we had a coding dojo on a user group meeting in Ratingen. This was the first coding dojo for most of the user group members and I was allowed to facilitate it. As a big fan of Ilker’s style coding dojos for his entertaining talent I wanted to deliver an energizing experience to the attendees if anything at all. So instead of throwing people at kata right away and watching them arguing which unit-testing framework to use I decided make a “demo of a coding dojo”.

Imagine yourself sitting in a racing car having never seen a race and knowing only how to ride a bicycle. Now go on and have fun on a track. Two hours later you already can start the engine and release the handbrake.  Was it fun? Will you come next time to learn how to shift gears? I doubt. Now Imagine somebody took you for a drifty ride. Now it makes sense! Now there is even a point to learn it yourself. The same way I learned to love coding katas: by watching masters (like this one) doing them.

I choose a modified version of the String Calculator Kata: instead of just adding numbers joined to a string, I aimed to implement an arithmetic expression evaluator (“1 + 2” –> 3). My tools for this kata included VS2010, C#, Resharper, xunit.net as testing framework, and Should as a fluent assertions library.

The thing I like most about TDD is that the whole software design emerges out of a consequence of simple decisions. Each design is unique and none is the right one. You can follow my implementation on Github, I’ll just list here most noticeable steps:

The first feature was to evaluate a decimal constant. The simple “double.Parse(expression)” method did the trick.

The next one was a simple addition. The “string.Split(‘+’)” is obvious to extract the arguments of addition, the next step is however that same little design decision that defined the whole solution. Instead of manually juggling array indices I used my favorite .NET API – Linq. So, to add the arguments from a string array I wrote the following:

return expression

    .Split('+')

    .Select(x => double.Parse(x))

    .Aggregate((a, b) => a + b);

Now implementing multiplication was analogous. The resulting code duplication was an obvious smell though. I always forget those fancy functional slang, but the point was to effectively build a pipeline of functions, where each function is applied to the result of the next one in the pipeline. Then the only thing to do is to call that pipeline as a function and pass it the original string expression. The whole solution looks like this:

public class Calculator

{

    private static readonly Func<string, double> Parse = double.Parse;

    private static readonly Func<string, double> Pipeline = Parse

        .Wrap(‘*’, (a, b) => a*b)

        .Wrap(‘/’, (a, b) => a/b)

        .Wrap(‘+’, (a, b) => a + b)

        .Wrap(‘-‘, (a, b) => a – b)

        ;

    public double Evaluate(string expression)

    {

        return Pipeline(expression);

    }

}

public static class PipelineExtensions

{

    public static Func<string, double> Wrap(

        this Func<string, double> inner,

        char split,

        Func<double, double, double> aggregate)

    {

        return expression => expression

            .Split(split)

            .Select(inner)

            .Aggregate(aggregate);

    }

}

It definitely doesn’t take parenthesis into account, but it quite elegantly solves four arithmetic operations with operator precedence and more than two arguments and more than one operator per expression. Without using Linq I would probably go with a bunch of if/else statements being than refactored into an expression parser and an expression tree evaluator (which is a way to go for supporting parenthesis). Anyway for the first iteration I implemented all the features I wanted and ended up with very little code, which I don’t mind to throw away if it doesn’t fit anymore. And this is a true virtue of TDD.

The next Coding Dojo at the User Group Rhine/Ruhr will be on 27th April, hosted by MT AG in Ratingen. Follow announcements of the UG or sign up at Xing.

Written by Sergey Shishkin

11.04.2011 at 16:15

Posted in Uncategorized

Binding Explicit Interface in Silverlight and WP7

Yesterday I faced a quite annoying limitation of Silverlight (and of its Windows Phone 7 variant). Due to the lack of cross-assembly private reflection Silverlight’s Data Binding is unable to bind to explicitly implemented interface properties. No, I wasn’t jail-braking the phone, all I wanted to do was to bind some hierarchical data control to a LINQ Grouping. Unfortunately IGrouping<TKey,TElement> is implemented in .NET not just by internal classes (as usual, ARRRGGHH!!!) but in addition explicitly. Fine!

Others confronted with the same problem gave up by writing a public wrapper class exposing a public Key property, binding-ready. Although that solution worked I felt wrong polluting all the queries in my view model because of Silverlight data binding limitations. Another interesting approach proposed by Christopher Bennage on Stack Overflow used a Value Converter to get the Key property of a grouping. Now it looked much better in terms of separation of concerns, but the converter was hard-coded to work with IGrouping<string, MyDomainClass> only. Remember? No cross-assembly private reflection.

I tried to tweak the converter approach with no luck:

  • LINQ expression tree code generation didn’t work without Reflection.Emit.
  • Casting to IGrouping<object, object> didn’t work without co-/contra-variance in WP7

So after pulling some hair out of my head I found a rather simple solution. The Key property on the interface itself is obviously public. It is indeed possible to use reflection to get the property value if only you use a PropertyInfo from the interface, not from the implementing type.

The resulting universal value converter looks like this:

public class ExplicitPropertyConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value == null ? null : GetPropertyValue(value, (string)parameter);
    }

    private static object GetPropertyValue(object target, string name)
    {
        return (
                from type in target.GetType().GetInterfaces()
                from prop in type.GetProperties()
                where prop.Name == name && prop.CanRead
                select prop.GetValue(target, new object[0])
            ).FirstOrDefault();
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

And the usage from XAML is like this:

<TextBlock
    Text="{Binding
        Converter={StaticResource ExplicitPropertyConverter},
        ConverterParameter=Key
    }"
    />

This is almost the right way from my perspective (the right way would if data binding in Silverlight just worked, but it’s not what Microsoft developers are accustomed to anyway). The converter itself is implemented as a cross-cutting concern, being able to bind any interface property. The only notion of this workaround is in XAML data binding, where it belongs. Of course I wish Silverlight, and especially WP7, was a real thing and not that creepy lame castrated shade of .NET, standing in my way to be more productive. Rant over…

Written by Sergey Shishkin

18.01.2011 at 11:34

Posted in Uncategorized

First Success With Heroku

Recently I moved my blog away from Live Spaces to WordPress.com. I remember myself a few years ago comparing Live Spaces and WP among other blogging platforms, I bought in to Live’s tight integration of the blog engine, the SkyDrive and the Live Writer. That was definitely not my best decision as recently Microsoft announced that they are discontinuing Live Spaces and all users are kindly requested to move their blogs to WP. The migration procedure took just several clicks and I got my whole blog with all the comments on WP. One thing I missed after Live Spaces however was custom domain redirection. I want my domain – shishkin.org to point to my blog, but this is a premium feature at WP that costs money. After no luck with DNS configuration at my registrar I headed to cloud solutions.

And here comes Heroku. Heroku is a ruby hosting platform in the cloud, which is free for small demands and feature rich, rock-solid and scalable when you need it. So I decided to build and host at Heroku an absolutely dumb HTTP Ruby application that should redirect all the requests to my blog at WP. Thanks Heroku Custom Domains I was able to host my small dumb app for free with my custom domains (shishkin.org and www.shishkin.org).

The application itself is a simplest Rack application:

class Redirect
  def call(env)
    [301, {
      "Location" => "https://shishkin.wordpress.com",
      "Content-Type" => "text/plain"
    },
    ""]
  end
end

run Redirect.new

That’s it! Using simple Heroku documentation I was able to build, test and deploy my little app in minutes. Heroku’s git-based deployment is somewhat cool. It just can’t be simpler given that each Ruby developer probably has git installed already.

As for Rack, I think it’s an awesome framework we really miss in .NET. After being intrigued by Rack’s ultimate simplicity and extensibility I watched TekPub’s episode on Rack and started to watch the Sinatra series. Now I’m intrigued even more Winking smile Rob Conery does a great job of getting .NET developers out of their comfort zone and provoking us by showing how simple software development can really be on the other side of the fence.

To summarize, I finally did something productive with Ruby! I solved my real-world problem (not that big for sure), I solved it simple, fast and elegant. And I learned a lot along the way.

Written by Sergey Shishkin

29.11.2010 at 21:44

Posted in Uncategorized