What are the advantages and disadvantages when using either one of the following:
payer.transfer(payee, amount); vs. transfer(payer, payee, amount);
Regarding this simple example, my interest is toward the design, dependencies, abstraction etc...
Appreciate your comments and resources pointed out!
Top comments (2)
payer.transfer(payee, amount);
transfer(payer, payee, amount);
argument
comes then behaviour is something else we have to switch to default.As you can see there are pros and cons to both, personally I would prefer second approach as it gives us the flexibility to have defaults.
Most of the library developers tend to provide both the approaches.
In the first case, you use the payer as an entity, and in the other case the entity is the transfer itself. The question that i would consider is: "Could the transfer exists without the payer?" I think it couldnt, but the payer can exists by itself, because normally you want to store data about the client prior to the transfer.
As always, there is not a clear answer. Developing software is a logical process, but also has creative influence. Each developer has a different point of view, and all of them could solve the same problem with different focus. And I think that's the most enjoyable thing about design