什么是界面膨胀?

发布于 2024-08-14 10:24:00 字数 41 浏览 4 评论 0原文

有人可以向我解释一下 OOP 中的接口膨胀是什么(最好有一个例子)。

Can someone explain to me what interface bloat in OOP is (preferably with an example).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

埋葬我深情 2024-08-21 10:24:00

天哪,

假设您指的是 API 而不是 GUI,对我来说,I/F 膨胀可能会以多种方式发生。

  1. API 只是不断地用新函数进行扩展,而没有任何形式的隔离,因此您最终会得到一个难以使用的整体头文件。
  2. 现有 API 中声明的函数不断将新参数添加到其签名中,因此您必须不断升级,并且现有应用程序不向后兼容。
  3. 现有 API 中的函数不断因非常相似的变体而过载,这可能导致难以选择要使用的相关函数。

为了帮助解决这个问题,您可以:

  1. 将 API 分成一系列标头和库,以便您可以更轻松地控制您实际需要的部分。任何内部依赖项都应该由供应商自动解决,这样用户就不必通过反复试验来找出依赖项,例如,当我只想使用声明的 API 中的函数时,我需要包含头文件 wibble.h在 shozbot.h 头文件中。
  2. 通过在适用的情况下引入重载,使 API 升级向后兼容。但是您应该将重载函数分组到类别中,例如,如果将新的重载函数集添加到现有 API(例如 our_api.h)以使其适应新技术(例如 SOA),那么它们将在自己的头文件中单独提供our_api_soa.h 除了现有的标头 our_api.h 之外。

华泰

G'day,

Assuming you mean API and not GUI, for me I/F bloat can happen in several ways.

  1. An API just keeps getting extended and extended with new functions without any form of segregation so you finish up with a monolithic header file that becomes hard to use.
  2. The functions declared in an existing API keep getting new parameters added to their signatures so you have to keep upgrading and your existing applications are not backwards compatible.
  3. Functions in an existing API keep getting overloaded with very similar variants which can lead to difficulty selecting the relevant function to be used.

To help with this you can:

  1. Separate out the API into a series of headers and libraries so you can more easily control what parts you actually need. Any internal dependencies should be resolved automatically by the vendor so the user doesn't have to find out the dependencies by trial and error, e.g. that I need to include header file wibble.h when I only wanted to use the functions in the API declared in the shozbot.h header file.
  2. Make upgrades to the API backwards compatible by introducing overloading where applicable. But you should group the overloaded functions into categpories, e.g. if new set of overloaded functions are added to an existing API, say our_api.h, to adapt it to a new technology, say SOA, then they are provided separately in their own header file our_api_soa.h in addition to the existing header our_api.h.

HTH

眉目亦如画i 2024-08-21 10:24:00

想象一下 OO 语言,其中所有方法都在 Object 中定义,即使它们仅对某些子类有意义。这将是最极端的例子。

Think of an OO language where all methods are defined in Object, even though they are only meaningful for some subclasses. That would be the most extreme example.

知你几分 2024-08-21 10:24:00

大多数微软产品?

界面膨胀是指屏幕上同时显示太多内容,特别是很少使用或功能混乱的元素。描述界面膨胀的一个更简单的方法可能是查看没有它的东西,尝试 37signals 的 Basecamp。标题中只有几个选项卡和几个链接。

界面膨胀可以通过可折叠窗格(例如使用 JavaScript)或隐藏不常用选项直到需要时的向下钻取菜单来解决。

Most Microsoft products?

Interface bloat is having too much on the screen at once, particularly elements that are little used, or are confusing in their function. Probably an easier way to describe interface bloat is to look at something that does not have it, try Basecamp from 37signals. There are only a few tabs, and a few links in the header.

Interface bloat can be remedied by collapsable panes (using Javascript, for example), or drill-down menus that hide less-often used choices until they are needed.

作业与我同在 2024-08-21 10:24:00

界面膨胀是指逐渐添加元素,将原本简单、优雅的界面变成布满按钮、菜单、选项等的界面,破坏了应用程序原有的凝聚力。我想到的一个例子是 iTunes。在它的早期版本中,它非常简单,但随着时间的推移,添加了很多可能被认为是臃肿的功能(iTunes DJ、Coverflow、Genius)。

Interface bloat is the gradual addition of elements that turn what may been a simple, elegant interface into one littered with buttons, menus, options, etc. all over the place that ruin the original cohesive feel of the application. One example that comes to mind for me is iTunes. In it's early renditions, it was quite simple, but has, over time, added quite a lot of features that might qualify as bloat (iTunes DJ, Coverflow, Genius).

别理我 2024-08-21 10:24:00

界面膨胀有时是由于试图一键点击所有功能而导致的,如这个幽默的示例所示:

工具栏按钮太多

(虽然很有趣,但这个例子对 Firefox 不公平,因为在这个例子中用户添加了所有这些工具栏)

一种称为“渐进式披露”的 UI 设计技术是一种方法以减少界面膨胀。仅将最常用的功能公开为顶级点击。如果您有一些不太常用的功能,但仍然有价值,可以包含在您的应用程序中,请以逻辑方式将它们分组,例如放在下拉菜单或其他导航元素后面。

Interface bloat is sometimes caused by trying to have every feature one click away, as in this humorous example:

Too many toolbar buttons

(Although funny, this example isn't fair to Firefox because in this example the user added all those toolbars)

A UI design technique called "progressive disclosure" is one way to reduce interface bloat. Only expose the most frequently-used features as a top-level click. If you have less-frequently-used features that are still valuable enough to include in your app, group them in a logical way, e.g. behind a dropdown menu or other navigation element.

轮廓§ 2024-08-21 10:24:00

大多数 C++ 程序员都熟悉的接口膨胀的一个极端例子是 std: :basic_string。成员函数的向上翻页和向下翻页只有很小的变化,这些函数中的大多数不必是成员函数,而可以是字符串实用程序库中的自由函数。

An extreme example of interface bloat that most C++ programmers will be familiar with is std::basic_string. Page up and page down of member functions with only small variations, most of these functions wouldn't have had to be member functions but could have been free functions in a string utility library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文