DWX 2016 – day 2

Halftime. On the second day of the conference I concentrated on .NET development.

The day started for me with Carsten König who gave an introduction to F# – Funktionale Programmierung mit F#. It was a good talk although only few things were really informative for me. One of my highlights so far followed: akka.net – Einführung in das Actor Model mit .NET held by Ralph Waldenmaier. He gave a very good overview and background information on that topic. I am surely going to try out the actor model in an eligible project! Normally, databases are not one of my favourite topics. But Constantin ‘Kostja’ Klein told us about Database Lifecycle Management. I found his information very useful, for they perfectly go with our actions taken to improve the lifecycle management of our software. He showed me how we can add the database aspects to that process.

In the afternoon, there were two DevSessions. David Tielke talked about .NET Core. It comprised great background information about the .NET Framework as well as about the new .NET Core. David explained very well what Microsoft’s strategy change means to us as developers. The last session was WPF Troubleshooting in Visual Studio 2015. Manuel Meyer presented very useful debugging and analysis tools that are free of charge and that help to find issues in .NET applications. Some of them are even part of the Visual Studio. In particular, Manuel concentrated on WPF applications. Very exciting and informative talk, too!

Now, I’m preparing my schedule for tomorrow.

DWX 2016 – day 1

This is a short report of the 1st day of the Developer Week (DWX) 2016 currently held at Nuremberg. I was here for the first time last year. For it was an impressive event, my expectations were very high. What shall I say, I am not disappointed. Again, the sessions are divided into 10 thematic tracks. The choice is hard. The good thing is that the slides of the talks are all available later.

The conference started with a great keynote by Jurgen Appelo who told us about Managing for Happiness, which was quite inspiring. Then, I listened to David Tielke who proposed an overview over the Composite Components Architecture. Although it was not really new to me, there were some interesting thoughts and approaches I will share with my co-workers. David Würfel informed us about some core tools regarding WPF development. His talk was named The WPF First Aid Kit. The last two talks today for me were given by Andi Grabner. They both were about metrics, Top Performance Fehler in .NET and Metrik gesteuertes DevOps und Continuous Delivery, respectively.

To sum it up, the sessions today were either an eye-opener to me or gave me some deeper insight or a new approach to things I already have in mind.

So far, the event brought valuable information to me personally as well as to my daily business life. As it did last year…

Be curious about my report tomorrow.

New blog theme, too

After having upgraded my blog software recently, I changed its theme today as well. The new look is more modern with respect to design and technical aspects. The second reason was that the previous theme isn’t supported any more, the author has ceased further development.

I have done some minor adjustments, but maybe there is still some work to do. I think, the next days or weeks will tell.

If you want, you can drop me a note about how you like the new design.

Blog software upgraded – at last

I have just upgraded my WordPress software to the latest version. The (major) software upgrade took 10 or 15 minutes. There were no problems.

I hesitated long time. Maybe the reason was that I do not post regularly. It looks like I am a little bit trapped in the daily grind. There are some interesting things to share with you, though.

Currently, I feel a new drive to revive my blog. This is because I am occupied with many exciting things regarding different aspects, e.g. code style, software development process, personnel management. So, I am quite sure that my frequence of posting will increase in the near future!

String extensions using LINQ

Some days ago, I encountered this C# code which defines some more or less standard string operations:

using System;
 
namespace My.Extensions
{
    public static class StringExtensions
    {
        public static string Left(this string s, int count) {
            if(count > s.Length) {
                return s;
            }
 
            return s.Substring(0, count);
        }
 
        public static string Right(this string s, int count) {
            if(s.Length <= count) {
                return s;
            }
 
            return s.Substring(s.Length - count, count);
        }
 
        public static string Shorten(this string s, int count) {
            if(s.Length < count) {
                return String.Empty;
            }
 
            return s.Substring(0, s.Length - count);
        }
    }
}

Personally, I don’t like this kind of implementation. It looks too technical to me. The string manipulations, the condition checks – it’s completely from a technical point of view.

There is a way to implement that functionality in a descriptive way which makes it look more aesthetic. The key is to understand a string as a sequence of characters. Let’s try to rewrite the extension methods using LINQ:

using System.Linq;
 
