Posts from 2020
-
2020-12-31 The Books I Read in 2020
2020 was well, a shit storm. I didn’t do much of anything once the country shut down in early March. I had a semi-productive garden, and adjusted to working from home. Fortunately, and most importantly, my wife and I enjoyed good health.
One of my hobbies is reading and this year was a good reading year, all things considered. I found it difficult to concentrate and didn’t read as many books as would have liked. But the books I did read I enjoyed, for the most part.
Here is the list of them and a brief mention of the effect they had on me.
-
2020-12-27 Modern C#
C# has evolved a lot in recent years and I am guilty of not taking advantage of some of the new syntax to improve my code. Here are some of the new features I need to remember to use more often.
-
2020-12-20 Choosing the Correct LogLevel in ASP.NET Core
ASP.NET Core includes a very powerful and easy to use logging framework. It provides you with a lot of options, including the level you want the log entry to be made. It can be tricky to choose the correct level so let’s explore it a bit.
Assumption I assume you are using the logging API to store logging messages to a persistent store, like a file, or a database.
-
2020-12-06 Software Kata Part 3 - Progress Update
As described in Parts 1 and 2, the concept of kata in software development has been around for years. I decided to start a process of regular practice with Angular and ASP.NET Core to retain my skills and to improve them over time. Here is my progress update on what I learned from completing only two sessions.
-
2020-11-29 Clean Architecture Ideas for Microservices using ASP.NET Core
I have written about a Clean Architecture on several occasions. While I don’t see eye-to-eye with its popular proponent Robert C Martin on several ideas he has, the use of a Clean Architecture is not one of them. It is a effective approach to creating any software application. Over the last year I have worked with a set of microservices written in ASP.NET and I thought I would write down some of the ideas I had regarding the use of a Clean Architecture in this context.
-
2020-11-28 Software Kata Part 2 - ASP.NET Core
As described in Part 1, the concept of kata in software development has been around for years. I decided to start a process of regular practice with Angular to retain my skills and to improve them over time.
The same goes for ASP.NET Core, my backend HTTP API development tool of choice. While there are other API frameworks out there, ASP.NET Core is by far the simplest and powerful one I have come across. One can star up a new API project and get it up and running in no time. But I don’t create a new API from scratch very often. SO I plan on practicing it as well.
-
2020-11-24 Software Kata Part 1 - Angular
The concept of kata in software development has been around for years. The idea is to memorize and improve your coding skills through repetition and practice.
-
2020-11-22 Verifying Structure with EF Core
Sometimes when using EF Core with an existing database, the underlying database structure can change without you knowing. Here is how you can verify the structure of the database matches the code.
-
2020-11-15 Timeouts in ASP.NET Core hosted by IIS
When developing and maintaining ASP.NET Core applications, it is possible you will encounter timeouts with the deployed application. If you are using IIS to host the application, it is helpful to know how it all strings together.
-
2020-11-08 Unit Testing in Controllers Part 2: ClaimsPrincipal
In the first part of this mini-series, I showed how I created a simulated HttpContext for a controller action unit test. In this post I wanted to describe how I added a ClaimsPrincipal implementation.
-
2020-11-07 Unit Testing in Controllers Part 1: QueryString
The ASPNET Core approach to processing HTTP requests is to abstract as much as possible. As a result, it is rare that you have to use anything but POCO classes when processing a request with a controller action. All the HTTP-ness is nicely hidden behind model binders and value providers that parses the incoming request (query string, form, body, url, etc.). This makes it possible to unit test your controllers without having to create mock implementations of the HTTP request itself (ie. the HttpContext).
But this doesn’t work in all cases.
-
2020-11-01 Column Not Found with EF Core
This week I encountered an odd error while working with EF Core. I hand-crafted a C# class representing an existing table in a legacy database. I added it to my
Context
, just like I had with dozens of other tables. But when I queried the table, EF Core raised an exception. -
2020-10-25 Loading JavaScript in Angular
The project I have been working on integrates with an external API. It requires a JavaScript reference to be added to the
index.html
file (i.e. a<script>
element). The URL to this script changes, depending on the environment the application uses (local, dev, test, prod). I wanted to explore how to make this reference dynamically loaded via theenvironment
configuration file. -
2020-10-17 This Week in Angular
This past week I spent a good portion of my time working on an Angular project. It is only the second Angular project I have worked on so my experience is limited. But I wanted to write down some thoughts on what I felt using this technology. My future self might like to remember what it was like.
-
2020-10-10 Prototype Versus Mockup
Some people use the terms prototype and mockup interchangeably. In my mind, these are two different concepts and serve slightly different needs.
-
2020-10-04 Integrating Angular with an Identity Provider
Security is a fundamental aspect of any website application. This is especially true for Angular applications (and other browser-based applications). Here are some notes, links, and samples I have used to help me implement security correctly.
-
2020-09-26 Using SSL Locally With Angular
In this day and age, it is required that all websites use SSL. So I want to ensure I am using it wherever possible. When developing locally with Angular, I wanted to use https://localhost:4200/. I found a couple of ways to help, but it didn’t go exactly as planned.
-
2020-09-20 Using Code Inspections the Wrong Way
Modern IDE tools provide a wealth of productivity features including automated code inspections. These analysis tools run in the background and give you advice (suggestions) or raise warnings (or errors) when they discover a problem. How you react to them is important. Let’s see how not to do it.
-
2020-09-13 Who Pushes You?
Every now and again, you need a little push to get you moving in the right direction. Who pushes you?
-
2020-09-06 Situational Awareness
I feel that decision making requires a good sense of Situational Awareness. This applies to a lot of situations, including software development. Let’s explore it, shall we?
-
2020-08-29 A Year of Writing Blob Posts
A year ago I challenged myself to write one blob post a week. Here are some of the things I discovered over the last year.
-
2020-08-22 Creating Rulesets for .NET Core
I found a useful Roslyn Analyzer for C# projects that added compiler warnings for some common coding issues. I didn’t agree with all the default settings so I wanted to disable a few. Here is how I did it using a Custom Ruleset.
-
2020-08-17 Using EditorConfig with C#
Consistency is very important when coding software programs. Ideally everyone on your team should follow a common set of coding styles. EditorConfig helps maintain consistent coding styles. Let’s see how it fairs with C#.
-
2020-08-08 Small Pull Requests Work Best
One of the reasons that Agile software development approaches work so well is the way the work is performed in small iterations. Breaking down complex tasks into smaller pieces means that each piece is much simpler to define (ie. requirements), implement, and test. The same goes for code changes submitted as a Pull Request. It takes practice to work with small sets of changes, but the benefits are worth it.
-
2020-08-01 How I Synchronize Changes With Git
As with most things, there are more than one way to accomplish a task. But some are better (simpler or easier or faster) than others. I’d like to share my approach to synchronizing my local branch with Git. It is not the ‘best’ way or the ‘only’ way, but it works well for me.
-
2020-07-24 Windows Event Logs with Serilog
If your .NET Core application needs to store log entries in a Windows Event Log, Serilog has a great option. However, the samples and API documentation aren’t that great. So here are my notes on my experiences.
-
2020-07-19 Coding Minimalism
I believe and promote the philosophy of Coding Minimalism. Let’s explore what it means and how it affects developing code.
-
2020-07-10 Rely On Your Keyboard
I forget sometimes how much I rely on the keyboard to select and manipulate text as a software developer. It makes me very productive simply because I take less time to get work done. I encourage all developers to rely on their keyboard more and their keyboard less.
-
2020-07-06 Be Excessively Kind
Today I faced a moral question. An author, whose books and teachings have had influence over me, published some statements and ideas I found inappropriate and offensive. Does that mean I should disavow his contributions to the industry I am passionate about? This wouldn’t be an issue if he had followed one piece of advice. Be Excessively Kind.
-
2020-07-05 ASP.NET Code Logging - Lessons Learned
The built-in logging support in ASP.NET Core is wonderful. But there are ways you can shot yourself in the foot if you aren’t careful. Here are some lessons I’ve learned to help make logging better.
-
2020-06-21 An Approach to Reviewing Pull Requests
As part of my job, I am often asked to review pull requests from other developers. Here are some ideas on my approach and things I have learned along the way.
-
2020-06-13 Setup Order Using Moq
I use Moq to help create test doubles in my unit tests. I discovered that setting up the order of fake method call can affect how they behave.
-
2020-06-03 The Cost of Broken Windows
In the book The Pragmatic Programmer I was first exposed to the idea of “broken windows theory” and how it impacts the life of a software product. I was reminded of that this week and it is still an important concept to consider in software development.
-
2020-05-25 Test Doubles in C# with Moq
Unit testing relies on creating automated and repeatable tests. A powerful technique supporting this practice is using test doubles. I use the Moq library for this and find it works very well…. with a few tweaks.
-
2020-05-17 Why Do We Write Unit Tests?
A lot of time we get wrapped up in our day to day work and forget to be mindful of the reasons why we work a certain way or follow a particular approach to software development. One such practice is unit testing our code. It is important to remember why we test our code and how to do it well.
-
2020-05-10 The Most Important Rule for Testing Existing Code
When following Test-Driven Development (TDD), one creates a failing test and then writes code to make the test pass. But what if the code already exists?
-
2020-05-03 Remove and Sort Using in C#
Code is a liability. The more code you have to maintain, the more challenging it becomes. Small bits of additional code can built up over time and it is important to stay on top of the waste as you build and change the code. A perfect case in point is removing unused and sorting using directives.
-
2020-04-28 Too Much of a Good Thing
Each line of code is a liability. The more code you have, the more can go wrong; the more you have to maintain and test. Finding ways to keep code to a minimum is part art and part science. However, it is a skill that can be learned.
-
2020-04-19 Using Stored Procedures with EF Core
Sometimes, especially when using a legacy database, it is necessary to call stored procedures. Here are some of the ways possible with EF Core using SQL Server.
-
2020-04-12 Functional Architecture: Is it the Answer?
C# is an object-oriented language first, but has a number of functional programming capabilities. I like to think that these two approaches compliment each other more than one being superior to the other.
-
2020-03-29 Dealing with ASPNET Core 3 API Contract Changes
If you work with HTTP API endpoints long enough, you will encounter scenarios when you want/need to make changes to the data contract without breaking changes. Prior to ASPNET 3, the
[DataContract]
and[DataMember]
attributes made it possible. However, with the new JSON parsing library in ASPNET 3, these are no longer as straightforward. -
2020-03-21 Using Shared Databases with EF Core
Sometimes it isn’t possible to have a nice clean database to work from with EF Core. Using EF Core with an existing database is well understood. However, there are a few gotchas.
-
2020-03-14 Isolation Levels with EF Core
When using Entity Framework Core, transactions are a fact of life. When using
TransactionScope
to explicitly manage business transactions there are some gotchas you should be aware of. -
2020-03-07 Upgrading GEM on GitHub Pages
Whenever I receive an email from GitHub indicating a new security advisory on my blog, I can never remember how to update things.
This is meant to list the steps so I don’t have to relearn things each time.
-
2020-02-29 Why object initializers and conditional operators are bad
Originally published Nov 17, 2013.
I recently listened to a podcast from Scott Hanselman where Douglas Crockford discussed ideas about good parts and bad parts of programming languages. I was familiar with Crockford’s wonderful book “JavaScript: The Good Parts” and found the podcast to be equally enjoyable to consume. (If you haven’t already, I would recommend you listen to the podcast.)
Let’s face it, all programming languages are made up of good parts and bad parts. One of Crockford’s great insights is that he (and the rest of us programmers) create better programs when only using the good parts of a programming language.
It got me thinking about the day-to-day coding I do using C#. C# is a pretty impressive programming language. But what are the good parts? And equally importantly, what are the bad (and truly awful) parts?
-
2020-02-23 Test-Driven Development: Is it necessary?
This is a post originally written in May of 2014. Still relevant today I feel. Not my best writing to be sure, but I love the Google+ reference.
-
2020-02-16 ASPNET Core Unit Testing Lessons Learned Part 4
When building a Web API endpoint with ASPNET Core, the test cases can get confusing at times, just like with testing any complex code base. Using fluent assertions can help manage that complexity and make the tests easier to read and understand. Of course, so does naming things in a logical manner. Let’s take a look at these in more detail.
-
2020-02-09 ASPNET Core Unit Testing Lessons Learned Part 3
When building a Web API endpoint with ASPNET Core, you end up writing a lot of tests. Along the way I found some ideas that helped me manage them more efficiently. Let’s take a look at a few. Note, that most of these apply to any testing effort, not specifically to ASPNET Core projects.
-
2020-02-01 ASPNET Core Unit Testing Lessons Learned Part 2
When building a Web API endpoint with ASPNET Core, it is desirable to keep the Controller classes as small as possible. The important logic should be in business classes or input/view models. What remains in the Controllers should be simple. But, they still require unit tests in some situations. Let’s look at some of these patterns.
-
2020-01-26 Custom Serilog Configurations with ASP.NET Core 3
I am particular about the logs my application generate. Here are some ways I have found to customize Serilog with ASPNET Core 3.
-
2020-01-19 Sequential GUID Values for SQL Server
As a developer, I design applications that are testable, easy to understand, and the best representation possible of the real world concepts. Sometimes, I do not think of the database and its design with as much concern or care. Inevitably, that causes performance problems that need addressing. Such an issue presented itself this week when using a GUID data type as the primary key of a table in SQL Server. Let’s take a look at the issue and the set of possible solutions.
-
2020-01-11 ASPNET Core Unit Testing Lessons Learned Part 1
When building a Web API endpoint with ASPNET Core, my team and I have strived to include appropriate test coverage on all the REST endpoints. This includes unit tests on all the business/domain classes the endpoints use to process each request. This is the first in a series of posts that describes some of the lessons we have learned along the way.
-
2020-01-05 Capture Response Header in Postman
When building a Web API endpoint, my team uses Postman to send requests to the endpoints and confirm the correct results. One could argue that Postman is our user interface. One use case we run dozens of times a day requires us to copy-and-paste a value from one response into the request for another endpoint. It is slow and tiresome and I was curious if Postman could help us be more efficient. Turns out, I was right.