Tuesday, June 30, 2015

Architects’s dream, Developer’s nightmare

Great article by Martin Fowler on Dr.Dobb’s about Errant Architectures.

As a (lead) developer/tech lead/application architect this probably happened to you before: you start on a new project and the first day you arrive, the (enterprise) architect shows you proudly his nice architecture; you know; this thing with all the arrows and boxes.

You hear the architect explaining; “…And every box runs on its own server…” “…bla bla bla…” “…And performance is critical…”.

Now without hearing any other part of the conversation, you know you are in trouble. Especially if some micro services flavor is added to the mix. This is a recipe for disaster. The architect forgot the First Law of Distributed Object Design: Don’t distribute your objects!

But how you are going to tell this to the architect, especially on your first day on the job?

The answer is simple, forward the link about this article to your architect.  Glimlach

Dilbert

Monday, June 29, 2015

ReactiveUI Design Guidelines

Learning Reactive Extensions and Reactive UI can be quiet challenging. There are a lot of new concepts you need to wrap your head around. GitHub, one of the companies that use Reactive UI (for building their GitHub for Windows app), shared their ReactiveUI Design guidelines with the rest of the world.

Thanks guys!

image

Friday, June 26, 2015

Podcasts I started listening to…

I’m a long time listener to DotNetRocks and HanselMinutes. It helps me through the hours I’m stuck in traffic jams. Recently I started working for a customer in the Netherlands, meaning that my travel time increased a lot. Even in such a way that I listened to podcasts faster than they could product them. Time to search for some extra content to listen to…

After trying multiple others podcasts, I ended with these 2 podcasts from DevChat.tv:

image

 

image

Great content and great quality!

DevChat.tv hosts some other podcasts as well. Definitely worth checking out…

Thursday, June 25, 2015

ReactiveUI - The base class or interface 'Splat.IEnableLogger' could not be resolved

I’m building an application where I’m experimenting with ReactiveUI, an MVVM framework built on top of the Reactive Extensions. It’s the perfect fit if your application has a lot of interactivity and data that changes a lot.

image

When I started using it, after installing the “reactiveui” nuget package, it immediately failed with the following error message:

The base class or interface 'Splat.IEnableLogger' in assembly 'Splat, Version=1.6.2.0, Culture=neutral, PublicKeyToken=null' referenced by type 'ReactiveUI.IReactiveObject' could not be resolved.

It is an annoying issue in the NuGet package where ReactiveUI.Core has a dependency on a Splat version >= 1.0. according to the package configuration.

image

The problem is that the  latest version of Reactive UI couldn’t work with older Splat versions. After updating Splat to the latest version, the issue was solved. I hope the creator of the NuGet package fixes this, as this is really annoying for everyone that wants to start using ReactiveUI.

image

Wednesday, June 24, 2015

Mommy, there is an Xbox 360 hidden inside my Xbox One

After a long time without gaming, I couldn’t resist any more and got an Xbox One. Last week at the E3 conference, Microsoft announced its plans to bring Xbox 360 games to the Xbox One. To achieve this Microsoft built an Xbox 360 emulator that runs on the Xbox One.  Great!

Time to buy Mass Effect

 

Tuesday, June 23, 2015

Team Foundation Server–Print the list of active TFS users

Today I got a request to print the list of active TFS users. I first tried to get this information through the Team Foundation Sidekicks, but unfortunately I didn’t found an easy way to extract the list of users from this otherwise great tool.

In the end I used a different approach:

  • Open SQL Server Management Studio
  • Connect to your TFS Database instance
  • Execute the following query for every collection database:

Monday, June 22, 2015

ASP.NET MVC 5 and the [AllowAnonymous] attribute

In ASP.NET MVC 4 the [AllowAnonymous] attribute was introduced. This attribute made it a lot easier to secure your whole ASP.NET MVC application. What it allowed you to do is to use a global authentication filter for your application and only allow anonymous access to your login(and register) page. Before you had to add the authorize filter to every controller as there was no way to override the filter when registered globally.

So far the good news… The problem is that in ASP.NET MVC 5, the security model was slightly changed with the introduction of authentication filters. Prior to authentication filters, developers used the Authorization filters to drive some of the authentication tasks for the current request. These tasks can now be separated out to a new custom authentication filter and authorization related tasks can be performed using authorization filters which provide a clean separation of concerns.

The problem is that this new separation doesn’t play nicely with the [AllowAnonymous] attribute. Although you would expect that AllowAnonymous would work at the authentication level, it doesn’t. Instead it is still coupled to the AuthorizationFilter. Why? To not break backwards compatibility.

To fix this and make AllowAnonymous work with the AuthenticationFilter I created my own implementation:

Wednesday, June 17, 2015

Time for some self-reflection…

