Coding and Dismantling Stuff

Don't thank me, it's what I do.

About the author

Russell is a .Net developer based in Lancashire in the UK.  His day job is as a C# developer for the UK's largest online white-goods retailer, DRL Limited.

His weekend job entails alternately demolishing and constructing various bits of his home, much to the distress of his fiance Kelly, 3-year-old daughter Amelie, and menagerie of pets.

TextBox

  1. Fix dodgy keywords Google is scraping from my blog
  2. Complete migration of NHaml from Google Code to GitHub
  3. ReTelnet Mock Telnet Server à la Jetty
  4. Learn to use Git
  5. Complete beta release FHEMDotNet
  6. Publish FHEMDotNet on Google Code
  7. Learn NancyFX library
  8. Pull RussPAll/NHaml into NHaml/NHaml
  9. Open Source Blackberry Twitter app
  10. Other stuff

Enterprise Logging Part 2 - Logging From .Net to RabbitMq via Log4Net

Hi all,

I'm back with Part 2 of my plan to log, search, graph and alert on milllions of log messages with Log4Net, RabbitMq, GrayLog2 and NEsper. I must confess, I've been pretty astonished at the reaction to part 1 (a week later I was still seeing 4 times my normal blog traffic), so I guess I've gotta follow through and see the plan to fruition!

