1. Structured Logging

    On weekends I was reading latest Technology Radar from Thought Works. It’s really interesting! Some of things they mentioned we are already using here at Compellotech (such as HAL, Angular JS, Nancy, TypeScript, etc.) Others are good not know about, for example Structured Logging. Structured Logging Lately I was thinking on the best approach to enabled monitoring in our distributed system. The goal is to have some universal solution which will allow us to release something in 1 or 2 sprints (we use one week sprint). I did some research and I suppose it’s a way to go for us.

    • Allows to enable monitoring in all the components without significant changes
    • Allow to setup Alerts for different things (if they appear in the log)
    • Allow to search for issues for example by Customer ID. Just imagine you type CustomerID=”777” and you see all the events in the system related to that customer!
    Technical details There is a great Structured Logging framework http://serilog.net/. It allows you to publish logs to different systems. For example you would use Seq web application. Alternative approach is to publish logs to Elastic Search and use Kibana as a Front End. Another interesting option is to push logs into MongoDB. So you ‘ll be able to do something like  
    db.log.find( { customerId: “777”, application: “PaymentGateway” } )

  2. Command Query Responsibility Segregation (CQRS) pattern

    Time flies, it’s more than two years since I discovered CQRS pattern. If it’s first time you hear about CQRS, there is a great A Journey into CQRS talk on Channel 9. Today we are using CQRS actively at Compellotech. We are using it as a high level architecture on some components. In the same time we are using it inside of our systems to make internal design better. The approach we are using is Very similar to the one described by Steven on .NET Junkie. I really encourage you to check his articles out. By the way he’s the author of easy, flexible, and fast dependency injection framework - Simple Injector. …

  3. MSSQL Activity Monitoring

    At Compellotech we were using Sp_GetWhoIsActive for some time now. It’s VERY convenient for activity monitoring. It was created by very bright guy, but it’s too heavy sometimes (might impact a production performance). So from now on we are using newer query which uses DMO views and does not have any impact on the database performance.

    -- Currently executing batches, with text and wait info
    SELECT dm_tran_locks.request_session_id,
           DB_NAME(dm_tran_locks.resource_database_id) AS dbname,
               WHEN resource_type = 'OBJECT'
                   THEN OBJECT_NAME(dm_tran_locks.resource_associated_entity_id)
               ELSE OBJECT_NAME(partitions.OBJECT_ID)
           END AS ObjectName,
           indexes.name AS index_name,
    FROM sys.dm_tran_locks
    LEFT JOIN sys.partitions ON partitions.hobt_id = dm_tran_locks.resource_associated_entity_id
    LEFT JOIN sys.indexes ON indexes.OBJECT_ID = partitions.OBJECT_ID AND indexes.index_id = partitions.index_id
    WHERE resource_associated_entity_id > 0
      AND resource_database_id = DB_ID()
    ORDER BY request_session_id, resource_associated_entity_id 

  4. Thoughts about Qt 5

    I’m working as a windows developer for the most part of my carrier. I started as a PHP developer and I like linux (especially command line). Recenlty we were making our middleware system to work on Mono to be able to run it on Raspberry Pi and similar low price devices. So I had a chance to play with Linux again. It’s was fun so I decided to do some reading on cross platform development. I did a brief reading on Qt and liked it. Then I found very nice book on Qt5 and QML. I really encoredge you to do at least a brief reading of it. It’s worth to mention that porting our .NET system to Mono wasn’t a painfull process at all. But still now we have 2 support two different platforms .NET & Mono. There some difference on how Mono executes our code. In the same time Qt will execute your code just the same on any plaform. It’s really neat advantage. So it’s very good idea to have Qt5 in a toolbox while choosing architecture for an upcoming project. …

  5. Javascript Unit Tests on Team Foundation Service with Chutzpah

    I was helping my peer developer to setup TFS Build to run Jasmine tests. Thanks to Visual Studio & TFS teams it’s really easy to do since TFS 2012! (I configured TFS Build to run Machine.Specification couple of years ago) We were using the Javascript Unit Tests on Team Foundation Service with Chutzpah guide. It’s very nice and straightforward article. The only thing I don’t like about it is that it needs to set Copy to Output Directory on each test file. Instead of that we added the following Post-build script, so we don’t need to set Copy to Output Directory on each test file.

    for /R $(ProjectDir) %%G IN (*.test.js) DO copy "%%G" $(TargetDir)
    Hope it helps! …

  6. Dependency Injection in .NET. Seemann Mark.

    Recently I had a chat with a peer developer about IT books. I recommended him a great Seemann Mark’s book Dependency Injection in .NET. After that I realized that I never blogged about it! I’d say that in my opinion this is an Must Read book for .NET software developers. At first I was a bit surprised that it’s a 500+ pages book about one pattern, but it’s really worth it. First chapters are an amazing explanation of the Dependency Injection and Inversion of Control patterns. Last chapters dives in details of some popular DI containers. Unfortunately it doesn’t contain a chapter about Ninject which is my favorite DI container, but there are tons of information about it on the Internet. Service Locator is anti-pattern? I was very excited that he lists Service Locator as a DI anti-pattern! We were using Service Locator on a big WPF application couple of years ago. After some time I released that it’s not an ideal choice. Seemann Mark stated the following issues with Service Locator pattern:

    • The module drags along a redundant Dependency
    • It isn't apparent that DI is being used
    I’d like to just add that it’s way easier to read the code if you can see all the dependencies just by looking at the class constructor. Also it’s easier to test such code because you don’t need to configure Service Locator to use Mocks. All you need is just pass the objects you want. In some cases it would be real implementation, in others it would be mock, test double, etc. So even if you aren’t .NET developer I still suppose it makes sense to read first chapters of this amazing book. Highly recommend! …

  7. Mono 3.2.7 is working on a Raspberry Pi running Raspbian (hard float)!

    We were planning to port our application into Mono to give it a try on a Raspberry Pi for a quite a while. What’s interesting now, then we finally started to do this, Alex Rønne Petersen added a hard float support to Mono! I was able to build his armhf branch directly on my Raspberry Pi. So now I’m all set to port our application! Thanks to Alex! Thanks to the Mono team! :) …

  8. Stop your console app the nice way

    This would be obvious for someone. Posting it just in case :)

        class Program
            private static readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
            static void Main(string[] args)
                Console.CancelKeyPress += OnCancelKeyPress;
                //TODO: do work here
                //TODO: shutdown here
            private static void OnCancelKeyPress(object sender, ConsoleCancelEventArgs e)
                e.Cancel = true;

  9. Durandal: TypeScript modules support

    I’m working on a prototype of HTML5 Single Page Application (SPA). I’m happy to use plumbing provided by Durandal. It’s really exciting SPA framework.  Unfortunately it doesn’t support TypeScript modules. According to Rob Eisenberg it won’t be fixed for now (quote below)

    I'd rather not make a change in the core based on the current state of TypeScript. Rather, I'd prefer a plugin that re-configures durandal for this case. But, it will get fixed in TypeScript before v1.0 I confirmed that by checking their roadmap. Also Luke Hoban responded to me via codeplex to say they have every intent to fix it https://github.com/BlueSpire/Durandal/pull/13
    So if we are going to start to use TypeScript with Durandal… we need some workaround. So here we go. First we need to apply below lines into router.js. It will add basic TypeScript modules support. Second step is to enable master\detail scenario by adding below lines into system.js Would be happy to get some feedback on this. …

  10. Typed XML programming

    I want to tell you about very useful project LINQ to XSD

    The LINQ to XSD technology provides .NET developers with support for typed XML programming. LINQ to XSD contributes to the LINQ project (.NET Language Integrated Query); in particular, LINQ to XSD enhances the existing LINQ to XML technology.
    Please consider the following code:
    services services = services.Load(@"c:\services.xml");
    string name = services.service.First(x => x.FullTypeName == "xx").Namespace;
    As you probably understand it reads XML underneath. But you deal with LINQ query and don’t worry about parsing XML. …