namespace My.Extensions
{
    public static class StringExtensions
    {
        public static string Left(this string characters, int number) {
            return new string(characters.Take(number).ToArray());
        }
 
        public static string Right(this string characters, int number) {
            return new string(characters.Skip(characters.Length - number).ToArray());
        }
 
        public static string Shorten(this string characters, int number) {
            return new string(characters.Take(characters.Length - number).ToArray());
        }
    }
}

Better? In my eyes, yes! The code is shorter, it looks more precise. The core part of the methods is extremely descriptive. The methods meet their respective purpose by taking or skipping a certain number of characters of the input string – nice.

Unfortunately, there is one thing that is not so nice. There is some noise in the above implementation. We are forced by the .NET framework to switch from IEnumerable to string making a detour via an array of char. But by introducing another extension method, we make our short code example a little bit more readable again:

using System.Collections.Generic;
using System.Linq;
 
namespace My.Extensions
{
    public static class StringExtensions
    {
        public static string Left(this string characters, int number) {
            return characters.Take(number).AsString();
        }
 
        public static string Right(this string characters, int number) {
            return characters.Skip(characters.Length - number).AsString();
        }
 
        public static string Shorten(this string characters, int number) {
            return characters.Take(characters.Length - number).AsString();
        }
    }
 
    public static class EnumerableExtensions
    {
        public static string AsString(this IEnumerable characters) {
            return new string(characters.ToArray());
        }
    }
}

And exactly this is the driving force behind all the code changes we made here: readability! Code should be simple, readable, and self-explanatory.

So, what’s left? With respect to self-explanation, we maybe can find better names for the string extension methods. As the saying goes, I leave this as an exercise for you…

Just to mention, the original implementation as well as the one developed here satisfies this specification:

using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace My.Extensions.Tests
{
    [TestClass]
    public class MyExtensionsSpecifications
    {
        private const string Abcdefghij = "abcdefghij";
 
        [TestMethod]
        public void The_first_5_characters_of_abcdefghij_are_abcde() {
            Assert.AreEqual("abcde", Abcdefghij.Left(5));
        }
 
        [TestMethod]
        public void The_first_50_characters_of_abcdefghij_are_abcdefghij() {
            Assert.AreEqual(Abcdefghij, Abcdefghij.Left(50));
        }
 
        [TestMethod]
        public void The_last_3_characters_of_abcdefghij_are_hij() {
            Assert.AreEqual("hij", Abcdefghij.Right(3));
        }
 
        [TestMethod]
        public void The_last_20_characters_of_abcdefghij_are_abcdefghij() {
            Assert.AreEqual(Abcdefghij, Abcdefghij.Right(20));
        }
 
        [TestMethod]
        public void abcdefghij_shortened_by_4_characters_is_abcdef() {
            Assert.AreEqual("abcdef", Abcdefghij.Shorten(4));
        }
 
        [TestMethod]
        public void abcdefghij_shortened_by_12_characters_is_an_empty_string() {
            Assert.AreEqual(string.Empty, Abcdefghij.Shorten(12));
        }
    }
}

When a debugger is needed

Something became clear to me when I attended a Code Review last week. The code we reviewed was written by a co-worker who is quite new in the business, i.e. who passed his academic studies not long ago and has never worked as a software developer before – so let’s call him a newbie. And of course, there was this unbelievable implementation of a class method: All concerns were present in that single method, and you may imagine the length of that method.

So I asked, why all these things are in one single method. His answer was that it is difficult when the debugger jumps from method to method and from class to class. So, it would be better to have it all in one method. Having the logic spread over the whole solution appeared too difficult to him. He needed the debugger to understand what was going on.

Now, what do I have learned from that?

A debugger is needed when the code rules us, when we don’t understand the code just by reading it. It should be vice versa: We should rule the code! Then, no debugger is needed to understand the code.

So, let’s rule the code! I am quite sure you know what you have to do to obtain that.

(Just a short note: A debugger may be used during talks or Code Reviews when you want to show some internal states or just to demonstrate something. Or as the last resort when hunting a bug. In my eyes, these are scenarios where a debugger is useful.)

The dotnet Cologne 2012

