Design Principles [closed]

2019-01-30 07:07发布

What principles do you generally follow when doing class design?

12条回答
贼婆χ
2楼-- · 2019-01-30 07:45

SOLID principles and Liskov's pattern, along with Single responsibility pattern.

查看更多
萌系小妹纸
3楼-- · 2019-01-30 07:46

As mentioned above, some of the fundamental Object Oriented Design principles are OCP, LSP, DIP and ISP.

An excellent overview of these by Robert C. Martin (of Object Mentor) is available here: OOD Principles and Patterns

查看更多
Emotional °昔
4楼-- · 2019-01-30 07:49

The S.O.L.I.D. principles.
Or at least I try not to steer away too much from them.

查看更多
做自己的国王
5楼-- · 2019-01-30 07:49

I usually try to fit the class into one of the oo design patterns.

查看更多
【Aperson】
6楼-- · 2019-01-30 07:56

The "Resource Acquisition Is Initialization" paradigm is handy, particularly when writing in C++ and dealing with operating system resources (file handles, ports, etc.).

A key benefit of this approach is that an object, once created, is "complete" - there is no need for two-phase initialization and no possibility of partially-initialized objects.

查看更多
太酷不给撩
7楼-- · 2019-01-30 07:56

loosely coupled, highly cohesive.

Composition over inheritance.

查看更多
登录 后发表回答