This might sound weird and probably is, but I am struggling to find a good place where to place what I will just call "Doers" for lack of a better name.

Basically, my project currently has these Namespaces (Folders in src)

/Error (Custom exception classes)
/Facade (Facades for legacy operations of things not yet converted)
/Model (Entity classes and helpers for ORM mapping)
/Repository (Repository classes that wrap ORM)
/Utility (Anti-pattern probably, things like extension methods, translation,...)

Now, I need to implement a class that will receive a file (CSV) and import that file into the database, following an algorithm to decide what to do with each entry.

To me, this is a class that actively does something (in contrast to e.g. the entity classes).

Because it operates on the database, one might be tempted to put it into the Repository space, but that doesn't really fit, because it won't be a repository class - it will just import things following a specific logic.

Currently, the classes that actively do stuff are all legacy facades, so they already have a place in the Facade namespace. But what about new things? Where to put them?

What would I describe this class as? It is a ThingImporter, but what is its "parent"? It feels dirty to put in the root namespace...


You could go for 'Workers'? But what I find worrying is that your name spaces are grouping by 'type' rather than responsibility.

For example, I would put the errors with the component that throws them, not all together in one name space.

  • I am absolutely open to change the structure. Grouping by responsibility - would that mean to e.g. put anything to do with a certain Entity in a namespace? What if an exception can be thrown by two workers? Where should that go? – Florian Peschka Aug 24 '16 at 7:56
  • 1
    it would depend on the specifics, but say both workers read csv, one outputs to a db and one to a different file format. both throw csv exceptions. In That case you could use the same csv reading component in both workers and have the csv exception class in that component – Ewan Aug 24 '16 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.