Close your curtains, find yourself a cozy chair, browse to the following link;http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/ and start reading What is code? by Paul Ford. In one of the longest articles I’ve ever read online, Paul brings some new, insightful, sometimes funny, sometimes painful reflections about the software industry, software development, programming languages, developer conferences,  coding and many more.

keep-calm-and-take-some-time-to-reflect

A must read for everyone who is in any way involved in the IT business…

Tuesday, June 16, 2015

Nice quote

There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.

C.A.R Hoare

Monday, June 15, 2015

Web Performance Optimization: Limit Web Font size

After using images for years, I switched to using web fonts a few years ago and never looked back. Thanks to web fonts you can use (almost)any font combination you want in your website without rendering it to an image first and embedding it into your page. You can now easily change the font of your website without replacing all the images. I don’t miss the old times…

The only disadvantage that web fonts have is that they add some overhead to your website as the font should be loaded first. However if you are using Google Fonts than there are some neat tricks to limit the extra cost.

Trick 1 – Specify the exact text

If you only need some specific letters, you can specify them:

http://fonts.googleapis.com/css?family=Open+Sans&text=Test

Trick 2 – Specify a subset

Another thing you can do, is limit the character set that you use:

http://fonts.googleapis.com/css?family=Open+Sans&subset=latin

Trick 3 – Specify multipe fonts

If you use multiple web fonts in your website, you can download them all in one request:

http://fonts.googleapis.com/css?family=Open+Sans|Roboto

Friday, June 12, 2015

Specflow and Xamarin

I’m a big fan of BDD and SpecFlow in particular. Last month I did a session about Specflow for my colleagues in the Netherlands. One of the questions I got during the presentation was if it was possible to use Specflow together with Xamarin. My short answer was “yes”. I promised to write a follow-up post explaining all the details.

When I started writing this post, I stumbled over Rob Gibbens ‘BDD Tests with Xamarin.UITest and SpecFlow’ post where he explained everything much better than I could do myself. He even included some sample code.

 

Thanks to Rob, I don’t have to write this post anymore and start my weekend a little bit sooner. Great! Glimlach

Thursday, June 11, 2015

TypeScript–Set the version of the generated JavaScript

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. What most people don’t realize is that you can control the JavaScript version that is generated by the TypeScript compiler. By default it will generate EcmaScript 5 compliant JavaScript, but you can change this if you need/want.

To do this, right-click on your project and choose Properties. Go to the TypeScript Build tab. There is a drop down where you can choose the ECMAScript version.

image

Wednesday, June 10, 2015

System.InvalidOperationException : DataTableReader is invalid for current DataTable 'Customers'.

Aaah… The good old times. I had to add a bug fix to a project I worked on years ago. This was before ORM’s were mainstream so all data access was done through DataTables and DataReaders. While fixing the bug, I wanted to add an extra test to verify if my solution worked without having to go to the database.

This is actually really easy when using DataTables because you can create them in memory:

Inside my code I was using an IDataRecord so I used the CreateDataReader() method to get a DataReader object that implements the IDataRecord interface.

image

I pass the created reader to my method:

However when executing this code, it failed with the following cryptic message:

System.InvalidOperationException : DataTableReader is invalid for current DataTable 'Customers'.

What was the problem? Before the IDataRecord interface inside the DataReader can be used, you should call the Read() function first.

Tuesday, June 9, 2015

TypeScript–Compilation failed for d.ts files

A colleague was working on a web application and decided to make the switch from regular JavaScript to TypeScript. To get the type system happy, he loaded the necessary Type Definition(.d.ts) files for jQuery and some other external libraries he was using in this project.

After doing that, he got a long list with compiler errors inside the type definition files. Here is a subset of the errors he got:

jquery.d.ts(279,61): error TS1005: '=' expected.
jquery.d.ts(279,64): error TS1109: Expression expected.
jquery.d.ts(279,97): error TS1005: ',' expected.
jquery.d.ts(279,118): error TS1005: '=' expected.
jquery.d.ts(279,121): error TS1109: Expression expected.
jquery.d.ts(342,40): error TS1005: ',' expected.
jquery.d.ts(342,61): error TS1005: '=' expected.
jquery.d.ts(342,64): error TS1109: Expression expected.
jquery.d.ts(342,103): error TS1005: ',' expected.
jquery.d.ts(342,124): error TS1005: '=' expected.
jquery.d.ts(342,127): error TS1109: Expression expected.
jquery.d.ts(352,48): error TS1005: ',' expected.
jquery.d.ts(352,69): error TS1005: '=' expected.
jquery.d.ts(352,72): error TS1109: Expression expected.
jquery.d.ts(352,111): error TS1005: ',' expected.
jquery.d.ts(352,132): error TS1005: '=' expected.
jquery.d.ts(352,135): error TS1109: Expression expected.
jquery.d.ts(677,35): error TS1005: ',' expected.
jquery.d.ts(677,36): error TS1016: A required parameter cannot follow an optional parameter.
jquery.d.ts(692,39): error TS1005: ',' expected.
jquery.d.ts(692,40): error TS1016: A required parameter cannot follow an optional parameter.
jquery.d.ts(722,36): error TS1005: ',' expected.

