The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Single Responsibilty, How Did I Forget You

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Amos King

Posts: 78
Nickname: adkron
Registered: Jan, 2007

Amos King is a Web Developer for the US Postal Service and for Ramped Media.
Single Responsibilty, How Did I Forget You Posted: Apr 12, 2011 10:23 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Amos King.
Original Post: Single Responsibilty, How Did I Forget You
Feed Title: DirtyInformation
Feed URL: http://feeds.feedburner.com/Dirtyinformation
Feed Description: Information about Ruby/Rails/JRuby/WebDevelpoment/whatever.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Amos King
Latest Posts From DirtyInformation

Advertisement

Sometimes when developing I forget some of the basics as I go along. This time and many times in the past I have forgotten to follow the Single Responsibility Principle. I always forget it in the same place, the User object.

The User class always appears to be a place to take care of login and logout, but it does so much more. Everytime I need to change the User or expand to multiple types I end up dealing with login issues. It is easy to think that the responsibility of the User is to handle all things related to the User, but logins are not part of the credentials.

What happens when I need multiple logins to act on behalf of the same user, or when I have multiple user types, but I want to use the same login system. In the past I've always created a User and an AdminUser, with separate logins. Why?...It just felt right, and the AdminUser had different properties than a regular user. Now I have multiple user types that should share some common code. Sweet, a module will do that for me. It still doesn't solve all of my issues. I have to separate logins. What should I have done?

A Credential class should be created and can link to a profile. This allows my Credential class to only change if the login system changes. Each user type can be a separate Profile class. This eases the burden of the user class and allows greater future expandability.

Why didn't I do this in the past? I've run into this problem many times in the past, but never really got it. Now I'd just like to say, "I GET IT!!!"

Read: Single Responsibilty, How Did I Forget You

Topic: Single Responsibilty, How Did I Forget You Previous Topic   Next Topic Topic: Learn Ruby Programming For Free

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use