u/grim89 - Archived Voat Post in v/programming
u/grim89
  • home
  • search

u/grim89

0 posts · 1 comment · 1 total

Active in: v/programming (1)

  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››
Comment on: WPF C#: Static classes, when to use them?

Static classes are generally considered an anti pattern and have few and very specific uses cases (don't remember them of the top of my head). In your example you don't need a static class so u shouldn't use it. All you need to do is pass the instance of ChannelModel to the classes that use it. So let say your ViewModel.cs need ChannelModel you do something liked this.

 public class ViewModel 
    {
     ChannelModel  _channelModel ;
        public ViewModel (ChannelModel  channelModel)
        {
            _channelModel = channelModel;
        }
     }

You should look into Dependency Injection and Inversion of Control since is pretty much a standard now.

Dependency Injection (DI) vs. Inversion of Control (IOC)

2 20 Jun 2018 23:37 u/grim89 in v/programming
  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››

archive has 9,592 posts and 65,719 comments. source code.