Jeremy Bytes

byte-sized chunks of .NET

Skip Navigation Links


Exploring Task, Await, and Asynchronous Methods

Link to This

There's a lot of confusion about async/await, Task/TPL, and asynchronous and parallel programming in general. I've had some requests to dive into the topic, so we'll start with the basics and go deeper from there.

Rewriting a Legacy Application - Creating the MVP

Link to This

Here we take a look at a legacy application that I have running in my house (a home automation system). It's time for a rewrite, so we'll start by coming up with an MVP (minimum viable product) based on what we actually need. After that, we'll see that implementation isn't all that hard. In less than a week, we have a working product that can replace the existing legacy app.

Learning Git

Link to This

I finally got around to learning Git, and I really like it. If you've been putting off learning Git, now's the time to get started.

Exploring Code Analyzers

Link to This

The .NET Compiler Platform ("Roslyn") allows us to easily create diagnostic analyzers that can alert us to issues in code as well as provide automated code fixes. We'll create a very simple analyzer and fix to show how easy this is to do. This uses the Visual Studio 2015 Preview, and instructions on getting what you need are in the video.

Exploring Smart Unit Tests (Preview)

Link to This

Smart Unit Tests is a new feature in Visual Studio 2015 Preview that automatically generates tests based on existing code. The technology that accomplishes this is pretty cool. So, I decided to take it out for a spin to see how it works.

Coding Practice with Conway's Game of Life

Link to This

For a bit of coding practice, let's implement the rules for Conway's Game of Life using TDD. We'll start out with MSTest, but we'll find out a limitation: no parameterized testing. We'll move on to NUnit and discover how parameterized tests can make our testing code easier to follow.

After that, we continue the coding practice by adding a UI to display the grid of changing cells. And then we work on optimizing our code. What we'll find is that our "optimizations" may make our performance worse.

CallerMemberName Attribute

Link to This

In .NET 4.5, we got a new attribute: CallerMemberName. This let's us get the name of the member that is calling a method and use that value as a parameter. This can make implementing the INotifyPropertyChanged interface a lot better.

Leveling Up: The Professional Coder Workshop

Link to This

How can you create better software? What cutting edge practices can you employ to become a better professional? This workshop is a packed day of training and labs. Come experience how common design patterns, coding techniques and core concepts combine to make you more effective. More effective as an individual developer, more effective in a team, more insightful about how to go about things.

Coding Practice: Displaying Bitmaps from Pixel Data

Link to This

I started looking for articles on machine learning and ended up doing some coding practice instead. The sample take pixel data from a comma-separated values (CSV) file and turns them into bitmaps that are then displayed.

Clean Code: Principles, Patterns, and Practices for Better Code

You already code. Now it's time to take the next steps to becoming a better developer. Those steps are not difficult; we just need to put them into practice. The end result is code that is easier to maintain, easier to test, and easier to extend. Through lots of examples and hands-on labs, we'll learn about software design principles and the patterns that help us implement them. We'll see how Dependency Injection helps us create loosely-coupled code. And we'll spend a bit of time looking at Software Craftsmanship: ensuring that our code is readable by humans while still easy to maintain and test.

Practical Reflection in .NET

Reflection is an extremely powerful feature of .NET. But there is a big difference between what we can do and what we should do. Several of these features are useful to the everyday developer. We'll take a quick look at what reflection is capable of and then narrow our focus to practical uses -- balancing flexibility, safety, and performance.

Abstract Art: Getting Things "Just Right"

Abstraction is a blessing and a curse. Too little, and our applications are difficult to extend and maintain. Too much, and our applications are difficult to extend and maintain. Finding the balance is the key to success. The first step is to identify your natural tendency as an under-abstractor or an over-abstractor. Once we know that, we can work on real-world techniques to dial in the level of abstraction that is "just right" for our applications.

Changing Culture in WPF

Changing cultures in a running application is not straight forward. But it turns out there's a bit of a hack that works with WPF applications. This is easier than restarting the application and has less code that updating the resources in code.

Dependency Injection: A Practical Introduction

What is Dependency Injection? The answers to the question seem to cause more confusion than help. We'll take a look at what Dependency Injection (DI) is, when we should use it, and what design patterns we can use to help us implement it. Benefits range from extensibility to late binding to testability. We'll also determine whether DI is appropriate for our application.

Clean Code: Homicidal Maniacs Read Code, Too

There's no such thing as a write-once application. The world is constantly changing, and our code needs to change with it. We'll think in small pieces and take a look at some principles and techniques that will keep our code manageable and understandable. Think about the developer who will come after you. Now, imagine that he's a homicidal maniac who knows where you live.

T, Earl Grey, Hot: Generics in .NET

Let the compiler work for you. Generics shift the burden of type-safety from the developer to the compiler. To understand Generics, we'll take a look at some .NET classes from the BCL (such as List), comparing the generic and non-generic versions. Then we'll add Generics to our own methods to add flexibility and type-safety.

Metrocizing XAML

Several of the code samples have been updated to be more Metro-ish. The updates were accomplished without changing any of the application code -- that's what is awesome about XAML. With updates to some Data Templates, Value Converters, and a couple Control Templates, we can breathe new life into our applications that look dated.

IEnumerable, ISaveable, IDontGetIt: Interfaces in .NET

Do you want code that's maintainable, extensible, and easily testable? If so, then C# interfaces are here to help. We’ll take a look at how we can use interfaces effectively in our code -- starting at the beginning ("What are interfaces?") and then exploring why we want to use them. Along the way we'll use existing interfaces, implement own interfaces, and take a look at dynamic loading, unit testing, and dependency injection. All of which is made easier with interfaces.

