我应该编写小型 CGI 脚本还是大型整体脚本?

发布于 2024-09-02 11:17:49 字数 159 浏览 2 评论 0原文

我正在努力创建一个网站来显示有关我的系统的一些信息。这包括一些图表和一些文本信息。现在我正在创建不同的 CGI 脚本并通过创建链接来调用它们。几天前,我的一位朋友告诉我,与其编写不同的 CGI 脚本,不如编写单个 CGI 脚本并创建函数来调用部分代码。我很困惑。

创建网站时您更喜欢什么?

I am working on to create a web site to display some information about my system. This includes some graphs and some text information. For now I am creating different CGI scripts and calling them by creating links. A few days back one of my friends told me that instead of writting different CGI scripts, it's better to write single CGI script and create functions to call the part of code. I am confused.

What do you prefer while creating a web site?

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

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

发布评论

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

评论(2

漫漫岁月 2024-09-09 11:17:49

如果您不自己编写调度代码,编写单个 CGI 程序确实更好(重用共享代码稍微容易一些)。如果您决心走这条路,请使用框架。 CGI-Application 的运行模式概念基本上是你的朋友建议的正式概念,所以这是前进道路的一个不错的选择。

一旦您不再受此系统的限制,请查看 Catalyst

Writing a single CGI program is indeed better (slightly easier to reuse shared code) if you're not writing the dispatch code yourself. If you commit to go this way, use a framework. CGI-Application's concept of runmodes is basically the formalised concept of what your friend suggested, so this is a good choice for an advancing path.

Once you outgrow this system's limitations, have a look at Catalyst.

女皇必胜 2024-09-09 11:17:49

我倾向于编写单独的脚本,通过库共享它们的共性。如果你做的只是显示信息的小事情,我认为学习一个大框架是浪费时间。

但是,如果您要开始与脚本交互、运行查询等,那么框架可能很有吸引力并且值得付出努力。

查看您现在拥有的脚本,看看每个脚本有多少相似之处。如果您在所有这些代码中执行相同的基础设施编码,那么将它们移至单个脚本中可能会受益。如果它们看起来并不相同或做的事情并不相同,那么您可能不会从额外的工作中获得那么多好处。

I tend to write separate scripts that share their commonality through libraries. If you're doing small things that simply show information, I think it's a waste of your time to learn a big framework.

However, if you are going to start interacting with your scripts, running queries, and so on, a framework might be attractive and worth the effort.

Look at the scripts you have now and see how much is similar in each. If you are doing the same infrastructure coding in all of them, you might benefit from moving them into a single script. If they don't really look the same or do the same thing, you're probably not going to get that much benefit in the extra work.

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