C
C#6mo ago
Trou

Looking for Boilerplate and Learning Resources

Hello, I am a NodeJS developer. I have mostly worked with frameworks like NestJS and have had brief experience with Spring Boot. Now, I want to learn the .NET side, but unlike the others, there seems to be no similar framework. Because of this, when I examined projects, I saw that very different file structures are used even if the same architecture is used. Can you guide me to some boilerplate examples and educational content that I can use during my learning process?
21 Replies
Pobiega
Pobiega6mo ago
There absolutely is a "framework" - its called ASP.NET Core you can easily get started simply by using the dotnet CLI to create your project. dotnet new webapi would create an ASP.NET Core web api project, for example
cap5lut
cap5lut6mo ago
here is also an overview which will guide you to to further resources on asp.net core: https://learn.microsoft.com/en-us/aspnet/core/introduction-to-aspnet-core?view=aspnetcore-8.0
Trou
TrouOP6mo ago
This is not exactly what I meant. As far as I understand, apart from some simple tasks (Endpoint Mapping, Built-In IOC), it doesn't do much. The remaining part is more flexible, whereas in others, many things are already written for us, so we don't implement them. This brings a certain standard to the projects, and you can't easily deviate from it (unless you want to).
Pobiega
Pobiega6mo ago
Right. I see what you mean. Yeah, thats sort of the beauty of asp if you ask me. It does the HTTP(s) stuff really well and lets you do the rest however you want, with usually very easy integration as for examples, there are as many ways to do this as there are developers - but I personally like something called vertical slice architecture. $vsa
Pobiega
Pobiega6mo ago
our very own viceroy has a template he maintains at https://github.com/viceroypenguin/VsaTemplate that you can look at, but its very opinionated he uses his own libraries for handling endpoints and command pattern (Immediate.Apis, Immediate.Handlers), and most controversial - he doesnt use EF Core to talk to the database, which is the defacto standard way to do it I don't have any "more standard" vsa templates to link I'm afraid, but https://fast-endpoints.com/ is what I normally use and their quickstart should show you what it can do again, I stronly recommend VSA but there is ofc alternatives, "clean architecture" being a fairly common one. I don't like it myself, but many do. A commonly linked to resource for that would be... https://github.com/ardalis/CleanArchitecture I suggest reading $whynotca thou
MODiX
MODiX6mo ago
CA is not necessarily difficult to understand conceptually, but they're difficult to build and difficult to maintain. When you build a real project, you will quickly (as often evidenced on this server) run into questions like "Is this an infrastructure object or a domain object?" or "Should I implement this contract in the infrastructure or the application?". Questions that a) take your time to ponder and ultimately answer, and b) distract you from doing your actual work. It also adds unnecessary abstractions, by forcing you to use layers: both unnecessary layers and unnecessary decoupling between layers. For example, CA would generally argue that you should abstract the database into repositories and services should depend on an interface for the repository. However, modern ORMs like EFC already implement the repository pattern, by abstracting the implementation of a query via LINQ. Furthermore, in most applications, there's only one implementation of IXxxRepository - so why create the interface abstraction? Instead, it's generally better to get rid of nearly all interfaces, keeping only ones that truly have more than one implementation; simplifying maintenance because any change to an api only needs to be done in one class instead of both class and interface. Smush all of the code down into a single Web project, or possibly two: Web and Services projects; removing any questions about "which project does this class go into?". Organize your code well in the Web project, with all of the User-related services/controllers/models/etc under /Features/Users/Xxx; all of the Order-related services/controllers/models/etc under /Features/Orders/Xxx; etc. Then it will be easy to find and maintain all of the code related to such and such feature. Any Infrastructure code (like emails, behaviors, startup code, etc.) can go under /Infrastructure/Xxx, and any non-infrastructure code that's not related to a feature can go under /Features/Shared.
Trou
TrouOP6mo ago
Thank you for your responses. I will review VSA, but I don't think to use Clean/Union architecture (or microservices) because I believe it complicates the development process and would be an unnecessary burden for projects with above-average requests. I think I will review different repositories based on a layered architecture template and come up with something.
Pobiega
Pobiega6mo ago
in terms of performance, architecture doesnt hugely affect it other than you should be using minimal api/fastendpoints/immediate.apis or similar and not controllers
Trou
TrouOP6mo ago
If I'm not getting millions of requests for a sec, performance is not and should not be a metric to consider
Pobiega
Pobiega6mo ago
would be an unnecessary burden for projects with above-average requests.
you just said it mattered. but yeah, I agree, dont use CA, its overly complicated, and performance is rarely bound by the HTTP layer itself
Trou
TrouOP6mo ago
"because I believe it complicates the development process and would be an unnecessary burden for projects with above-average requests." I was referring to the development workload and cost when I mentioned the burden here, I didn't mean code performance
Pobiega
Pobiega6mo ago
oh you mean "requests" as in change/feature requests, not actual http requests? probably worth specifying that, given the context I think most would assume http requests/load but yeah, then VSA for sure
Trou
TrouOP6mo ago
nah, http requests but Clean Architecture need to much effort instead of NLayered and because of this it can be unnecessary for small project and for learning curve. Thanks again, .Net ecosystem seemed a bit strange and different to me, we have to implement many things such as core things Exceptions, Cache, Logging etc. In other frameworks these things comes by built in feature as provider just plug and use It seems even important mechanisms like Authentication were included in .Net Core relatively late.
Pobiega
Pobiega6mo ago
uh not sure what you are on about exceptions, cache, logging etc are all in asp.net core and authentication has been there for ages. what they recently did was simplify using EF Core + mvc + identity
Trou
TrouOP6mo ago
im not talking about try catch block is there an wrapper for Exception Filter or Global Handler above if yes its my bad Please don't misunderstand, I'm not comparing technologies as good or bad, I'm just leaving this example:
Trou
TrouOP6mo ago
Documentation | NestJS - A progressive Node.js framework
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
Trou
TrouOP6mo ago
Medium
Spring Boot Global Exception Handler
Merhaba bu yazıda bir Spring Boot projesinde kullanmak üzere bir Hata Yönetimi(Exception Handling) mekanizması oluşturacağız. Bir projede…
Trou
TrouOP6mo ago
For caching, @Cacheable annotations is actually sufficient; this is what I meant to convey https://docs.spring.io/spring-boot/reference/io/caching.html
Pobiega
Pobiega6mo ago
asp.net has all of the above. Sure, caching is a little more involved than just a single attribute, but that makes sense to me - you can/need to specify things such as eviction policy, TTL, cache provider etc anyways
Want results from more Discord servers?
Add your server