Directory structure with commands.

I have winforms projects and we are using a command template. We are trying to clean up our directory structure and make it consistent.

We are trying to decide whether to have a command root folder or not. What do you think is best for the directory structure?


Project --Commands
---- AddCommand
---- SubtractCommand
---- InsertCommand
---- DeleteCommand

or


Project --Calculation
---- AddCommand
---- SubtractCommand
--Database
---- InsertCommand
---- DeleteCommand

+1


source to share


2 answers


It seems like a common question is whether you want to categorize actions / verbs (eg Commands folder) or target / nouns (folders for database, calculations, etc.). Whichever route you take, you can try to be consistent (use the same approach with views and widgets as with commands, etc.).

Several considerations I can think of:



  • Are there other things that also end up in the Project / Database / etc folders or just commands? If only commands, it might simplify things to only have a Commands folder, so you don't have to pick a good top-level folder for every new command. For example, where do you put a command that performs calculations on database values?

  • If you have a large number of commands (where "big" is somewhat vaguely defined), having an extra directory layer can be nice.

In my experience, the question of how to organize your code is always annoying. If all else fails, you should simply select an option and go with it, and rearrange later if you decide you made the wrong choice.

+2


source


I personally like the second option, but I think you could also do something like this:

Project
-Commands
--Calculation
----AddCommand
----SubtractCommand
--Database
----InsertCommand
----DeleteCommand

      



Just my 2 cents

0


source







All Articles