Timeline for Using constructors for "layered" instances
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 10, 2017 at 14:11 | comment | added | Daniel M. |
if they wish to, or simply construct their class (or use a static factory) like normal. The second method would also accept a list to pass along to the constructor. The first method would simply use this as the argument to the function, while the second method would prepend this to the list. I can also use these methods for the default functions.
|
|
| Feb 10, 2017 at 14:05 | comment | added | Daniel M. |
Good point about having the method simply call the constructor of the public class. Since they would be effectively identical, I can expose both and make it very clear in the documentation that the method is simply a shortcut for the constructor. Also the linked article made a good point about having all composite objects inherit from the same subclass of LEDStrip. What I might do is in the base strip class, create two methods, one that accepts a Function<LedStrip, CompositeLedStrip> and one Function<List<LedStrip>, CompositeLedStrip> so users can pass in constructors in a functional style
|
|
| Feb 10, 2017 at 13:48 | vote | accept | Daniel M. | ||
| Feb 10, 2017 at 13:31 | history | answered | amon | CC BY-SA 3.0 |