Get Func<>-y: Delegates in .NET

Do you use delegates in .NET? If so, then Func<T> and Action<T> are just waiting to make your life easier. Not using delegates? Maybe you should. We'll take a look at what delegates are, why you would want to use them, and how to use Func<T> and Action<T> to tie things all together (with a few Lambdas thrown in just for fun).

Next, Please! - A Closer Look at IEnumerable

The IEnumerable interface keeps popping up in my samples, whether we're looking at Design Patterns, LINQ, Interfaces, or the BackgroundWorker component. That's because IEnumerable (or more precisely classes that implement IEnumerable) open up a whole world of possibilities. In this series of articles, we'll take a look at IEnumerable interface, what functionality it gives us, and how we can use this functionality to create useful classes.

XAML App Review

As developers, we usually don't get things exactly right the first time (gasp!). As we move from project to project, we are always learning. To help make those learnings stick, it's useful to go back to old projects for review. This series of articles takes a look at a Silverlight application that was put into production in 2009.

Meet the Next Code Camp Speaker: You!

Ever wonder where the speakers for Code Camp come from? Just look in the mirror. Everyone has something to share. Take the next step and sign up as a speaker. In this informal session, we'll talk about some practical tips to make your session successful.

Quick Byte: Get Func<>-y

If you look into the LINQ extension methods, you will run across Func<T, TResult> quite a bit. If you see a Func<> in a method definition, you can treat it like a big sign that says "Put your lambda expression here." What we'll see is that Func<> is simply shorthand for creating a delegate.

Learn the Lingo: Design Patterns

You already use Design Patterns but probably don't know it. Observer, Adapter, Iterator, Proxy -- Learning the lingo allows you to better communicate your ideas with other developers. We'll take a look at several GoF patterns that we regularly use without realizing it. Don't know who the GoF is? Read on to find out.

Learn to Love Lambdas (and LINQ, Too!)

Lambda expressions can be confusing the first time you walk up to them. But once you get to know them, you’ll see that they are a great addition to your toolbox. Used properly, they can add elegance and simplicity to your code. And some .NET constructs (such as LINQ) lend themselves to lambda expressions. We’ll take a look at how lambda expressions work and see them in action.

Quick Byte: Extension Methods

Extension methods allow you to add functionality to existing types by adding new methods -- not subtyping required. Here's a quick overview of how they work.

Keep Your UI Responsive with the BackgroundWorker Component

Long running processes are a user experience killer. How many times have you had an application "lock up" while trying to do some function? The BackgroundWorker component in .NET allows you to spawn those long running processes in the background and keep your WPF, Silverlight or WinForms user interfaces responsive. We'll take a look at the features of the BackgroundWorker in a WPF application including running a background process, updating the progress in the UI, and cancelling the process before it has completed.

Introduction to XAML: Don't Fear the Markup

Understanding XAML (eXtensible Application Markup Language) is a key to creating the latest .NET user experiences in WPF, Silverlight and Windows Phone. We will introduce the basic concepts around XAML and take a look at various features such as namespaces, elements, properties, events, attached properties and some basic layout. We’ll create a simple WPF / Silverlight application that covers these fundamentals. Although you will probably end up doing most of your UI design with a drag-and-drop tool such as Expression Blend, knowing the internals gives you a leg up in making the final tweaks to ensure an excellent user experience.

NOTE: This demo is available in both WPF and Silverlight versions. The same XAML features are covered in each environment.

Introduction to Data Templates And Value Converters in Silverlight

Business applications are all about data, and laying out that data is critical to creating a good user experience. Silverlight has several tools, including Data Templates and Value Converters, that make this easier for the business developer to manage. By the time we're done, you will have a good understanding of the basics of both of these valuable tools.

Quick Byte: Statement Lambdas

The first time I came across a lambda expression, I was perplexed. I could tell that something important was going on, but I got stuck on the new syntax. As I studied them some more, I had an "aha" moment, and it all clicked into place. This is a brief runthrough of that process with statement lambdas.

Target Practice - Silverlight 3 / XAML Sample

XAML has intrigued me ever since I took a close look at it. Previously, I created an entire WPF application using only XAML (it's trivial, yet functional). When I got started with Silverlight 2, I wanted to replicate that application. Unfortunately, there were limitations to Silverlight 2 (such as a lack of triggers) that kept me from implementing it. Silverlight 3 allowed me to implement the application entirely in XAML.

Silverlight 3 / Visual Studio 2008:

Data Templates & Value Converters - Silverlight 2

Here's a few more useful things that I've come across. This time, it's Data Templates (which make List Boxes extremely flexible) and Value Converters. Note: this is applicable for Silverlight 3 as well (although Silverlight 3 does have some additional features that makes this easier).

User Controls and Events - Silverlight 2

This demo shows how to split out a section of your UI as a user control. We'll also add an event to the user control that the other controls can hook into. Note: although this application uses Silverlight 2 (and Silverlight 3 has better ways of implementing this particular scenario), the concepts of eventing are still useful in other contexts.

Silverlight 2, WCF, and Lambda Expressions

This is an introductory demo in creating a WCF service and consuming it with a Silverlight 2 application. In addition, we'll take a look at the various ways of creating the call backs for the service (Event Handlers, Anonymous Delegates, and Lambda Expressions) and the various advantages of each. Note: this demo is applicable for Silverlight 3 as well.

Target Practice - WPF / XAML Sample

XAML has intrigued me ever since I took a close look at it. In this demo, the goal was to create an entire application using only XAML. This application is somewhat trivial, but it shows the power and flexibility of XAML and declarative programming.