Monday, April 18, 2022

Throwing stones from a potentially glass house - proper citations and clarity in code snippets and articles

implicit usings in C# is a terrible idea. It is hard enough to get people writing articles or posting sample code to include the damn using clauses, let alone references or assembly version numbers. lets make it so people are used to looking at code without any and requiring every onlooker to go find the source repo to really be able to replicate the code. VB had it for more than 10 years and there were announcements of feature parity around 10 years ago, why does C# suddenly think it is a good idea now?

I'm repeatedly running into code examples with many major problems for reproduction:
  • the usings/opens are excluded from snippets (and often from the entire article/post/page)
  • the packages needed aren't mentioned
  • the repo doesn't exist or isn't linked
  • the references don't specify a version
  • the article/snippet has no date/time visibility
  • implicit usings are turned on (making even a full repo far less clear unless you download it)
  • there is some implicit context that makes it unclear the true target

    • turning in implicit usings is a special kind of evil for example/sample repos.
    • is this how you write a framework service or a net core service?
    • is this how you use something magical built-in to hangfire to install your hangire app as a service, or is there a dependency some hangfire package depends on that is doing it?

I'm having a really tough time finding an updated article on setting up an app that goes 1 of 4 ways:

  • Run as a console spitting out simple information on the command line arguments
  • Run as a console executing a specific potentially long running job
  • Run as a console app starting up a web server with a dashboard using Hangfire Asp.Net Core
  • Run as a console app to install some part of itself as a windows service (including the Hangfire Asp.Net Core dashboard).
I understand that asking for a simple article or post, up to date, that shows how to do 4 things at once is a lot to ask for. However, the above major problems for reproducing little parts individually combine to form serious frustration.

No comments:

Post a Comment