TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How to approach this problem functionally

1 点作者 sigmaml超过 4 年前
Here is a logic that I have to implement in an in-house application that manages attendance, leaves, etc. The following is one of the workflows in leave application processing.<p><pre><code> if (attendance has been marked for any session of the leave duration) { perform exception processing &#x2F;&#x2F; excluded for simplicity return } if (applied leave duration overlaps (partly or fully) with any other currently-valid leave application) { reject and return } switch (leave type) { case annual: if (not enough annual leave balance) { reject and return } &#x2F;&#x2F; more annual condition checks case carry-forward: if (not enough carry forward leave balance) { reject and return } &#x2F;&#x2F; more carry-forward condition checks case paternity, maternity: branch out to eligibility and extent of availability processing &#x2F;&#x2F; excluded for simplicity case compensatory-off: if (date against which compensation is availed was working) { reject and return } if (employee did not work on that day) { reject and return } if (that date is already used for compensatory off) { reject and return } &#x2F;&#x2F; more compensatory checks case loss-of-pay: &#x2F;&#x2F; several loss-of-pay checks &#x2F;&#x2F; several more varieties } load the holiday calendar based on employee&#x27;s location load the shift details for the employee calculate effective duration of leave insert &#x2F; update all applicable records write audit entries and logs send response back </code></pre> Significantly simplified logic above excludes things like leave duration crossing year boundary (some counters get reset; new leave quotas may become available).<p>I look forward to guidance on how to approach this from a functional programming perspective. Thanks.

暂无评论

暂无评论