Wow, wow, wow. The 4th dotnet Cologne was a great event – once again! It was held at the KOMED for the second time. It is a location quite good to reach by car or public transport. 350 people met there to get information and ideas from speakers who are developers themselves. This year, a great number of the sessions dealt with the new Microsoft technologies and products such as Windows 8, WinRT, Visual Studio 2012, and SQL Server 2012. The other session topics were a mixture of agility, software technology, etc., as usual. The conference was organised in five tracks plus one additional Microsoft track. The latter comprised of sessions held by Microsoft Evangelists. Bad thing, you were spoilt for choice…

It was nice to see that JetBrains was present with a booth and two talks (on their products ReSharper and YouTrack). It was for the first time, so I went to their booth and had an interesting conversation. Anyway, talking to other participants and exhibitors is as much important as the conference sessions.

My highlight session was Rainer Stropek talking about WinRT! It was a great technical deep dive. Johannes Hofmeister shared his thoughts about Empathic Code (i.e. how code should look like with respect to readability) with us which urged me to nod the whole time. Besides that, I was interested in CQRS, some C# goodies, Windows 8 for .NET developers, and in what is new in Visual Studio 2012. Again, it was hard to pick the best sessions of that broad offering.

PS: The next dotnet Cologne is on 3 May 2013!

Googled by ‘scrum master coding ability’

Recently, my blog was found by a search engine using the search term ‘scrum master coding ability‘. I think, somebody asked here for the programming skills of a Scrum Master. This makes me feel urged to a short reply.

So, should a Scrum Master be a skilled programmer? In my eyes: Definitely yes!

Why? Well, I think, that is quite obvious. One aspect of the the Scrum Master role is his responsibility for the team. The Scrum Master has to improve the team. There are a lot of facets of what can be improved, one of these are programming skills for sure. Improving the programming skills lead to better code, to clean code in best case. If a Scrum Master finds his team (or a part of it) needing some help in that area, he has to coach it. First, this requires that a Scrum Master is able to recognise this. And second, the Scrum Master must be able to demonstrate to the team better techniques, best practices, and so on. (This is not meant as a prescript for the team. It is more a hint how things may go better. Still, the team can decide in what way it wants to work.) Therefore, to fulfil this part of his role, the Scrum Master must own programming skills!

By the way: Meanwhile, it should be clear what my understanding of a skilled programmer (or better: skilled developer) is. It is not only the knowledge of one or more programming languages, frameworks, and development environments. It is rather the things, that CCD comprises, behaviour/test driven development, domain driven design, design patterns/principles, just to name a few… I think, both sorts of skill are requirements for a skilled programmer which make him a skilled developer then.

Guia: A new tool for automated UI testing

I have started to play around with UI Automation in order to write automated UI tests. There is a lot to do for a setup of such tests. So I am wondering if there is already a framework for this purpose. After asking the internet a bit I found Guia on Codeplex. It seems to be the right tool for us. The key features from my point of view are:

  • It works with WPF and WinForms.
  • No compiled application is needed, windows and user controls can be tested stand-alone.
  • NUnit is supported.

The project is on a very, very early stage. So I keep an eye on it for it really seems to be a useful thing for us.

Update (29 July 2011):
Sadly, the project does not make any progress at all. We have meanwhile implemented our own framework which of course fits our needs perfectly.

Gandalf the White (in CCD terms)

By reaching the final white CCD degree I put on my white wristband today. So, from now on I have to obey all the principles and practices that the previous CCD degrees comprise. That is quite challenging in my eyes, for I have to keep an eye on many aspects of the whole development process. But it is worth it! It is obvious that my code has become cleaner since I read Uncle Bob’s Clean Code which was the source for the CCD idea.

Regarding the title of this post, it really feels like being on the developer’s next evolution level. Many things have become clearer to me. As I wrote before, most of the clean code ideas are not new, but they are brought together and verbalised in a quite concise way now.

One of the main points of the CCD approach is the perpetual focusing on a subset of the CCD principles and practices, i.e. on the different CCD degrees. That means, although having reached the final degree and thus keeping in mind all principles and practices, one works on the “coloured” degrees with their specific focus again and again. This is because repetition is a good teacher. Additionally, the principles and practices are not fixed, they are changed or modified from time to time. For example, the degrees comprised rules at the beginning; these have merged into the principles and practices completely.

Definitely, I will follow this track!