8 ms·
I think its a poor example. How often you are going to write something like that in RL scenario? In case of more complex data generation you could use supplier
by pojzon 7y ago
I think its a poor example. How often you are going to write something like that in RL scenario?
In case of more complex data generation you could use supplier pattern and combine it with strategy.
No need for any if else statements at all.
Sure it requires a lot more of work but is future proof and clear.
- brigandish 7y agoI've not heard of the supplier pattern, any chance you would direct me to a resource about it?
- pojzon 7y agoIm pretty sure you know what i meant, no need for nitpicking. (Does not make me any less right)
- stevesimmons 7y agoJust maybe he genuinely doesn't know what you mean. I mainly use Python and have no idea what you are talking about. (You might consider reflecting on your tone and message. It presupposes bad faith on the other party, is dismissive and condescending, and you are probably less right than you think you are.)
- brankoB 7y agoI, too, have no idea what a supplier pattern is. Don't think that's a very mainstream notion.
- oblio 7y agoI'm not OP, but I don't know what you mean... Googling it leads me to Supplier in Java 8, which is probably not what you meant?
- brigandish 7y agoI can't nitpick what I don't know about. I know the strategy pattern, not the supplier pattern. It sounds interesting, that was all.
- fjsolwmv 7y agoA Supplier is when a function needs a value, and instead of providing a value as an argument, you pass in callable: Foo(int x){return x+1} becomes Foo(Supplier x){return x() + 1}
- pojzon 7y agoFunction that supplies value, can also encapsulate alot of data generation code. After that you can write a strategy to select which data generation algorithm (supplier) shpuld be used. Thats my cause.
- brigandish 7y agoThanks.