↓ Skip to main content
The technical notebook of Bryan Avery

Ideas worth sharing.

Practical notes on software architecture, cloud platforms, security and AI. Written from real engineering experience, with an eye on what actually works.

A little about me

Latest articles

553 articles in the archive
SecureString

SecureString

·7 mins
I’ve come across a class in the System.Security namespace that is often overlooked. The class is SecureString. In this post, I will go over what SecureString is and why it is needed. Have you ever come across these scenarios before?
Raising Multiple Exceptions with AggregateException

Raising Multiple Exceptions with AggregateException

·6 mins
There are occasions where you are aware of many exceptions within your code that you want to raise together in one go. Perhaps your system makes a service call to a middleware orchestration component that potentially returns many exceptions detailed in its response, or another scenario might be a batch processing task dealing with many items in one process that require you to collate all exceptions until the end and then throw them together.
Using MongoDB

Using MongoDB

·1 min
If you want to setup MongoDB with C#, then the best option is to follow the getting started guide on the MongoDB website https://docs.mongodb.com/getting-started/csharp/client/ You can install the NuGet package for MongoDB by typing into the Package Manager Console
Custom Configuration in your config

Custom Configuration in your config

·2 mins
This post is to show how to setup a customised configuration section in your app.config or web.conifg of your .NET application I have written an article on this before, back in 2008, but things have moved on in the libraries and this is the latest and easiest way to create your own customised configuration.

New Features in C# 7.0

·7 mins
Microsoft have release C# 7.0 and it comes with a number of new features and brings a focus on data consumption, code simplification and performance. Tuples have been around for a while but they have made them so much easier to use, which make it easy to have multiple results, and pattern matching which simplifies code that is conditional on the shape of data. But there are many other features big and small.

A web-developer’s guide to help eliminate non-coding tasks and get code done faster

·1 min
Microsoft have just published this great eBook which helps web developers cut right to the code scripting of environments to make all the firewall ports and get code done quickly by providing an overview of key services in the cloud, what services to use based on your needs, step by step guidance, sample code, sample applications, and a free account to get started.
How slow are Exceptions

How slow are Exceptions

·4 mins
I’ve seen from time to time applications that wrap a TRY – CATCH around some code, but do nothing except carry on. So why is this so wrong? As programmers we want to write quality code that solves problems. Unfortunately, exceptions come as side effects of our code. No one likes side effects, so we soon find our own ways to get around them. I have seen some smart programmers deal with exceptions the following way:
Entity Framework Unit of Work Patterns

Entity Framework Unit of Work Patterns

·15 mins
I’m not often shocked, but when I found out that Entity Framework was not thread safe, I was horrified. I even had to buy a fellow college dinner as I lost a bet. Now that I knew what the problem was how can it be resolved?
Decorator Pattern

Decorator Pattern

·5 mins
Decorator pattern falls under Structural Pattern of Gang of Four (GOF) Design Patterns in .Net. Decorator pattern is used to add new functionality to an existing object without changing its structure. Hence Decorator pattern provides an alternative way to inheritance for modifying the behavior of an object. In this article, I would like to go over what the decorator pattern can do, and how it works.

Kendo Grid custom sort order

·2 mins
I’ve been racking my brains as the sorting on the Kendo Grid is pretty good, only that I need to be able to not sort in the order that is being displayed. An example would be numbers written out in full and you want them in number sort order.

Uncle Bob On Coding Standards

·1 min
It’s important for a team to have a single coding standard for each language to avoid several problems: A lack of standards can make your code unreadable. Disagreement over standards can cause check-in wars between developers. Seeing different standards in the same class can be extremely irritating. UncleBob wrote this:
Code Metrics what do they mean?

Code Metrics what do they mean?

·2 mins
 Code metrics is a set of software measures that provide developers better insight into the code they are developing. By taking advantage of code metrics, developers can understand which types and/or methods should be reworked or more thoroughly tested.
IoC Benchmark

IoC Benchmark

