dongtui6347 2015-12-08 17:39
浏览 21

将属性计算放在MVC设计中的位置

I'm building an application that manages holidays and absences from work using MVC patterns.

model

  • Data layer - the properties of an absence
  • Domain layer - load all the absences for an employee for a period
  • Service layer - interacts with the domain layer and manipulate absence entities

I need to calculate the amount of holiday time used and available. Logically I'd do this in the service layer, that is get all the absences from the domain and iterate through them to get a result.

In the view I need to display all the absences and holidays used. This implies the system is loading the absences twice, once to calculate holiday usage and once to get a list to display.

Is this aright? In a non MVC but OOP world I would have an AbsenceList class with a getHolidayUse() method so the class would only need to be loaded from the database once.

Should I just accept that I'll need to load and destroy entities a lot and implement caching to cope with it?

Should I implement an AbsenceList entity that includes the list of absences and has a holidayUsed property that is calculated in the domain layer findAll() method?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探