A question of semantics?

Posts   
 
    
thomas
User
Posts: 24
Joined: 21-Oct-2004
# Posted on: 09-Dec-2004 01:57:39   

Lets say I have a UserEntity want to employ a UserEntityManager for all the good things a manager class brings with it. I have a very basic question. Do you think that a UserManager.AddUser ( ) method should take a UserEntity as parameter or should take the various strings, ints etc that make up the users properties. In other words, have you found this better

 public void AddUser(UserEntity newUser)
{
.... do some validation of the entity against more complex business rules and then 
     add it to the db
    
     newUser.Save()

}

Or have you found this approach more useful

 public void AddUser(string userName, string userPassword)
{

     UserEntity newUser = new UserEntity();
     userEntity.Password=userPassword;
    userEntity.UserName = userName;
.... do some validation of the entity against more complex business rules and then 
     add it to the db
    
    userEntity.Save()

}

The reason I'm asking is because one approach allows Entity objects to reach the PL while the other approach works to avoid that. If I'm interested in having a real facade of some sort, would'nt I pretty much always want the second approach? That way it doesnt matter if a smartphone is calling the code, a winapp or an asp.net page.

Any thoughts?

Thanks, Thomas

MarcoP avatar
MarcoP
User
Posts: 270
Joined: 29-Sep-2004
# Posted on: 09-Dec-2004 03:07:21   

I opt to allow the ui tier to know about entities. One of the main reasons for this is that we are taking advantage of the .net databinding and the entities are well armed to support this. Not to mention, I love the IsDirty() property, which allows me to prompt for dirty changes when the user tries to close the form.

thomas
User
Posts: 24
Joined: 21-Oct-2004
# Posted on: 09-Dec-2004 04:50:39   

Good point! Would you believe that my work has been in the web world of .NET? What your saying makes sense - and I just remembered Frans posting something about loading entities into the VS toolbar..... hmmm. Interesting.

Thomas