C#
Sam Lau  

Things you should learn to get into C# .NET backend development

I have been working as a C# .NET engineer mostly working in the backend for almost 6 years. C# is very popular in enterprise environment and used a lot in backend development. I want to share my experience in the field and give some advise if you want to get into this field or just starting.

What is backend?

First of all, let’s definite what is backend development. In a broad sense, anything not frontend can be called backend. Frontend usually means Web UI that the user interact with. Backend is all the things after that layer. That include Web API that the Web UI talks to send data from and to, datastore / databases that store data, message queue that transfer data between services.

The main theme here is data. Backend development usually deal with data. The focus is how data is stored, transformed and transfer. In fact, there are companies / products that are purely backend. It could be some computation engine that transform data and the only way you interact with the service is through some APIs.

Databases

As backend is data-centric, The first thing I suggest learning is databases, where data is stored. Traditionally, most C# .NET tech stack use SQL / relational databases. Even though there are more companies adopting newer fancier NoSQL databases, I would say that SQL is still king in the industry. It is import to understand how SQL syntax work, what is ACID, how relations are handle with parent / foreign keys and how indexes work.

If you would like to dive deeper, I would look into SQL vs NoSQL. In fact, NoSQL is just a name for anything not SQL / relational. There are many different types of NoSQL and each address different downfalls of SQL. The main takeaway is to understand there is no single best datastore. Everything is about tradeoff. SQL was being used everywhere at some point because it provided the best balance of tradeoff at the time. The exercise of looking into different database technologies will help you understand the fundamentals of data storage.

Web API

After knowing databases, the next important thing is Web API, where data is being transferred. A lot of modern backend work involve developing Web API. An API is the interface for applications to talks to each others. This is usually how a Web UI gets its data. You can say Web API is the frontend of backend.

The modern web framework in C# .NET is ASP.NET Core. Modern ASP.NET Core supports two approaches to creating APIs: controller-based and minimal APIs. I suggest starting with controller-based as it is still widely used as it is the way API is developed for a long time. Minimal APIs is the newer kid so you will not see it as often. Regardless, whatever you learn from one approach will like be transferable to the other.

The main concept to learn here is RESTful API (there are other architectural, like GraphQL, but REST is still the most popular), HTTP protocol, dependency injection, Swagger / OpenAPI, JSON, etc. The best way to get started is follow this official tutorial and create you own API (maybe connect to the database you created in the previous lesson).

Background Services

The third thing I suggest learning is background services. This is usually where data is being transformed. This is the things that users do not see but are usually doing the most heavy-lifting. Think of it like the algorithm that YouTube run to suggest you videos or the engine that Google used to determine what ad you see. This is the place where data is being manipulated and transformed.

In modern C# .NET, Worker services is the way to do it. In terms of architectural, it is not that different from ASP.NET Core Web API. Of course, it does not have API endpoint and all the http related stuff. However, it still follow dependency injection and way it is structured is pretty similar. The main difference is how the app is being trigger. APIs are triggered by HTTP requests. Background services are usually trigger on a schedule or by a queue.

Conclusion

Of course, there are a lot more to learn and I am just scratching the surface. However, I hope this gives you a starting point in case you don’t know where to start. Any one of the above topic can be dived deeper and I may write a separate post on every one of the topic in the future.