I'm going to start at the application end today, I'm going to install RabbitMq on a Windows box, and demonstrate a .Net application sending messages to it via a custom Log4Net appender (Gelf4Net over at http://github.com/RussPAll/gelf4net).

More...


Categories: Architecture | Hacking
Permalink | Comments (2)

Enterprise Logging and Alerting with Graylog2, RabbitMq and NEsper

Do you work with lots of software and need to know what it's all getting up to, when you need to know it? I work for a .Net house with over 10 years' worth of software under our belts, we totally have this problem.

Our full estate includes many small and large systems - Web services, Windows services, .Net web apps, MVC web apps... if it's Microsoft badged, we'll have one somewhere. Each of these systems currently logs to a mixture of database tables, flat text files, e-mail alerts - the whole thing is becoming increasingly difficult to manage.

This blog post will be the first in a series looking at an open source solution, involving Log4Net, RabbitMq, Graylog2, ElasticSearch and NEsper, with the following capabilities:

  • Aggregating logs from various distributed systems into a flexible and searchable persistent storage mechanism
  • A web front-end for querying and graphing the log data
  • A system capable of detecting abnormal or critical log patterns and alerting support staff

More...


Categories: Architecture | Linux
Permalink | Comments (3)

An Enterprise MVC .Net Project Template - Part 1 of Many

Hi all,

That time's come again - another project's come along (actually an oooollld project from 6 years back has come around again), and I'm about to fire up Windows Explorer and Visual Studio ready to start dev.

I've done this dozens of times over the last couple of years, but I still remember back in the early days struggling to get to grips with where to put what, where to put my DLLs, my unit tests, etc. So I thought some folks might benefit if I jot down some notes as I go along. This post will detail exactly how I get started with a new Visual Studio project, in this case looking at an MVC project, and all of the things I do before I start cutting code.

By the way, this is the same project structure I use for most of my enterprise level work. I'm going to document this for Subversion users, as I still feel like they're in the majority (and I still suck at Git), so Git or Mercurial users will possibly want to ignore me when I talk about branches and trunks!

More...


Categories: Architecture
Permalink | Comments (2)

Four Of The Best Linq Extension Methods

If you've read any of my previous blog posts, you might have the feeling that I absolutely love Lambdas in .Net, they're just plain awesome. Get a good handle on Lambdas, and you can chuck out a good wedge of your crummy old nested "foreach" statements. When the language feature first came on the scene, Lamdas seemed (to my eyes at least) to be confined to the world of Linq extension methods. Since then of course there's been a plethora of tools that have jumped on, such as Fluent NHibernate and Moq, but there's still plenty of life in the ol' Linq extension method yet! Here are my top four linq extensions, the lifesavers that I keep coming back to.

More...


Categories: Architecture
Permalink | Comments (0)

"The Rules" Part 1 - Single Responsibility Principle

Over the last few years, my experience of being a software dev has changed massively. I've not changed the language I code in, I've not changed what I'm trying to achieve, the change has purely been a move from coding on my own, to coding as part of a team.

Previously, my number one concern was "Does this code produce the right end result". Today, I balance this with the need for clean and reliable code. Now that I work as part of a team, I see that code needs to do more than just work. It needs to work reliably, it needs to be resilient in the face of unanticipated change, and it needs to be trustworthy in the eyes of my colleagues.

This should be the first of a couple of blog posts looking at different ways I'm striving to write resilient code. My four planned posts are:

  • Single Responsibility (this one)
  • Command-Query Separation
  • Tell Don't Ask
  • The Law of Demeter

If anyone can suggest anything to add to this list (Open-Closed principle and Design By Contracts are on the edge of my mind somewhere), please let me know in the comments below.

More...


Categories: Architecture
Permalink | Comments (0)

Cooking with .Net Lambdas Part 2 - Injecting Predicates into Where Expressions

A nice quick post this morning, something I spotted in a code snippet from the Castle Windsor folks over at http://docs.castleproject.org/Windsor.Windsor-tutorial-part-three-a-testing-your-first-installer.ashx and thought was nice. This post will show you how to pass a lambda into a method, and then invoke that lambda as part of a Where clause. It may not warrant a full blog post, but it's been a quiet few weeks, so there.

Also, check out the first part of this series, Cooking with .Net Lambdas Part 1 - Covering Up Them Code Smells for a more generic example of lambda goodness.

More...


Categories: Architecture
Permalink | Comments (0)

Cooking with .Net Lambdas Part 1 - Covering Up Them Code Smells

.Net Lambas are awesome. I know a few folks who maybe don't share the sentiment, but to me they thoroughly kick ass. I just need to look at projects such as Fluent NHIbernate, or Moq, and it's pretty clear that Lambas have been one of the most rewarding language extensions ever, period. But I'm going to hazard a guess that if you're a C# developer and you're reading this, you've used lambas many times in things like a "List<T>.Where(...)", but you haven't got a clue what the heck that "Func<T, string>" stuff is all about.

I'm not going to give you a nitty-gritty low level explanation - there are plenty of those already knocking around, so instead I'm going to just going to give a nice step-by-step example.

More...


Categories: Architecture
Permalink | Comments (0)

Debugging Good Patterns #1 - ToString() Is Your Friend!

Here's a nice punchy one - so short a post, it might even warrant now't more than a tweet, but the blog's been a bit barren of late so here I am.

When you're debugging code (of course that's a rare thing now I'm living the TDD dream ;), if you frequently find yourself digging around in the Visual Studio Watch or Quickwatch windows investigating properties on objects, sub-objects, sub-sub objects, etc, then here's a good 'un. The quickwatch window becomes massively more useful with one simple addition - override the ToString() method on every class in your system so that it summarises the key properties, without you having to expand that object and hunt down those properties.

More...


Categories: Architecture
Permalink | Comments (0)

Unit testing WebForms With a Nod Towards MVC and MVP

Hi all,

For those of you who've had a read of my last post, I'm afraid it's enough of the gadget hackery and back to coding!  This time, I'm going to reflect on some work that I'm involved in with my sterling team-dudes in the office.

This last two weeks, we've been migrating chunks of a classic WebForms app to an MVP structure, with an eye to ultimately migrating across to MVC.  This post is going to look at the very first stage in this process - getting our UI and non-UI code split between a View and combined Presenter/Model, so that we can get this code under test.  Future posts are (hopefully) going to look at how we get clean up the messy combined Presenter/Model to leave a properly structured set of Presenters and Models, and how these should and should not be coupled to one-another.

More...


Permalink | Comments (1)

C# .net Exception Handling Best Practice - As Easy as 1, 2, 3?

Hi all,

In my day job, I'm currently running a little project to establish some best practices that we can both adopt going forward, and somehow start applying to our existing legacy systems.

I know there a million people out there with their own ideas of "best practice", and it's a shame that these things don't seem to be portable between different development teams, but I guess as long as we can't agree on the whole tabs-vs-spaces thing for indenting code, I'm not going to hold my breath waiting.  Instead, here's where we are at the moment - our Exception Handling holy trinity.

More...


Categories: Architecture
Permalink | Comments (0)