I've a service called Claims-Service which has following signature:
IClaimsService { EnsureClaim(claimType, userId) }
It queries database to see if the claim is present in any of my roles or not.
Based on my current requirements, I don't have a scenario which requires a user to have more than one claim to do something, but I think I'm going to need it in near future. (I'm in the very beginning of the project)
Is it ok to add following method to my service or not?
EnsureClaims( claimTypes, userId )
So I can pass array of claim types to it.
What pros and cons do you see if I develop the second method in my service?
Note that EnsureClaim and EnsureClaims need their own queries and there won't be any type of code re use. So I'm talking about developing new codes, automated tests & code review. And I'm not talking about huge amount of new codes.
EnsureClaim
is invoked... – user3347715 Jun 03 '19 at 15:14EnsureClaims
makes no sense. What would that method do? Internally loop over each item, open a new transaction, and executeEnsureClaim
? Or would it attempt to ensure all claims provided in one transaction? It's unclear given the lack of requirements you list. The point I'm making is that the choice between adding the method to your interface vs simply asking the caller to write afor
loop is not a question of code maintenance. It is a question of design. – user3347715 Jun 03 '19 at 15:19EnsureClaim
preferable to onlyEnsureClaims
where the caller can pass an array with a single value? – user3347715 Jun 03 '19 at 17:15EnsureClaim
bound to a single transaction? I do not have a mental model of your system so I cannot give you the answer, but adding a method to save the caller a for loop is a waste of time. It doesn't make your system any more cohesive. I would consider such a method "cruft" or technical debt. – user3347715 Jun 04 '19 at 15:26