I want ask experienced software developers and architects about this domain class which I was found one day in some code.
public class User : Entity { public virtual string Firstname { get; set; } public virtual string Lastname { get; set; } public User(string firstName, string lastName, IUserRepository userRepository, IUserService userService) { Firstname = firstName; Lastname = lastName userRepository.Save(this); userService.DoSomeStaff(this); } }
What you think about SOLID principles in particular class constructor? I think that it break at least single responsibility principle. I think that because I see in constructor 3 responsibilities(1 – object init in constructor, 2 – object saving to db using repository, 3 – doing some staff using service).
Sorry for my stupid question, but I need your opinion about it. May be some project architecture allows this code style?