The latest version of the jquery.d.ts file uses a syntax that is new to TypeScript 1.4. As the colleague had TypeScript 1.3 installed, the compiler throw a lot of errors.

There are 2 possible solutions to fix this problem:

  • Option 1 – Upgrade the TypeScript compiler from 1.3 to 1.4.
  • Option 2- Use an earlier version of the .d.ts files. Have a look at the "1.3" branch on DefinitelyTyped.

Monday, June 8, 2015

Compiling TypeScript on your build server - "tsc.exe" exited with code 1 (again)

A few months after a previous issue with TypeScript on our build server, the same error was there again:

image

This error is not really helpful. So I logged in on the build server and tried to execute tsc.exe directly. This gave me a different error. On the command line I got the following error:

“Cannot initialize ActiveScript”

and a message box opened up with the following message:

“The program can’t start because api-ms-win-downlevel-advapi32-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.”

image

So what is the problem? The thing is that TypeScript has a dependency on IE. On the build server IE8 was installed which is not compatible with TypeScript 1.4(and also 1.3).  After upgrading to IE11, our builds turned green again.

Friday, June 5, 2015

SonarQube in action –Nemo

I really like SonarQube and all the options it has to offer. If you want to see what SonarQube can do, you could either browse through all the documentation or even better, have a look at Nemo, the online instance of SonarQube dedicated to open source projects.

image

Thursday, June 4, 2015

SonarQube Runner–OutOfMemoryError - Java Heap Space

I’m currently integrating SonarQube in our Build pipeline. During the process I stumbled over some issues. One issue I got was related to the Java runtime running out-of-memory.

The SonarQube Runner will analyze your project and collect and send all the results to your SonarQube database. If your project is large, it can happen that the JVM used behind the scenes runs out of memory.

You have 2 options to fix this:

  • Option 1 - Reduce the analyze scope by either reducing the project size(split your project in smaller sub projects/modules) or reducing the set of rules that are analyzed.
  • Option 2 – Increase the memory size that can be consumed by the JVM.  This can be done by adding the following Environment Variable:
    • SONAR_RUNNER_OPTS=-Xmx1024m -XX:MaxPermSize=512m
image

Wednesday, June 3, 2015

PostgreSQL error: no pg_hba.conf entry for host

I’m currently integrating SonarQube in our Build pipeline. During the process I stumbled over some issues. One issue I got was related to PostgreSQL that we were using as our database for SonarQube.

Everything worked nicely from the SonarQube web portal, but when I tried to execute the SonarQube Runner on our build server, it failed with the following PostgreSQL error:

connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host

I’m not an expert in PostgreSQL, so with the help of a google search I discovered that the pg_hba.conf file is used to configure the security of your PostgreSQL database. By default only local connections are allowed. So it is not possible to connect to the PostgreSQL database from outside the server it is running on. As I had SonarQube running on the same server as my database, it worked for the SonarQube web portal. However my build server was a different machine(even in a different datacenter) and couldn’t reach the PostgreSQL database.

To fix it, you have to update the pg_hba.conf file in your PostgreSQL installation directory. I added the following line to the file just below the # TYPE DATABASE USER CIDR-ADDRESS METHOD header:

host all all 0.0.0.0/0 md5

Warning: Note that this line will give everyone(with a correct username and password) access to your PostgreSQL instance. It is recommended to limit the attack surface by specifying a more restrictive set of allowed IP addresses.

Tuesday, June 2, 2015

Clean(er) C#

Do you want to write cleaner, more maintainable, more readable, and more pleasurable C# code? Of course Glimlach!

Have a look at the Clean C# book by Jason Roberts

You can download the book for free from http://cleancsharp.com/

image

Monday, June 1, 2015

Akka.NET–Distributed Systems made simple

For a customer I’m working on a highly concurrent distributed system. As the requirements evolve, we get more and more an idea about the high level of complexity that is involved in building such a system.

I could switch to a different language like Erlang, that is designed for such a task, but instead I decided to give Akka.NET a try…

image

From the site:

Akka.NET is a toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on .NET & Mono.

This community-driven port brings C# & F# developers the capabilities of the original Akka framework in Java/Scala.

Learn about Akka for the JVM here.

Akka  offers a C# implementation of the Actor Model. The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems. Actors were defined in the 1973 paper by Carl Hewitt but have been popularized by the Erlang language, and used for example at Ericsson with great success to build highly concurrent and reliable telecom systems.

Similar projects exist like Microsoft Project Orleans.

image

To help you get started, the creators of Akka.NET, provided a free(!) bootcamp with 18 lessons. Go check it out at https://petabridge.com/bootcamp/.