我正在处理什么设计理念?

发布于 2025-01-11 08:32:43 字数 562 浏览 2 评论 0原文

我有两个数据对象 - customersjobs。工作记录是根据客户记录的某些字段创建的。为每次对客户的服务访问创建一个工作记录,每周重复发生一次。

因此,我正在考虑创建作业记录的最佳方式,我可以:

  1. 使用服务器功能在后端创建作业记录。并分批创建它们——比如每季度——这样我就可以获得未来 12 周的工作记录。这样我就可以在 jobs 表中查询表示层中的任何操作。

  2. 使用customers表上的字段在表示层中创建作业,仅在与表示层进行一些交互后创建job记录。 这样,就业机会始终是根据更新的数据创建的。

我认为我应该采用第二种方法,但在处理数据和表示层时,我似乎可能犯了设计违规。

是否有一些概念可以概括此类问题?

--

第一种方法的缺点:服务器功能必须在客户记录发生任何更改后运行,以便更新作业。我想我可以安排该函数每晚运行(cron 作业),这样我每天都会得到更新的记录。但我认为应该有一个更简单的方法。

I have two data objects- customers and jobs. Job records are created based on certain fields of the customer record. A job record is created for each service visit to the customer, which happens on a recurring weekly basis.

So I'm considering the best way to create job records, I can either:

  1. Use a server function to create job records on the backend. And create them in batches- say, quarterly- so I'd have job records for 12 weeks ahead. This way I can just query the jobs table for any operations in the presentation layer.

  2. Use fields on the customers table to create jobs in the presentation layer, creating the job record only after some interaction with the presentation layer.
    This way, jobs are always created from updated data.

I think I should go with the second approach but it seems like I might be committing a design transgression when it comes to handling data and presentation layers.

Is there some concept that encapsulates this type of problem?

--

Drawback to first approach: The server function would have to run after any changes to the customer record so that jobs are updated. I suppose I could schedule the function to run every night (cron job) so I'm getting updated records every day. But I think there should be a simpler way.

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

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

发布评论

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

评论(1

欢你一世 2025-01-18 08:32:43

这是一个意见问题,我怀疑它可能会被删除。

但是,我总是会选择#2。对于#1,您将创建大量空数据记录,这些记录没有任何价值,并且可能会也可能不会被使用。它还使您有机会在保存作业之前向用户提供数据以进行验证。

This is kind of an opinion question, and I suspect it might get removed.

but, I would go with #2, always. with #1 you're creating a lot of empty data records that hold no value and may or may not get used. It also gives you an opportunity to present the data to the user for verification before saving the job.

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