Docker – Containers versus Virtual Machines

05 June 2015

There is a lot of talk in the industry at the moment about Docker (and containers in general). But, there also seems to be a lot of confusion about what Docker is, why you would use it, and how it is different than any other virtualization framework such as VirtualBox, VMWare, or Parallels. This confusion is especially prevalent in the developer community where systems administration work is often delegated to another team. Docker is a different kind of virtualization that solves common problems that software teams face everyday. Docker, and more generally a container, is something that every developer should learn about as they are likely going to need to use them in the coming years.

Principles of Aspect Oriented Programming in C#

01 June 2015

Aspect Oriented Programming (AOP) has been around for a long time. It is a powerful concept that allows for the separation of “crosscutting” concerns that has always been widely misunderstood by developers and managers alike in my experience. This confusion has largely been due to the mismatch between AOP theory, terminology, and implementation. Recently, I have seen a renewed interest in it, and I hope this article can help to demystify some of the confusions.

MEAN.io on Ubuntu 14.04

14 October 2014

I recently tried to get MEAN running on Ubuntu 14.04 and I ran into problems. Here are the issues that I ran into, what I did wrong to respond to the errors, and how you can easily resolve the problems.

Mitigating Incomplete Dependencies

09 September 2014

As a consultant, I frequently encounter projects where assumed dependencies are not in place before the beginning of the project. Sometimes, these items might not even be available for months after I am expected to finish and leave. This is especial true of anything related to data (e.g. data services, data access libraries, databases, and sample data). But, it could also be related to non-functional requirements such as authentication and logging frameworks. Despite this, even when estimates were based on these items being ready and the customer knowingly signed off on those assumptions, customers have a hard time understanding the impact to the project schedule and will often argue not to move the target release date. I am not advocating that your team should give in to these unreasonable demands. In fact, I would argue the opposite. However, whether you are waiting on dependencies that should have been completed or had planned to work in parallel from the start, I do recommend architecting your application in such a way as to minimize the damage caused by incomplete dependencies.

Bad Method Cohesion

25 August 2014

In a previous post, I talked about bad coupling through injecting too many dependencies into a class. Developers should also be concerned with the cohesion within individual methods. In the 1993 classic Code Complete (which is great, but a little dated), it said that a method should be under 200 lines of code (LoC). In more recent years, after test driven development methodologies have taken hold, we find that the LoC metric is not as good of an indicator as it was in the past. Therefore, methods with 200 lines are absurdly large in today's world. Large methods have the following problems:

Bad Coupling with Constructor Injection

20 August 2014

In previous posts, I started to explain the difference between Dependency Injection (DI) and a simple factory. To leverage more of the potential of DI, I gave an example of using constructor injection and contrasted that with setter injection. Like all things, too much of a good thing can have horrible consequences. Hopefully, this post can help you to identify when things are going wrong.

Setter Injection

12 August 2014

In my last post, I explained some of the differences between Dependency Injection (DI) and the factory pattern. I also gave an example of how constructor injection could be used to leverage the DI framework's ability to manage dependencies of dependencies. While constructor injection is my personal preferred way of doing it, there is an alternative. You could also use setter injection.

Factories and Dependency Injectors

14 July 2014

It seems that over the years, many people have accepted that Dependency Injection (DI), which is sometimes called Inversion of Control (IoC), is a "good thing" and that they should be "doing it." But, few of those that I talk to seem to know why that is. And, fewer still can tell you the difference between the Factory Pattern and DI. This is usually an indicator of how they (mis)utilize their DI framework. Many of the implementations that I have seen use it as a glorified factory. But, DI is a special implementation of the factory pattern that can do so many more things to help improve the structure of your code and improve testability than just serving out objects. The relationship between the factory pattern and DI is like the relationship between rectangles and squares. All squares are rectangles, but a rectangle is not necessarily a square. Just like all DI frameworks follow the factory pattern, but a factory is not necessarily a DI container.

Windows 8 Development - Continuous Integration

17 June 2014

Continuous integration (CI) is one of those practices that is a necessity for me on all of my projects. Without the tight feedback loops that CI gives you, projects feel unprofessional to me. This has been a point of frustration for me while developing for Windows 8 with JavaScript. Building the solution can easily be done with MSBuild. But, unit testing has been a bit of a problem.

Windows 8 Development - Application Errors

13 June 2014

An event that is often overlooked, but which is extremely important for customer service and diagnosing of issues is the event that occurs when there is an unhandled exception. In the paradigm of web application development, you can control your hardware and rely on your application logs. But in the distributed world of mobile, the logs are all on the user's mobile device. In this scenario, it is important for you to be able to capture these problems and "phone them home" to be diagnosed/fixed (with the user's permission of course).

Windows 8 Development - Application Resume

12 June 2014

While most of the events I described in previous posts had events in both Windows.UI.WebUI.WebUIApplication and WinJS.Application, there is no WinJS wrapper around WinRT event in this situation.

Windows 8 Development - Application Suspend and Shutdown

11 June 2014

