← Back to context

Comment by throw1234651234

5 years ago

In C# and .NET specifically, we find ourselves having a plethora of services when they are "human-readable" and short.

A service has 3 "helper" services it calls, which may, in turn have helper services, or worse, depend on a shared repo project.

The only solution I have found is to move these helpers into their own project, and mark the helpers as internal. This achieves 2 things:

1. The "sub-services" are not confused as stand-alone and only the "main/parent" service can be called. 2. The "module" can now be deployed independently if micro-services ever become a necessity.

I would like feedback on this approach. I do honestly thing files over 100 lines long are unreadable trash, and we have achieved a lot be re-using modular services.

We are 1.5 years into a project and our code re-use is sky-rocketing, which allows us to keep errors low.

Of course, a lot of dependencies also make testing difficult, but allow easier mocks if there are no globals.

>I would like feedback on this approach. I do honestly thing files over 100 lines long are unreadable trash

Dunno if this is the feedback you are after, but I would try to not be such an absolutist. There is no reason that a great 100 line long file becomes unreadable trash if you add one line.

  • I mean feedback on a way to abstract away helper services. As far as file length, I realize that this is subjective, and the 100 lines number is pulled out of thing air, but extremely long files are generally difficult to read and context gets lost.

    • Putting shared context in another file makes it harder to read though. Files should be big enough to represent some reasonable context, for more complicated things that necessary creates a big shared context you want bigger files and simpler things smaller files.

      A thing that can be perfectly encapsulated in a 1000 line file with a small clean interface is much much better than splitting that up into 20 files 100 lines each calling each other.