Introduction Swagger is a way to document a REST API, and tools can automate much of this process (but not all of it). At the centre of things is a JSON file that describes the API. You can create this file by hand or use a tool to generate e.g. from the API source code. … Continue reading Documenting ASP.NET REST APIs with Swagger / Swashbuckle
Category: Coding
Surgical drapes for programmers
Introduction You’ve probably seen medical dramas on TV where someone is lying on an operating table, and medical staff with gowns and masks are operating on them. You can’t see most of the person because they’re covered in green sheets, which are called surgical drapes. There’s a gap in the sheets big enough for the … Continue reading Surgical drapes for programmers
Counting – fence panels or fence posts?
Introduction This is a post about fences, but not in the good fences make good neighbours sense that you might expect. (This could be the way into lots of good things about interfaces, encapsulation and so on.) In this post I'm not interested in the things that the fence is separating, but in the fence … Continue reading Counting – fence panels or fence posts?
Named parameters with default values can help unit tests
Introduction I find myself using default values much more in unit tests than in production code. That is, I do it more often, and use more parameters with defaults per method. This isn't because default values are bad, but they are often particularly useful when setting data up for unit tests. It makes the tests … Continue reading Named parameters with default values can help unit tests
Going a bit deeper with Don’t Repeat Yourself (DRY)
DRY, or Don't Repeat Yourself, is a principle of software engineering. It makes code quicker and easier to understand and to change. For instance, instead of having the same chunk of code typed out twice or more, you carve it out into a method and then call it each time you need it. However, I … Continue reading Going a bit deeper with Don’t Repeat Yourself (DRY)
An introduction to integers and floating point numbers
Integers on a computer are simple and behave in predictable ways. Floating point numbers are not and don’t always respectively – I’ll explain what they are and why below. Working with floating point numbers is also slightly like cleaning up after my dogs, which I will also explain below. Integers Integers are a bit like … Continue reading An introduction to integers and floating point numbers
Balancing big picture and details when coding, testing and documenting
Introduction I very much hope that this avoids being a rant. I also hope it avoids being self-indulgently clever rather than being helpful. Finally, I understand that people learn in different ways; I think I like images and like to get the big picture before getting into detail. Other people like to be led along … Continue reading Balancing big picture and details when coding, testing and documenting
Single-step your code before you hit bugs
Introduction The habits or practices you adopt as a programmer influence your productivity and the quality of your output. The consequences of these practices can be good or bad, intended or unintended. After a brief stop off at the practice Test-Driven Development, I will go into another one: using a debugger to single-step your code … Continue reading Single-step your code before you hit bugs
Testing a Web API
If you write a Web API (I’m using this to mean any API that you call via HTTP, such as a REST API using the Microsoft Web API framework), the world it’s part of is: It’s likely that while you’re developing, Client machine = Web server machine = Database machine, but this might not be … Continue reading Testing a Web API
I couldn’t possibly comment
While there is always some new tool or technique to learn in programming, there are other things where you think you've already got it sorted. Commenting your code is one of those things for me. When I read a recent article on comments, that asked if comments were good or bad, I thought "Obviously, they're … Continue reading I couldn’t possibly comment