At any given time, there are only three states that your Windows Store application can be in. Obviously, the first two are “running” and “not running.” But, there is a third state that the web and WinForms/WPF developer might not be accustomed to called “suspended.” An application can be suspended in several conditions:

Windows 8 Development - Application Startup

10 June 2014

Unlike a web application, which always starts because someone has requested a page, Windows Store applications can be started for a whole host of reasons. It could be that the user has to click on the shortcut/tile to start your app. But, it could also be from the camera sharing a photo with your app, another application (e.g. a web browser) sharing data, or an auto-run triggered by the user inserting a flash drive. There are a whole host of activation kinds that your application can respond to.

Windows 8 Development - Life Cycle Events

09 June 2014

In another post, I mentioned that you do not need WinJS at all to write a Windows Store Application. Not only is this true of the user controls, but it is also (mostly) true with regard to the application life cycle.

Windows 8 Development - C# Components for JavaScript Applications

05 June 2014

Many articles will tell you that you cannot have a C# back end for an HTML5 presentation layer. While this is true on the surface because you cannot mix them in a project, it is still possible to mix-in C# (or VB.NET if you are a verbose kind of person) as a “Windows Runtime Component.” Since I came into my first Windows 8 project with an ASP.NET MVC mindset, this is the route my team and I took. In retrospect, this might not have been the best idea because of the many limitations and oddities that added complexity. Depending on your team's skill-set, this may or may not be an option for you. However, you should consider the following.

Windows 8 Development - Dynamic HTML Restrictions

04 June 2014

As I mentioned in my previous post, Microsoft places restrictions on what you are allowed to do to your HTML via JavaScript; they do not allow you to do anything that they consider “unsafe,” and the documentation is a little confusing on the subject. The important thing to know is that these restrictions only affect dynamic HTML and there are some simple ways of dealing with it.

Windows 8 Development - Things to Know about JavaScript

03 June 2014

For my client's Windows 8.1 project, the team was happy to see that Microsoft offers the ability to write the application in JavaScript. This is because we are primarily web developers, and we could bring a lot of our current skills directly into the project. Other than the code that is considered “unsafe” (which does bring a lot of runtime-only issues), there does not seem to be any restrictions on what you can do in your application. You still have complete access to the .NET (WinRT) framework in the same way that a C# project has. For us, the JavaScript project was actually even more beneficial to us than C# because we didn't have any expectations around open source libraries that we would later find out are not compatibility with WinRT.

Windows 8 Development - Environment

02 June 2014

For those of you that are not fans of Windows 8 (this includes me), this will be disappointing. But, you cannot use Windows7 to develop Windows Store Applications. This led me to run Ubuntu as my primary OS and run Windows 8.1 via VirtualBox whenever I work on Windows Store applications. I have found the transition from Windows 7 to Ubuntu to be a much smoother transition for me personally than being frustrated over waiting for Windows 8 to respond. This setup is working well for me and I can quickly switch between Windows 7 and 8.1 while keeping all of my browser tabs and documents open in Ubuntu. Obviously, this will not work in companies were the IT department has restrictions. But, it is worth mentioning.

Windows 8 Development - Understanding the Terminology

01 June 2014

The first thing to understand about developing applications for Windows 8/8.1 is the terminology. While these types of applications have been around for some time, there is still confusion over the original Microsoft-internal code names and resulting product names. Since the community is not as established as other platforms, many of the blog entries you will find are older and still use the code names.

Why Develop Applications for Windows 8.1?

31 May 2014

Recently, I was asked to write a Windows 8.1 application for a client. Although I have been a Microsoft-based technologist for all of my career, I had to ask myself why the client would chose this platform. Windows has less than 5% of the tablet market and there is not much of a developer community around it. Also, the devices are running a full-blown OS. This means the battery life is more comparable to a laptop than other tablet platforms. All of this being said, there are legitimate reasons to choose Windows. This is especially true in an enterprise environment.

Cyclomatic Complexity

19 March 2014

Over the last couple of years, I have largely changed my approach to projects and coding. This has been largely due to newer tools like git, learning from my coworkers at Summa, and from moving to a more open-minded environment where it was possible to experiment with new technologies and ideas. But, anyone who has ever had me review their code in the past knows that the first thing I do is run a static analysis tool and dive straight into the method with the highest cyclomatic complexity. More recently, I have found that if a project gets to the point where I need to employ this technique, the project is already headed down a bad path. That being said, cyclomatic complexity is still an extremely important metric to be aware of and to use as an indicator of problems.

Exporting Mercurial Data

16 February 2014

Yesterday, I came across a report card for GitHub users. It inspired me to mine the data from my current project, which uses Mercurial. For those of you that do not know, Mercurial is similar to git in that it is a distributed source control system. It is written in Python, which makes it the language of choice for exporting the data I am interested in.

Python Package Management

15 February 2014

Python had package management long before Visual Studio got Nuget. However, the official Python installation does not actually come with a package manager installed. There are more than one from which to choose, and (as with most things) they all have their strengths and weaknesses. I am pretty new to Python, so I am still learning this ecosystem, but so far this is what I have found.

.NET Async Utility

08 October 2012

