samedi 26 octobre 2019

How to follow SOLID principles and not break any rules with my application?

So let me first explain how my application is set out, I have many projects that all do their own thing, if a project needs a file from another project then it references that project, but the key thing is you can't reference projects both ways.

Project.Interfaces (Hold interfaces, referenced in most projects)
Project.Something
Project.SomethingElse
Project.Shared (Usually just utilities and helpers)

Now, I've reached a stage in my application where I need to use an enum. I thought cool lets host the enum in Project.SomethingElse where it's most related to - I need my enum in .Interfaces and .SomethingElse and I can't reference these two together. So what am I supposed to do?

I did try and host it in Project.Shared which made sense when I tried it, but .Shared needs .Interfaces - reason being for this is so I'm not referencing concrete types in .Shared.

I know a big question here is going to by why don't I reference concrete types anywhere and that's because I want to make my application as abstract as possible.

My solution was to make another project called Project.Enums and just hold all enums in there and this worked out okay because enums didn't need anything other than themselves.

But I've also been advised to let the .Interfaces project own the enum, but isn't this breaking some sort of SRP rule? I'm just looking for some guidance on what is the correct way to handle this without breaking any rules. Am I overthinking this?

Aucun commentaire:

Enregistrer un commentaire