Factory pattern in C#: How to ensure an object instance can only be created by a factory class?

后端 未结 17 1746
小鲜肉
小鲜肉 2020-11-29 16:51

Recently I\'ve been thinking about securing some of my code. I\'m curious how one could make sure an object can never be created directly, but only via some method of a fact

17条回答
  •  盖世英雄少女心
    2020-11-29 17:05

    I don't understand why you want to separate the "business logic" from the "business object". This sounds like a distortion of object orientation, and you'll end up tying yourself in knots by taking that approach.

提交回复
热议问题