Console application structure

I have written several .Net Console applications over the past 6 months, and we still have many different projects in our organization. I usually stick to the same standard format / structure for my console applications. Unfortunately, many of our console applications do not work.

I studied ways to standardize the structure of these console applications. I would also like to provide the structure of the basic structure of the Console application and provide easy access to standard ways of handling things such as passing arguments, logging, etc.

Can anyone offer some suggestions for resolving these issues? I read this MSDN article on Console Applications on .Net , which offers a design template for console applications. In this example, the template template template is used to handle some of the problems listed above.

The article lists two negatives of using this approach.

  • Completion with twice as many classes
  • Having a lot of simple, similar classes

Can anyone suggest better or more standard ways to handle this? How about incorporating additional negatives into this approach?

+4
source share
2 answers

To answer part of my own question ...

I spent a lot of time looking for a standard way to handle the parsing of arguments passed to my console applications. I specifically looked for something similar to GetOpt for python. With that in mind, the solution I settled on is NDesk.Options . It covers all our needs and seems to handle arguments in a standard way. I thought this could help someone who stumbled upon this question in their quest.

+1
source

I try to keep my console applications as simple as possible and in a different layer so that it is easier to perform unit and receive testing. I also tend to keep my console applications simple / single-tasked, so I often don't have as many possible paths through things like command line arguments. This allows me to simply take the arguments, if any, to analyze them and pass them back to the logic.

0
source

Source: https://habr.com/ru/post/1334702/


All Articles