I have a question about where to put some code. In a fishing tournament scoring system 2 classes are at issue: Catches and ScoreCard (a ScoreCard is a tournament entry -- standings are the ordered list of ScoreCards for a given Tournament). The tournament abstraction is layered over an underlying fishing log abstraction. There is no Cake association between Catches and ScoreCards -- a Catch can be utilized in multiple ScoreCards (ie in multiple tournaments that are concurrently being run) -- currently I am not using HABTM etc.
When a user adds or edits a catch the code must: - For each ScoreCard of the User - Determine if this catch is relevant to the ScoreCard - Calculate the score and update the ScoreCard The relevancy test examines the ScoreCard to get the Tournament timeframe to see if its active (it's actually in a Tournament record associated with the ScoreCard) and compare the Fish types on the ScoreCard and the Catch being saved. It determines whether any further ScoreCard processing is required. Afer relevancy is determined the scoring calculation requires querying all relevant catches and determining the highest score etc, then updating the relevant ScoreCard. I really wanted to put this code in the Catches Model AfterSave routine but ran into all kinds of contextual problems of not being able to access the functions I need to get the job done. Currently the code is in a subroutine invoked by the Edit and Add controller code for the Catches class just after the Save returns. In the controller context of the Edit or Add action I already have the User's ScoreCards and associated Catches available by association with the User doing the Add or Update. However when I try to migrate this code to the AfterSave I run into all kinds of restrictions. Should this code be in the model or controller? Is my application poorly designed or am I misinterpreting data logic and business logic? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
