Last active
January 13, 2026 22:04
-
-
Save sunmeat/a530877d9a25cbb4b9ab576ce0ddb3ec to your computer and use it in GitHub Desktop.
DIP bad example C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Worker | |
| { | |
| // ... | |
| public void DoWork() | |
| { | |
| Console.WriteLine("Працівник працює..."); | |
| } | |
| } | |
| class Manager | |
| { | |
| private Worker worker; | |
| public Manager() | |
| { | |
| worker = new Worker(); // висока зв'язаність (прив'язка до типу реалізації) | |
| } | |
| public void DoSomething() | |
| { | |
| worker.DoWork(); | |
| } | |
| } | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| Console.OutputEncoding = System.Text.Encoding.UTF8; | |
| var manager = new Manager(); | |
| manager.DoSomething(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment