gpt4 book ai didi

c# - 内部应用程序——为什么不公开所有内容?

转载 作者:太空狗 更新时间:2023-10-29 22:20:00 27 4
gpt4 key购买 nike

为什么我不应该在我们的 Intranet 报告应用程序中将所有内容都标记为公开?

公司外部的任何人都无法访问此代码 - 我们有大约 20 个项目 - 大多数都是小而具体的。

我们真的应该将事物标记为 public 以外的任何东西吗?

我对此有自己的想法,但我想忽略它,因为我希望它不带偏见。

(我把标题稍微搞了一下)

最佳答案

查找封装和/或 "Information Hiding" :

In object-oriented programming, information hiding (by way of nesting of types) reduces software development risk by shifting the code's dependency on an uncertain implementation (design decision) onto a well-defined interface. Clients of the interface perform operations purely through it so if the implementation changes, the clients do not have to change.

如果您将每个类的成员标记为公共(public)的,那么您将成为维护的噩梦, future 的开发人员(包括您自己)将不确定该类的哪些部分是永久性的(契约),哪些是纯粹的实现细节。

关于c# - 内部应用程序——为什么不公开所有内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9115266/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com