Tag Info

New answers tagged

2

Your class is called RVDBuilder. The point of the builder pattern is to avoid ridiculously complex constructors and instead allow you to gradually collect all necessary information via ordinary method calls. Therefore, the best solution would be to add a fluent interface to add pairs of information: class RVDBuilder { public RVDBuilder Add(string key, ...


4

I had to tackle this recently in Java. My solution was to make the Pair class fairly painless to instantiate: Pair.of(..., ...). That's only 7 extra characters before the parentheses, and naming the factory method of seems to be a convention that value-based classes follow in Java 8. But in my use case there were usually no more than 3-4 pairs, so I also ...


3

I read in "Effective C++" that APIs should always be easy to use correctly and hard to use incorrectly. Since you've stated that it can be used incorrectly, I would ditch it for a solution that can be safer.


0

For this particular problem I would recommend something similar to your's second aproach. Check out Service Locator pattern (Is this a good service locator, and is this service locator pattern(?) OK?) this is basically what you called "registry". Secondly - don't put User as a service there. Most probably you need something like Session, and in your code ...


1

It's a balance. In general, having specific interfaces is better than general interfaces. Functions should not know more than they need to know to work. But also, in general, it isn't good to have piles of interfaces that are only ever used in one place. So you need to balance making specific interfaces for your needs and using existing interfaces even ...


2

Is it better to have one or few parameters that supply more than enough information for the intended process "More than enough" is the red flag here. When paying in a store, you don't give your entire wallet so that the cashier takes cash out of it. The cashier doesn't really need to know what your wallet is like, or look at pictures of your kids, and ...



Top 50 recent answers are included