Open ascott18 opened 4 years ago
cc @MarkMichaelis
Great ideas.
The only one I would take any issue with is the DI 'whenever possible.'
My main issue with DI is that if it isn't used in a way that is commonly accepted, it is very confusing to understand what object I am getting and where it is coming from. In ASP.NET Core, this is a great thing since it is baked in and pretty much everyone knows where it gets set up. In other cases, I have spent hours looking around to find where some custom DI container was set up.
I would add an additional item in Hangfire that if background tasks is the main thing the app does, maybe it shouldn't be a web site. Unfortunately, there are not super good multi-cloud options for this outside web.
BTW: Seems like we should build this into some sort of MD files.
@GrantErickson we already have the web page for this stuff. Just a matter of finalizing what we want it to be, then do a PR )
Initial start of this covered by #107 , will circle back on individual proposals from here after that is done.
Call for volunteers posted to Yammer.
Regarding Project Documentation 1.i.a, in the specific scenario where there are recommended VSCode extensions, setting up workspace recommended extensions is a good means of augmenting this README.
I have spent hours looking around to find where some custom DI container was set up.
At least on the .NET side, we could create an IntelliTect.Debugging
(or whatever) package that may be installed into any webserver and expose any number of debug endpoints in development environments.
One such endpoint would allow a developer to enter a symbol name and see various details via reflection:
1) Installation path of the injected symbol 2) Serialized value in the current context 3) etc.
The recommendation in `Web Application Architecture" to use Hangfire feels like it might only cater to a subset of use-cases and a bit too strong/specific a recommendation for a general set of Architecture Guidelines. I would generally recommend not maintaining a job queue stack at all if it can be avoided, at least in the types of projects we work on.
@SteveByerly: Seems that in this case there is a caveat about "When an application needs to run long-running or recurring background jobs." I agree that these are undesirable, and we should do everything in 'real-time' if possible. I think the idea here is that if we need to run 'batch' jobs and if we are using ASP.NET, we should be using Hangfire as the default and not another 3rd party or homegrown method. One of my driving factors behind architecture choices for us is changing. We are encountering more customers who are looking to us for ongoing technical support (as opposed to where they support the product with existing staff). Having a standard set of tools to solve common problems makes it much easier to for one of our people who might not be familiar with a project to jump in and assist a customer.
@GrantErickson @SteveByerly Yeah, the point about Hangfire here is to start with the smallest, simplest solution for the problem at hand. Obviously if you don't have a need for scheduled background jobs or on-demand background jobs, don't use it. Also don't use it if you're not writing a .NET application.
It should be used in preference to a tangled web of Azure Queues/Azure Functions (or other cloud-native solution) because it doesn't vendor-lock you to a cloud provider and is far, far simpler to maintain and develop. It also should be used in preference to a home-grown, probably-implemented-wrong new Thread()
that you initialize on application start, or some other similarly janky solution.
Hangfire is a solution that itself is completely self-contained, and it also stays contained within the application in which it is implemented with no external dependencies other than the database that your application already has.
Of the dozen(s?) of .NET web projects I've worked on, I could count on one hand the number that have NOT had a need for some kind of background job processing. I could go into more detail here, but this is a public forum.
Some proposals for guidelines based on things I've seen recently, and over the years:
Project documentation:
All projects should have a README file in their repository root that includes the following information, or contains links or instructions on where to find the following information:
dotnet
tooling, butnpm
packages are not.All possible sources of application configuration that is environment-dependent MUST be clearly enumerated in a README file in the root of the project's repository, or must otherwise be linked to from such a README file. This file MUST be updated when changes are made to how an application is configured.
General Architecture:
DbContext
instances, because manual instantiation implies that theDbContextOptions<>
are also being manually created, are hardcoded into theDbContext
constructor, or are being stored as a global singleton.DbContext
instances during setup when the instance is being configured with some an in-memory provider.[FromServices]
, etc.)Web Application Architecture:
Task.Run
, or utilizing a cloud-native solution.