I’m a bit stuck with where to put some method calls (separation of responsibility) and although I’m trying to do it just simply now in the models, I think my problem raises a bigger question about Fat Models. But that’s another subject for another day.
Right now, I have …
has an a invitation_expiry date field.
DateTime.now.in_time_zone(‘UTC’) >= event.invitation_expiry.in_time_zone(‘UTC’)
My problem is when an invitation is made, I want to check if the invitation has expired. I have thought of the following …
- include a method call in the Invitation model
Check if the meeting (event’s invitation) has expired (should it be called event_invitation_expired?
Should the invitation know anything about the Event class?
def meeting_expired? ## event_invitation_expired?
meeting.invitation_expired? ## meeting.event.invitation_expired?
- include an event_id foreign key in the invitations table so I can have the same method as in the Meeting model
I’m happy with either one but am open to other ideas or what you would do.
The BIGGER question is, what exactly should go in the models?!! We talk about Fat models, but for me, that doesn’t fit nice with OO programming. To me, it’s quite clear that the we are not doing OO programming by stuffing our models with everything related to that model. There needs to be another level of abstraction to keep everything clean and have the separation of concerns.
I’m a self taught OO programmer and I come from a functional programming background, so maybe I’m talking out of my hat. But while writing tests for my app, to me, there are just too many code smells.
I look forward to your thought