Thanks for your reply, mwhitney.
I have a noob question after reading your reply. While I can see how the scoring logic can be refactored into the Model, I'm not too sure how to do that for the aggregating/sorting behaviour.
Suppose my Model is implemented as such:
PHP Code:
class ContestantModel extends CI_Model {
private $first_name;
private $last_name;
private $time_taken_hours;
private $experience_years;
private $money_spent;
private $score;
/* Setters and getters */
.
.
.
public function findContestantBy($field, $value) {
$query = $this->db->get_where('contestants', array($field => $value));
// Populate table row data into object properties
.
.
.
}
public function calculateScore() {
// Logic to calculate score
.
.
.
$this->score = $result;
}
}
Each ContestantModel object would correspond to one Contestant and is unaware of other ContestantModel objects. How would I be able to implement the aggregating/sorting logic into the Model itself?
This was the original reason why I had thought to place the logic in the Controller: since it was a "layer" above the Model, it could have an overview of all the ContestantModels objects and hence be able to loop through these objects.