This post is part of C# Advent organized by @mgroves. This is the time of the year when many of us are planning Christmas Parties. There is often a sign-up where attendees can indicate what food they want to bring. These usually ensure people bring the right mix of cookies, pie, and candy canes. But it doesn’t ensure the optimal assignments. The problem is that these sign-up sheets work on a…
This post is part of 2023 C# Advent ! Be sure to check every day for new posts from the .NET community! Recently, I was teaching C# to a group of developers. When I got to the topic of ranges, I was surprised at how much nuance there was. In this post, I don’t want to go into all of the features of ranges. That is covered in other places. I want to look at the structure of ranges to see that we…
Like many of you, I’ve got two computers on my desk when I’m at work. I was getting frustrated that I repeatedly needed to unplug my headset from one computer to hear the audio from the other. Who wants to stop listening to The Mighty Mighty Bosstones on their Mac Mini just so that they can hear part of a tutorial video on their laptop? I fully realize this is a first-world problem, but I still…
Note: This post is a part of the 2022 C# Advent Calendar. You can see the rest of the posts here . The Microsoft Graph API is a powerful way to automate interactions with the Microsoft apps you use every day. For example, you could use it to generate Todo items in your Microsoft TOOD account based on data in an Excel spreadsheet. Or you could respond to an event in your custom application by…
From time to time, I need to create a small C# or F# solution to experiment with a code feature or a library function. Often, what I want to do is create a simple console application and a unit test project that references the console application. This isn’t hard to do in Visual Studio, but it feels like it takes too many steps. Recently, I read a fantastic new book called Essential F#, by Ian…
TypeScript has an interesting feature that lets you define a type for a subset of valid strings. These are called String Literal Types. String Literals are a special kind of Union Type. At first glance, this looks similar to an enumeration. But enumerations use numbers as their underlying storage. String Literals maintains all of the behavior of strings. If I define a String Literal as I did on…
Each of the dozens of git repos on your machine contains a .git folder. But you may have never thought about the details of its contents. You know that somehow the folder holds the history of every version of every file ever committed to the repository. You just don’t know how. The contents are less mysterious than you think. For obvious reasons, git optimizes the contents of the .git folder for…
This post was written and published as part of the 2021 C# Advent . One of my favorite new tools is the .NET Interactive Notebooks plugin for Visual Studio Code. It allows you to intermingle executable code and markdown descriptions of it. So you can explain the code, run the code, and see its results all in one place. This makes the notebooks incredibly useful for teaching and exploring concepts.…
Earlier this month, a blog post went viral titled “ Complexity is killing software developers ”. The article is worth reading. It talks about how to control complexity. I agree we should try to reduce complexity. But what do we do when the dev work we do is necessarily complex? In this post, I want to discuss a tool to help developers work more effectively when solving complicated and complex…
I’ve been using the Pomodoro Technique to structure my work day for a few years I find it very helpful to plan and focus my work. But it requires a timer. I have used Tomighty and PomoFocus.io , but I wanted something different. I wanted a way to see the status of the pomodoro at a glance. I decided to try to use the Windows API that allows apps to display their progress in the taskbar to display…
A friend once told me that when I type in front of people, I spell like a drunken toddler on a broken keyboard. For years, I’ve worked to hide my poor spelling ability by removing the errors with a spell check tool. But then I got a different idea. What if, instead of trying to remove all of my mistakes, I had the software add more. That way, you wouldn’t know which spelling errors were mine and…
This is my contribution to the fantastic series of blog posts in this year’s C# Advent Calendar . Please check out the rest of the posts for more great content. In my past two posts , I’ve looked at upgrading an older C# code base to .Net 5. In this post I’m going to start looking at modernizing the code in that library to use C# 9. Specifically, I’m going to look at the benefits of using Init…
In my previous post , I described my efforts to upgrade an older .Net Framework code base to .Net 5. The initial effort was to get some class libraries moved over. Those libraries didn’t have many external dependencies. This post will describe what it took to upgrade other class libraries in the same solution that required dependency changes, many System.Configuration.ConfigurationManager. While…
Next month, .Net 5 will be released. This marks an important evolutionary step for .Net as it switches the primary platform from .Net Framework to .Net Core. Microsoft will upgrade .Net Core 3 and rename it to .Net 5. The version jump signifies that it now supper cedes .Net Framework 4. It will be important for all .Net Framework projects to move to .Net 5, or start down the slow road to…
As software developers we spend a lot of time writing unit tests. We worry about writing enough tests to give us good code coverage. We obsess over which test framework and test runner to use. We ensure that our tests run quickly. We run our test suite after every change and before each check in. But do we think about the different types of tests that we need write? Do we ever take the time to…
All too frequently, we hear news of another major software bug. Bugs from big companies make the biggest news. Bugs from little companies seem just as common. As programmers, all these bugs are costing us time and money. We know we need to improve. But we can’t seem to figure out how. As an industry, we’ve tried solving this problem with increasingly complex processes, increasingly complex tools,…
One of the beautiful things about software development is that you can build any application you want, no matter how large or small, with code. As Fred Brooks so elegantly said “The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination.” We write code to build functions. With more code, we…
This blog post is part of Third C# Annual Advent organized by Matt Groves, Developer Advocate Couchbase and Microsoft MVP. Thanks to Matt for giving me an opportunity to participate again this year. You can follow the C# Advent here . C# 8 introduced the ability to access subsets of collections with range operators. Frequently, ranges are used to access arrays or spans, but they can also be used…
One of the challenges of modern software development is handling errors in elegant ways. Fortunately for TypeScript users, there is a clean way to indicate whether or not a function encountered an error by using Union Types. Let’s consider an simple example where there is a table in a database that contains information about programmers. We have a function that intends to take the programmer’s…
For the second year in a row, Matt Groves is coordinating the C# Advent Calendar . It is a fantastic collection of posts on a wide variety of C# topics. I strongly encourage you to check out the other posts in series. For my entry, I wanted to take a look at the C# codebase behind the C# compiler. I’ve been fascinated with the Roslyn codebase ever since it was announced. With C# 8 now released in…
The power of machine learning algorithms has exploded in the last few years. Machine learning gives your app the ability to recognize objects in an image. Or it could detect the attitude of a user from something they wrote. This was beyond the capability of common apps until very recently. But in order to use machine learning algorithms correctly, you complete three challenging tasks. Find the…
The new tuple syntax that was added to C# in C#7 has made my code cleaner and more expressive. It isn’t a feature that I use every day. But when there are multiple values that need to be moved as a cohesive group, it is very nice. And it is a big upgrade over the older generic tuple that always had its members named Item1 and Item2. While the generic tuple was useful for creating lightweight…
One of the fascinating capabilities of Azure Cognitive Services is the ability to get a sentiment score for a text string. The score is a numeric value between 0 and 1. Values closer to 1 indicate that the statement is conveying a positive sentiment. Values closer to 0 indicate a negative sentiment. This could be used to gauge how people feel about a product launch by getting the sentiment score…
I have many fond memories of playing the original NES as a kid. So when I found out that someone had created an NES emulator that had an API, I was thrilled. The emulator I’m talking about is called Nintaco . And in this post I’ll show you how to write a simple bot in C# that plays an NES game. Nintaco is a full featured NES emulator written by a developer that goes by ‘zeroone’. You can use it to…
In a previous post , I looked at how I could use Azure Congitive Services to look at the keywords from the StirTrek conference session titles. In this post I want to continue that exploration and see what we can learn about the service and the conference. I am going to use the Text Analysis API. Specifically I am going to call the API that will return the key phrase or phrases for any input text.…
The thing that I want to talk about in this post is not something new. It is something that has been available to Visual Studio developers for a few years now. It is not something that I see many people using. But it is something that I find to be very useful. I am talking about T4 templates. T4 templates allow you to generate text in a similar way to how Razor pages allow you to generate HTML. It…
Machine Learning is revolutionizing how we think about processing data. But machine learning algorithms can have a steep learning curve. Luckily, Microsoft has released an easy way to access very powerful machine learning models through Azure Cognitive Services . They expose the power of machine learning through the ease of calling a REST API. Microsoft provides good samples for calling into the…
Creating integration tests is a great way to validate the functionality of a web application, from the JavaScript all the way to the database. One of the challenges comes from the fact that data is being persisted to the database. In some cases, this prevents the tests from working properly when the test run is repeated. As an example, let’s say that we have a test that creates a user account with…
The last time I was in the market to buy a car, I started by reading a lot of reviews. I talked to people that already owned the cars that I was interested in. I did comparisons of my top choices online. But before I would ever buy a car, I took it for a test drive. In fact I took several cars for test drives before buying the one that I liked the best. I often take a similar approach with…
As a consultant, I am frequently working in new code bases. Sometimes they are quite large and have existed for many years. In these cases, it is important to get a feel for how the project is structured. It is important to understand where the important parts of the code are. NDepend is a tool that helps developers understand what is going on in a code base. It provides graphical summaries of the…
Microsoft recently a preview version of their Microsoft Flow connector for CosmosDB. If you haven’t tried out Flow before, connectors are the tools that allow you to integrate external services into your workflows. Connectors allow you to read or write from data sources like Twitter, Office 365, Dropbox and many more. Flow already had connectors for SQL Server, PostgreSQL, and MySQL. They work…
Much has been written about how many APIs have been added to .Net Standard between version 1.1 and 2.0. I wanted to share a practical example of how this API growth has improved the product. There is an NES emulator named Nintaco . It can be controlled via an API , meaning that you can write a bot to play an NES game. There are API examples in several languages including C#. I got permission from…
I’ve been in love with pattern matching in C# since I first heard it was going to be added to the language. I had used it in F# and was excited to use it is C#. In a conversation I had this week I realized something important that I had known about pattern matching, but I had never articulated it. One of the most powerful things about pattern matching is that it cleanly combines a conditional…
The majority of the code I write completely abstracted away from the hardware it eventually runs on. If I am writing a Web API in C#, my code only knows what is will be run by the CLR, which may be running a server or an Azure host, but the code doesn’t need to know which one. And it certainly doesn’t need to know what kind of RAM is installed on the machine that it eventually runs on. It doesn’t…
In the previous post , there was a subtle feature that I didn’t highlight. That was the fact that the switch statement was switching on a tuple, which is a struct. This might not seem like a big deal, but before C# 7.0, if you tried to switch on a struct, you would have gotten the following error message: “A switch expression or case label must be a bool, char, string, integral, enum, or…
As I discussed in my previous post , pattern matching in a new feature in C# 7.0 that provides a more sophisticated way to write selection statements. The situations where sophisticated selections statements more necessary is when selecting on multiple criteria. Often this is seen in other languages when matching against tuples. In an older post , I looked at how Swift uses tuples and pattern…
As someone who dabbles in F#, I was excited when I heard that C# was getting Pattern Matching. In this post I want to look at why it is so beneficial. The three basic control flow mechanism available in all programming languages are selection, iteration, and calling subroutines. In same way that a foreach loop is an evolutionary step for iteration, pattern matching is an evolutionary step for…
One again, the content at CodeMash is going to be fantastic. There are great sessions all over the place. If you are attending, you will be like a blind dog in a butcher shop. Even if you don’t know where to go, you will find good content. That be said, it can be hard to pick which sessions to attend. I’d like to offer some humble suggestions. But before I do that, I’d like to offer a few caveats.…
Recently my son was looking at a globe and asking me questions like ‘Is Ecuador bigger than Texas?’ I found the answer quickly on Wikipedia, but it got me thinking that it may be fun to have a graphical representation of the comparison. I decided to put the GUI together as a web application using Aurelia. I wanted to have a list of checkboxes to allow my son to select the countries or states that…
That is a drywall saw. You can’t use it to measure a board. You can’t use it so see if something is level. You can use it to remove a screw. You can’t use it to drive in a nail, or at least not very efficiently. In fact, the only thing it does well is cutting drywall. It isn’t a tool you use frequently. I’ve only used mine a handful of times. But when you need it, which is generally when you are…
If you have been writing software for any length of time, you have almost certainly found yourself staring at a source file where you have made a mess. It had been nice and organized, but then you needed to add a feature. you wrote your tests and implemented the code. Your application is running as fast and smooth as a BMW on the Autobahn. But all of your changes have left the code as disheveled…
I can remember the first time I wrote code in an editor with syntax highlighting. It seemed to make the code so much more readable. Instead of looking at a wall of black and white text, I was getting visual cues about what was going on. The thing that I love about the Viasfora extension for Visual Studio is that it takes this concept to the next level. Viasfora simply adds color to source files to…
As a developer who primarily creates web applications on the .Net stack, I spend a lot of time in Visual Studio. For smaller edits, I’ll use tools like Visual Studio Code of gVim. But most of the time I want to be able to take full advantage of the full array of tools Visual Studio provides. Whether I am creating projects, editing files, or debugging code, Visual Studio offers an unmatched feature…
As software developers, we must be dedicated to continual learning. It can be hard to find time to keep up with things we need to learn. Something that I have found to be helpful is to listen to audio books. Guys like Cory House and John Somnez have done a good job extolling the virtues of listening to audio books on your commute. I’m a big fan of Audible.com and have learned much from books in…
One of the most amazing features in F# is Type Providers . They allow you to access data sources in incredibly easy ways. You can query data from databases, read data from CSV files, or consume JSON data from an API. I’m not going to go into depth here on Type Providers, but if you are unfamiliar with them, you should go check them out . Often times when I am writing Canopy tests, I want to…
One of the things that F# is particularly good at is dealing with things as lists. So when I had a Canopy test that needed to verify the elements on a page were sorted correctly, I looked for a way to leverage F#’s strengths. I am primarily a C# developer, so my first instinct was to get the elements, loop through them and check the ordering. But after some digging I came up with this solution.…
Recently a read a blog post by Eric Lippert about the top ten things he wished had been designed differently for C#. If you have not read it, you can find it here. It is worth reading in its entirety. The section that got me thinking was “#3: I rate plus-plus a minus-minus”. In it, he makes some very solid points about his dislike of the increment and decrement operators. Firstly he points out…
Yesterday Microsoft released Update 1 for Visual Studio 2015. There are a host of great features that were added. There are other blog posts that cover all of the features that are included. I just want to highlight the one that I am most excited about. In the previous versions of Visual Studio, you had the ability to right click on a method invocation statement and click ‘Go To Definition’. This…
So I had this idea. I had been using speed reading sites like Spreeder and Spritz . They accelerate your speeding by only showing you one word at a time. The words are always in the same place, so you don’t have to move your eyes. I found them to be a very helpful way to get through my daily reading list. The only problem was that at times I wanted to vary the speed at which I was reading. Both of…
As part of our continuous learning efforts at Aptera, we had a competition to see who could come up with the best implementation of Fizz Buzz in Swift. This was my first time coding in Apple’s new language. The Simple Solution At the beginning of my career, I was a C / C++ developer. So for my first implementation, I fell back on those roots. See it in action The first thing worth noting is that…