architecture - Architectural considerations in designing console applications? -


I have recently programmed a console application and I have done it in many aspects, especially C #, its pure o pattern Gave. The questions I have raised include some of them, including ways to pass options, how to return between the problems in the entry point category, many, many others.

My question is this: Do any of you apply in the console oo patterns so I can learn from them? Good implementation code especially are welcome.

Edit: I'm not following the command line API, but after good design principles and, in particular, I can learn from good implementation.

Edit 2: The app has simple user interaction, but this is not a complete CLI / REPL sort. Think of it as a tax command, more or less interesting thing is that even if good theory is running (no different than X, use pattern Y, you should know oo principles ... [Your computer science professor will be very proud!]), There is no real code. See these concepts in action. Then, for a good command line application in a pure o o pattern (code!) Where Should look?

It seems as if you are creating an interface that many different with each orientation One of the functions does. I'm not sure that you mention a "command line" application (which one works out, then exits) or a CLI application (which displays a prompt and repeatedly answers for user input) Used to be. Generally, the former will be very simple to build compared to the latter; I think that it only makes sense to use a CLI, if your application requires some compulsory position which develops over many orders, if you are facing something like this in the Alfazo is right - you should learn about REPL and make a good copy.

In any case, the operation that is carried out will depend on the arguments passed on the command - line, so I will churn about that part ...

This application Think about the specific "command" objects as a set, to make an application for each type of operation, the entry point should be a command line expression object in such a way that the appropriate command object is requested The Ejta.

To be modular, the sender must be configured with a brief mapping (e.g., a Hashtable) to connect each command token (usually the first word of the command-line string) with the command object For those who handle it, the Dispatcher can handle the general option-parsing, perhaps using some closed-the-shelf "getopts" library to lift heavy loads.

To start simple, each command object can implement a consistent interface for it; There may be something like this:

  Public invalid executed (list & lt; string & gt; args)  

In this way, the entry-point sender The bus command is being demanded, and executes it .

About handling errors: execute () Method errors can throw an exception to the communication ... the exception may have been caught and processed by the sender, Or just logged on screen. Alternatively, unsuccessful orders can implement some shared code usage function to combine an error message with normal sharing. I do not think "entry point" should be understood as important as you suggest; If you need strong error-settling (for example, to logging or alerting capabilities), it seems that it is in a different component that can be provided to the command object. Generally speaking, a command line app is no different than any other app answering the user's input - you will need a dispatcher to parse and route input to perform a supported operation, and handler (aka " Controller "). If you need other services (logging, alerts, database connectivity, etc.), you would love to create separate components to isolate this argument and display it with a clean interface.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -