On Mon, Mar 3, 2014 at 5:36 AM, Colin Law <clanlaw@gmail.com> wrote:
> On 3 March 2014 09:18, Brandon <wongwf82@gmail.com> wrote:
...
>> But it seems that User controller will be pretty FAT over time.
>
> Why?
Because User has a classic tendency to become a God Object. :-)
Brandon, sorry if I'm repeating stuff that came earlier, I didn't pay
much attention to this thread until the above exchange caught my eye.
The User class tends to accumulate a lot of crud (not to be confused
with CRUD), becoming what we call a God Object, one that sees, knows,
and tells all.
To combat that tendency, remember the Single Responsibility Principle,
and look for clear dividing lines to separate responsibilities. What
I usually do is keep User responsible only for logging in and out, so
it usually contains only username, encrypted password, and (only for
purposes of sending password reset tokens and suchlike) an email
address. Any other personal info, like a "real" name, address, phone
number, biography, picture, etc. goes in a Profile object that
belongs_to that User. Other info for specific aspects of using the
system, like availability and desired salary if it's a job board, go
in more specific profiles, like JobSeekerProfile or JobPosterProfile.
-Dave
--
Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us);
FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014;
creator of Pull Request Roulette, at PullRequestRoulette.com.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQiirXyJ5cW3AFe8RfaLUv9HjFjJNRpzNm4E8Eb%2Bxp7932g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment