我们可以衡量网站的复杂性吗?

发布于 2024-10-20 12:25:32 字数 49 浏览 1 评论 0原文

我熟悉使用圈复杂度来衡量软件。然而,就网站而言,我们是否有一种衡量网站复杂性的指标?

I am familiar with using cyclomatic complexity to measure software. However, in terms of web site, do we have a kind of metrics to measure complexity of website?

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

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

发布评论

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

评论(4

游魂 2024-10-27 12:25:32

如果将显示的 HTML 页面中的 HTML 标记计算为“运算符”,则可以计算每个网页的 Halstead 数。

如果您检查生成网页的源代码,您可以计算这些网页的复杂性度量(Halstead、McCabe、SLOC,...)。为此,您需要可以从网页源计算此类指标的工具。

我们的 SD 源代码搜索引擎 (SCSE) 通常用于跨大型代码库进行搜索(例如,网站代码),即使代码库是混合语言(HTML、PHP、ASP.net...)。作为副作用,SCSE 恰好会计算它可以搜索(已索引)的每个文件的 Halstead、McCabe、SLOC、评论计数和各种其他基本测量值。
这些指标导出为 XML 文件;有关示例,请参阅上面的网络链接。
这将使您能够粗略但立即计算网站复杂性指标。

If you count HTML tags in the displayed HTML pages, as "Operators", you can compute a Halstead number for each web page.

If you inspect the source code that produces the web pages, you can compute complexity measures (Halstead, McCabe, SLOC, ...) of those. To do that, you need tools that can compute such metrics from the web page sources.

Our SD Source Code Search Engine (SCSE) is normally used to search across large code bases (e.g., the web site code) even if the code base is set of mixed languages (HTML, PHP, ASP.net, ...). As a side effect, the SCSE just so happens to compute Halstead, McCabe, SLOC, comment counts, and a variety of other basic measurements, for each file it can search (has indexed).
Those metrics are exported as an XML file; see the web link above for an example.
This would give you a rough but immediate ability to compute web site complexity metrics.

以歌曲疗慰 2024-10-27 12:25:32

虽然这个问题是 6 个月前提出的……

如果您的网站是 100% 静态网站,根本没有 JavaScript,那么它需要由用编程语言编程的后端提供支持。因此,影响后端编程的复杂性指标也会间接影响网站维护的复杂性。

通常,我观察到网页本身的可维护性和质量(或缺乏)与后端编程中通过软件指标表现出的质量(或缺乏)之间的相关性。不要引用我的话,要持保留态度。这纯粹是我在工作中所做的观察。

如果您的网站(无论是否包含动态内容)也包含 JavaScript,那么这也是展示可衡量属性的源代码在软件复杂性指标方面。由于 JavaScript 通常用于呈现 HTML 内容,因此有可能(但不是必然),恶劣的、难以维护的 JavaScript 也会呈现同样恶劣的、难以维护的 HTML(或者嵌入恶劣的、难以维护的标记中) .)

对于完全静态的网站,您仍然可以设计某种类型的指标,尽管我不知道有任何已发布的指标。

无论如何,一个好的网站应该有统一的链接。

它应该提供统一的导航。

另外,html 页面不应该被复制或重复,很少甚至没有死链接。

站点内的链接应该是相对的(无论是相对于其当前位置还是相对于逻辑根“/”),而不是绝对的。也就是说,不要对域名进行硬编码。

URI 命名模式应该是统一的(最好是小写)。URL 不区分大小写,因此混合使用两种大小写的链接绝对没有意义。此外,链接可能会映射到实际文件系统中可能区分大小写的内容,这会导致下一个。

表示短语的 URI 应该是统一的(使用 - 或 _ 来分隔单词,但不能同时使用两者,当然也不能有空格)。避免驼峰式大小写(请参阅之前对小写字母的评论。)

我不知道有任何已发布或提倡的类似网站的软件指标,但我想如果有的话,他们可能会尝试衡量我提到的一些属性多于。

Though the question was asked 6 moths ago...

If your website is 100% static site with no javascript at all, then it needs to be powered by a back-end programmed in a programming language. So indirectly, the complexity measures that afflict the back-end programming will also affect the complexity of maintaining the site.

Typicall, I've observed a corellation between the maintainability and quality (or lack thereof) of the web pages themselves to the quality (or lack thereof) exhibited, through software metrics, in the back-end programming. Don't quote me on that, and take it with a grain of salt. It is purely an observation I've made in the gigs I've worked on.

If your site - dynamic content or not - also has JavaScript in it, then this is also source code that demonstrate measurable attributes in terms of software complexity metrics. And since JavaScript is typically used for rendering HTML content, it stands as a possibility (but not as a certainty) that attrocious, hard to maintain JavaScript will render similarly attrocious, hard to maintain HTML (or be embedded in attrocious, hard to maintain markup.)

For a completely static site, you could still devise some type of metrics, though I'm not aware of any that are publisized.

Regarless, a good web site should have uniform linking.

It should provide uniform navigation.

Also, html pages shouldn't be replicated or duplicated, little to no dead links.

Links within the site should be relative (either to their current location or to the logical root '/') and not absolute. That is, don't hard-code the domain name.

URI naming patterns should be uniform (preferably lower case.) URLs are case-insensitive, so it makes absolutely no sense to have links that mix both cases. Additionally, links might be mapping to stuff in actual filesystems that might be case-sensitive, which leads to the next.

URIs that represent phrases should be uniform (either use - or _ to separate words, but not both, and certainly no spaces). Avoid camel case (see previous comment on lower casing.)

I'm not aware of any published or advocated software-like metrics for web sites, but I would imagine that if there are, they might try to measure some of the attributes I mentioned above.

仙女山的月亮 2024-10-27 12:25:32

我想您可以将“中心分数”视为一个复杂性指标,因为它考虑了引用了多少外部站点。 Jon Kleinberg 的“超链接环境中的权威来源”对此进行了讨论。

I suppose you could consider "hub scores" to be a complexity metric since it considers how many external sites are referenced. "Authoritative sources in a hyperlinked environment" by Jon Kleinberg discusses it.

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