在遵循领域驱动设计时,实际实现服务类的最佳方式是什么?
例如说我想要一个AccountService
可以用来将资金从一个帐户转移到另一个帐户?以下哪一项(如果有)是实现这一点的最佳方式?
public class AccountService1
{
private IAccountRepository _accountRepo;
public AccountService1(IAccountRepository accountRepo)
{
_accountRepo = accountRepo;
}
public void TransferFunds(double ammount, int sourceAccountNumber, int targetAccountNumber)
{
//FUNDS TRANSFER CODE
}
}
public class AccountService2
{
public void TransferFunds(double ammount, Account sourceAccount, Account targetAccount)
{
//FUNDS TRANSFER CODE
}
}
public static class AccountService3
{
public static void TransferFunds(double amount, Account sourceAccount, Account targetAccount)
{
//FUNDS TRANSFER CODE
}
}
public static class AccountService4
{
public static void TransferFunds(double amount, int sourceAccountNumber, int targetAccountNumber, IAccountRepository repository)
{
//FUNDS TRANSFER CODE
}
}