Need more parameters in subclass overridden method

14 Views Asked by At

I use ddd in my learning project. The repository uses domain classes and internally maps them to persistence classes. In the base repository, I have the method Add(domainClass) and in the subclass UserRepository I need a method Add(domainClass, passwordHash, passwordSalt) to register a new user and I don't have these two fields in the domainClass because I do not have any domain logic that needs them.

1

There are 1 best solutions below

0
Mark Seemann On

You don't write which language you're using, but assuming something mainstream like Java or C#, if you've defined a method in a base class (or interface) then you can't change it in a derived or implementing class.

One option is to make the extra parameters part of the object (the domainClass, I assume?).

Another option is to pass the extra parameters via the constructor.