Hello, I asked this question to multiple people and until now I do not have an answer.
ASP.NET C#
Project tree (files and folders):
> (ROOT)
>
> Class MyAccess (namespace myproject.core)
>
> (Directory John)
------> Class MyJohn (namespace myproject.core.John)
------> Class JohnSecret (namespace myproject.core.John)
------> Class OtherJohnSecret (namespace myproject.core.John)
>
> (Directory Paul)
------> Class MyPaul (namespace myproject.core.Paul)
------> Class PaulSecret (namespace myproject.core.Paul)
How can I use (public, private, protected, internal) ????? to have have this behavior:
- class MyJohn sees and can create objects from all the classes inside John folder (all his secrets)
- class MyPaul have the same behavior but inside Paul folder
- All this secrets CAN NOT be used OUTSIDE this folders.
Examples:
- MyPaul can use all his secrets, and he can communicate with the classes MyAccess and with MyJohn.
- MyPaul, MyJohn, MyAccess will be public or internal
- MyAccess can not use PaulSecret.
Solutions that I do not like:
- BAD Solution 1
Make John secrets as protected and heritage one MyJohn
Example:
> protected JohnSecret
> internal MyJohn:JohnSecret
bad because if i've 100 class secrets I'll need to have something like:
> internal MyJohn:JohnSecret1, JohnSecret2,....,JohnSecret100
- BAD Solution 2
Have classes inside classes:
> internal class MyJohn {
>
> internal string DoSomething(){}
>
> private class JohnSecret{}
> private class JohnSecret2{}
> private class JohnSecret3{}
>
> }
It's not good because, once again, if I've 100 secrets I'll have a HUGE file, I can't split that code in different source code files.
Can anyone give a good solution?
I appreciate :)
Thanks a lot.