Below is a simple C# class that I've used on many projects over the years for fire-and-forget type operations. For example, if you have a data collection service that pools multiple sources for information, you probably do not want to wait for the first remote call to finish before moving on to the next. This utility can be used to simply move that operation on to another thread to be executed.

Log4Net Appender for Displaying Messages on a Windows Form Application

15 December 2010

Yesterday, I ran into a situation where I needed to display logging information on a WinForm application. The API that I wanted to show logging for was already using log4net for all of its logging, so the simplest way to accomplish my goal was to implement a custom log4net appender. The code below was the minimum that I needed, but there is room for enhancements as noted in the comments.

Ignoring XPath Namespaces

08 December 2010

XML namespaces might be useful for resolving conflicts when combining segments from multiple XML entitied into a single file. They can also be extremely useful for versioning large complicated documents. But, to most developers who are merely trying to accomplish simple tasks in a short amount of time, they are nothing more than obstacles.

Writing an SSRS Validation Tool

25 October 2010

I have been involved in a project that integrates with the Microsoft SQL Server Reporting Services (SSRS) web service API for quite a while now, and the majority of the issues I have seen are related to the configuration of SSRS and the installation of our product on top of SSRS.

Retry Utility

21 October 2010

This morning I ran into a situation where I needed to retry several method calls if they failed. I decided that the easiest and cleanest way to accomplish this would be via a generic utility class. Below is the class I wrote. In the future I may add a method that will handle targets with void returns. But, for now, this is all my application required.

WCF Serialization Basics - Opt In

20 April 2010

This post is part of a series of posts that I am writing as I prepare for a presentation on WCF basics. Prior to WCF, when exposing a web service, serialization was done using the SoapFormatter class. Using the SoapFormatter, the developer would tag the class being serialized with the Serializable attribute, and the SoapFormatter would serialize all of the fields in the class, regardless of visibility, unless you opted out by assigning the NonSerialized attribute to a field that you wanted to excluded.

Get Outside of Your Pool of Influence

30 March 2010

For quite a while now, Scott Hanselman has frequently talking about reading Open Source code to learn new ideas. I really like this thought. When you work on the same project every day, collaborate with the same people every day, continuously read books by the same publishers, and frequent blogs written by the same authors, you continue to learn new ideas and new technologies. But, this type of continuous education can still be lacking the diversity of thought needed to make you better. Observing the stylistic differences in code from new sources can have a big effect on you. Even if it is in the way you do everyday tasks like checking for null and setting a default, it can impact you and your style. Writing a plug-in for a pluggable app such as SportTracks or DotNetNuke, can affect the way you think about architecture. Learning about the inner workings of NHibernate can have big effect on the way you think about exposing events. Do not be complacent or afraid to look for new sources of inspiration. Grok the ideas and style of as many sources as you can. And, tinker with what you find. You just might find that you really like what you initially rejected.

Standardized Build Procedures

28 February 2010

When working on any software development project, it is fundamental to be able to compile, package, deliver, and track the project output. But quite often, this area is overlooked and all of the design efforts are put toward managing the complexity of the software itself. This often leads to an ad hoc build script that gets more and more tangled and unmanageable as time goes on leading to valuable development time being wasted on non-deliverable items. As the project moves into production, the problem usually grows even more out of control as additional branches are required in the source control system, and nearly duplicate build scripts are required for each of the additional branches. Eventually a build strategy without a defined architecture or clear procedures will collapse under its own weight.

Command Line Parsing

12 February 2010

From time to time, I am still asked to create a console application for someone, and most of the time PowerShell is still not accepted by my clients for various reasons. Just like method parameters can become unwieldy in an under-designed system as requirements change, so can command line arguments. To minimize the mess, regular expressions can be used to access a command/arguments pattern (e.g. EncryptionUtil.exe /Decrypt /File="C:\My Documents\foo.xml"). Furthermore, if argument are passed in as a key/value pairing (e.g. /File="C:\My Documents\foo.xml"), the order of the arguments should not matter.

Clearing SSRS Objects

12 February 2010

While performing integration testing with my current project, I often have to clear all of the reports, folder, datasources, etc from Reporting Services. Here is a very simple SQL script to quickly get this done.

Accepting Web Service Cerificates

12 February 2010

In the past, I have frequently tested in environments with self-generated SSL certificates, and then use "real" certificates in production environments. This usually is not much of a problem unless the application makes calls to web services that are also encrypted using a self-generated certificates. This scenario is increasingly the norm in the current world of SOA and RIA. For this scenario to work, you have to implement your own certificate validation code as follows:

ETL Testing Basics

12 September 2009

When doing developer testing outside of the database, it is always a good idea to start with simple unit tests that stub or mock any dependencies. If your test calls a method that calls other objects, a database, a service, etc., then you have entered the realm of integration tests. Integration tests are much harder to design, setup, and maintain. Unfortunately, when you start testing an ETL process, you are going to have to test the end-to-end integration of multiple databases. This makes an already difficult problem exponentially more difficult. For starters, your data needs to start in an expected state, and there can only be one test running against the database(s) at a given time or the data will be corrupted. To make the testing of ETL processes more manageable, this article introduces some general concepts that should be followed.