问题标签 [information-hiding]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
entity-framework - Hiding certain properties of EF generated entity classes
I'm using the Database-first EF model, and use breezeJs for the client-side data management.
Let's say I have a table [User] in my database, with a field called 'AccessCode'. I want to expose the User object through breeze to the clientside, but do not want to expose the AccessCode property. As far as I know, I have the following options:
- Make the AccessCode property on the EF generated entity class Internal.
- Create a DTO and omnit the AccessCode property. DTO is exposed to the client side.
2nd option doesn't work well with breeze, since we should be able to add/modify the User object directly from clientside.
Is there anything wrong with the first option? My concern is that if we make the property internal, the change will be wiped the next time the model is updated. I know if we want to enforce validations, we can use partial classes with the entity class, but we can't do that here.
What would be the best way to achieve the data-hiding here?
html - 手机上的隐藏按钮
这是我的网站: http ://site9171756.91.webydo.com/?v=1
有没有办法可以隐藏手机上的按钮?我想为移动设备编写不同的按钮。这是我对按钮的编码。
HTML
CSS:
问候 =)
information-hiding - 在我的网站上隐藏我的应用
现在我的网站上有一个应用程序,用户可以从我的网站轻松下载,有没有办法隐藏或很难找到我的应用程序,所以人们不能只添加 /files/App.exe进入我的域的末尾以获取我的应用程序?你有什么建议吗?
c - Ansi-C C99 接口与结构
我主要使用 National Instruments 的 Labwindows CVI 作为编译器。
我必须为设备创建一个接口,并开始为所有不同的寄存器寻找结构。
然后我在调用函数中填充结构,然后将结构传递到一个函数中,在该函数中我执行所有位移,将地址等附加到消息上,并通过 comm 接口将其发送出去。
这可以改进吗?我应该隐藏更多信息并让函数填充结构吗?我一直在做很多阅读,这肯定可以使用一些改进。
c++ - 通过前向声明隐藏实现
我有一个类,我们称它为 Product,我想对用户完全隐藏它的实现。尽管如此,我希望用户收集产品,将它们四处传递,一般来说,在不知道里面有什么的情况下决定如何处理它们。
我想到的第一个想法是简单地创建一个 ProductFactory 类并在 ProductFactory.h 头文件中前向声明 Product 类。
Product 类的对象将由 makeProduct 方法创建,该方法将返回指向 Product 类的共享指针。然后,用户将无法看到里面有什么,但它可以例如将其发送到 Service 类,该类在其实现中将包括 Product 的完整定义,以便它可以访问其内容。
您认为这是一个好主意还是感觉更像是一种解决方法?
我也在考虑使用 pimpl idiom,以防我需要一些用户可以访问的顶级功能,例如 operator== 以便用户可以检查产品是否相同。
请注意,抽象基类不是一个选项,因为实际上并没有一个接口可以兼具对用户的限制和对服务类的充分限制。
oop - 信息隐藏和封装是否相互独立?
我知道信息隐藏和封装不一定是同一回事,但根据定义,它们似乎是同义词。这让我想知道一个人是否可以在没有另一个人的情况下存在。
swift - Swift: access level between `private` and `internal`?
In my Swift code, I often use the private modifier to limit the visibility of helper classes. For example, in one file, I'll have a GridController
and a GridControllerModel
.
The GridController
(the UI) should be accessible to the rest of the application, but the model class is wholly internal and should never be accessed by the rest of the application.
I can address this in Swift by making both classes private
and keeping them in the same file. But this gets unwieldy as classes get bigger. What I'd like to do is keep each class in a separate file (for programming convenience), but prevent access to the model class anything but GridController
(for information hiding purposes).
Is there any way to do this in Swift?
ruby - 替换代码片段中的类和变量名称
我想在 CV 中插入我的代码的一些要点。为了不知道这段代码是关于什么的,我想用一些随机字符串自动替换所有类、方法和变量名称(使用一些脚本或在线创建者?),这样我就可以显示“我是如何编写的”,但我没有'不显示真正的功能。
我想改成:
或者也许有人知道更好的方式来向其他人展示“我的代码看起来如何,但没有向他展示功能”?
提前致谢
javascript - 使用 Angular 时隐藏 API 密钥(可能在环境变量中?)
我正在运行一个带有 Node/Express 后端的小型 Angular 应用程序。
在我的一个 Angular 工厂(即客户端)中,我向 Github 发出 $http 请求以返回用户信息。但是,执行此操作需要 Github 生成的密钥(应保密)。
我知道我不能在客户端使用 process.env.XYZ。我想知道如何才能将此 api 密钥保密?我是否必须在后端提出请求?如果是这样,我如何将返回的 Github 数据传输到前端?
抱歉,如果这看起来很简单,但我是一个相对新手,所以任何带有代码示例的明确回复将不胜感激。谢谢
java - java - 为什么在java中的枚举中不允许抽象私有方法?
在枚举中编写私有抽象方法不应该是完全合法的吗?有理由禁止我看不到的吗?
下面是一个无法编译的玩具代码示例;假设我不想提交任何 api,除了单例是否为多个。
请注意,这可以在没有抽象方法的情况下实现,但这只是一个示例。我在问是否有禁止它的一般理由。
编辑1:这不是问为什么通常禁止私有抽象方法。我在问为什么在枚举中使用它是非法的,并提供了一个这样的使用是有意义的例子。这不是重复的。我在 Stackoverflow 中找不到答案。一般情况的答案在这里不适用。