Tuesday, October 12, 2021

GitHub template project for .Net console Menu driven applications having DI and Logging capabilities

This is simple introduction to one of the new open source projects that I started in GitHub. It is not solving any planet scale problems but a simple problem of setting up a menu driven console application. Currently  every time when I start a PoC (Proof of Concept) application I start as blank console application then add the required infrastructure libraries. Those libraries include the logging, menu etc...Also a dependency injection framework. 

It is a GitHub project template and below is the link that has the DI, Logging and Menu (using EasyConsoleStd). Let me know if there are better starter templates to use.
 
Note that this is just a GitHub project template, not released as dotnet command extension. In other words if this is made that way, anyone can easily use with below command 

dotnet new <my template name>
Converting this as dotnet template is in consideration. But mean time if I get a better template why should I spend time?

Why Dependency Injection?

All the time, we start PoC as temporary arrangement to demo technology capabilities or feasibility of a solution. If its for a small project and deployed in to predefined environments, its fine. But think about the application needs to be installed in various departments or business units of a big enterprise with different environment configurations. Then our application may fail and we need to prove that the environment doesn't have the capabilities by using this PoC application. In such scenarios The PoC lives for months and on most of the environment failure, we may discover one more additional scenarios to be tested that cause changes to the PoC. As we all know the DI frameworks helps to do changes easily.

One more scenario depends on the dev team. We (from architecture or research or sales team) create a PoC and hand over to the dev team on the expectation that they know that the code we handed over is PoC grade. Never copy paste or extend that PoC to production. But sometimes it doesn't happen that way. So better do the PoC with DI so that even if dev team extend it, there will be minimum quality.

Why develop PoC as Menu driven application ? Don't you know about test projects

The scenario mentioned above about the variety of environments is the answer. If we want to run only on dev machine, its fine to do as test project having each scenario as test method. But its difficult to run a test project in production environment to debug something in isolation. 
eg: We are able to enqueue messages to ServiceBus in dev environment but in production it failed because some device in production network doesn't like AMQP traffic.

Another psychological reason is that demoing a console app with menu options gives an impression that something complex is going on. If we run tests from Visual Studio the same impact will not be there.

Why menu in the console app? Can't you use the command line switches?

Same psychological reason. The reason for PoC is that something that we are proving that we don't know. It may require days to get a PoC working. After this much time, if we just run a command line application with different arguments in a demo, there is a high chance that the stakeholders / managers think the developer is lazy. Mean time if we show a menu in the PoC with 10-15 options, it give a different impression. Coding efforts is more or less same.

I feels like I am becoming more of a sales demo guy. So stopping here. Let me know your comments.

No comments: