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.

    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.

    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 - 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.

    .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.

    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.

    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: