In my spare time, I've been designing a CMS in order to learn more about actual software design and architecture, etc.
Going through the SOLID principles, I already notice that ideas like "MVC", "DRY", and "KISS", pretty much fall right into place. That said, I'm still having problems deciding if one of two implementations is the best choice when it comes to the Single Responsibility Principle.
Implementation #1:
class User
getName
getPassword
getEmail
// etc...
class UserManager
create
read
update
delete
class Session
start
stop
class Login
main
class Logout
main
class Register
main
The idea behind this implementation is that all user-based actions are separated out into different classes (creating a possible case of the aptly-named Ravioli Code), but following the SRP to a "tee", almost literally.
But then I thought that it was a bit much, and came up with this next implementation
class UserView extends View
getLogin //Returns the html for the login screen
getShortLogin //Returns the html for an inline login bar
getLogout //Returns the html for a logout button
getRegister //Returns the html for a register page
// etc... as needed
class UserModel extends DataModel implements IDataModel
// Implements no new methods yet, outside of the interface methods
// Haven't figured out anything special to go here at the moment
// All CRUD operations are handled by DataModel
// through methods implemented by the interface
class UserControl extends Control implements IControl
login
logout
register
startSession
stopSession
class User extends DataObject
getName
getPassword
getEmail
// etc...
This is obviously still very organized, and still very "single responsibility". The User class is a data object that I can manipulate data on and then pass to the UserModel to save it to the database. All the user data rendering (what the user will see) is handled by UserView and it's methods, and all the user actions are in one space in UserControl (plus some automated stuff required by the CMS to keep a user logged in or to ensure that they stay out.) I personally can't think of anything wrong with this implementation either.
In my personal feelings I feel that both are effectively correct, but I can't decide which one would be easier to maintain and extend as life goes on (despite leaning towards Implementation #1.)
So what about you guys? What are your opinions on this? Which one is better? What basics (or otherwise, nuances) of that principle have I missed in either design?