·1 min
So which is the fastest at different IoC Lifestyles. In this benchmark we will be running, head to had, with Castle Windsor, Ninject, Spring.NET, Unity, Microsoft DI, AutoFac, and Structure Map. Here is a working project, this uses NuGet to included the packages, so as time goes on you may find the packages go out of date, so you’ll need to refactor the code to work with the next packages.
Differences between Scrum and Kanban

Differences between Scrum and Kanban

·6 mins
Scrum and Kanban are two terms that are often (incorrectly) used interchangeably or thought to be two sides of the same coin. In reality, there are significant differences between these two Agile methodologies. Understanding these differences is key to choosing the path that will work best for your environment. In a nutshell, what is Scrum? Without getting too detailed, Scrum is a tool used to organise work into small, manageable pieces that can be completed by a cross-functional team within a prescribed time period (called a sprint, generally 2-4 weeks long). To plan, organise, administer, and optimise this process, Scrum relies on at least three prescribed roles: the Product Owner (responsible for initial planning, prioritising, and communication with the rest of the company), the Scrum Master (responsible for overseeing the process during each sprint), and the Team Members (responsible to carry out the purpose of each sprint, such as producing software code.) Another common tool used by scrum teams is the Scrum Board – a visual representation of the work flow, broken down into manageable chunks called “stories”, with each story moved along the board from the “backlog” (the to-do list), into work-in-progress (WIP), and on to completion.
Factory Support Facility

Factory Support Facility

·3 mins
Factory Support Facility allows using factories to create components. This is beneficial when you want to make available as services components that do not have accessible constructor, or that you don’t instantiate, like HttpContext. Prefer UsingFactoryMethod over this facility: while the facility provides programmatic API it is deprecated and its usage is discouraged and won’t be discussed here. Recommended approach is to use UsingFactoryMethod method of fluent registration API to create components. This limits the usefulness of the facility to XML-driven and legacy scenarios.
Registering components for IoC

Registering components for IoC

·4 mins
Inversion of Control (IoC) is quite a big step for some developers, but the benefits once implemented are huge. With the applications performance, maintainability, unit testing and more importantly separation of concerns, just to name a few.

Introduction to IoC with Windsor

·7 mins
I do love dependency injection, but many developers still seem to miss the point and the reason for having it. If you’re only using it on a small scale, you don’t really need any tools to use the technique. But once you’re used to this design technique, you’ll quickly start using it in many places of your code. If you do, it quickly becomes cumbersome to deal with the real instances of your runtime dependencies manually. This is where tools like Inversion Of Control (IoC) containers come in to play. There are a few solid containers available for the .NET world, and even Microsoft has released their own container. Basically, what the IoC container does for you, is take care of providing dependencies to components in a flexible and customizable way. It allows clients to remain completely oblivious to the dependencies of components they use. This makes it easy to change components without having to modify client code. Not to mention the fact that your components are a lot easier to test, since you can simply inject fake dependencies during your tests.
Object to CSV extension

Object to CSV extension

·1 min
Here is a nice little extension that will take an object and convert it into a CSV file. Also has the option if you want to include a header on the CSV file. public static class ObjectToCsv { public static string ToCsv<T>(this IEnumerable<T> items, bool includeHeading = true) where T : class { var csvBuilder = new StringBuilder(); var properties = typeof(T).GetProperties(); if (includeHeading) { csvBuilder.AppendLine(string.Join(",", properties.Select(p => p.Name.ToCsvValue()).ToArray())); } foreach (var item in items) { var line = string.Join(",", properties.Select(p => p.GetValue(item, null).ToCsvValue()).ToArray()); csvBuilder.AppendLine(line); } return csvBuilder.ToString(); } private static string ToCsvValue<T>(this T item) { if (item == null) return “""”; if (item is string) { return $""{item.ToString().Replace(""", “\"”)}""; } double dummy; return double.TryParse(item.ToString(), out dummy) ? $"{item}" : $""{item}""; } }