Pages

Saturday, October 31, 2015

Presenting at the conference

Yesterday there was an in-house tech conference at stratton finance and was a part of it. Moreover - that was my first experience at presenting something in Australia!
First thing first - I really enjoyed it. And I`ve leaned a lot from the presentation itself and from preparation to it.

My topic was 'Docker containers'. I haven't used docker before so first thing I did was just a fresh installation of the docker to my Ubuntu laptop. Somehow I failed to install using official tutorial - so had to install it differently :) And when all was done I was able to pull few containers and run them - great success! Maybe, soon I`ll start using it mush more and not only locally...

We are at stratton not using docker at the moment so my presentation was a kind of 'what we can use'. Others were more about what are we using at the moment/what we will be using next week. I am not sure if this was good or not, should the theme of the conference be more focused?

Probably, the most important lesson I've learn was the obvious one - you need to prepare your speech. I was lazy and combined the presentation only the night before the event. My speech was not prepared at all - just few bullet points, almost duplicating the presentation. Surprisingly that was almost enough - I just forgot the name 'Core CLR' I wanted to use and it was an awkward pause. But other then that I hope my talk was smooth and interesting. Heh, I should ask for a feedback tomorrow!

As I said, I really enjoyed it and if the feedback would be positive enough I am going to start presenting at local meetups!


Thursday, October 22, 2015

Nullable comparisons simplified with LINQ

What if you need to compare few nullable values? For example, you store latest call date and latest email date and need to define the latest contact date - either call or email. The simplest approach in that case probably is

DateTime? callDate, emailDate;

var latestDate = callDate ?? emailDate;
if (callDate.HasValue && emailDate.HasValue)
    latestDate = callDate > emailDate
                ? callDate
                : emailDate;

Simple and straightforward. Especially if you have read Eric Lippert`s blog post about nullable comparisons. But what if you have third option - liveConversationDate? Or something even bigger? Writing all those conditions one by one can be troublesome.
I found that LINQ is the simplest approach. Just combine all values into a list, filter out nulls (or apply your business rules) and order it!

 int? a, b, c;
 a = null;
 b = 5;
 c = 3;
 
 var res = new List<int>() {a, b, c};
 Console.WriteLine(res.OrderByDescending(i => i).First());
 Console.WriteLine(res.OrderBy(i => i).First());
 Console.WriteLine(res.Where(i => i != null).OrderBy(i => i).First());