Timeline for Designing UI module for an application
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 13, 2021 at 15:18 | comment | added | Peter M | @RobertBräutigam It's a trade off between a function call to get a pointer vs passing a pointer down through every function that might use it or need to pass it on to another function that will use it. The latter pollutes the function call hierarchy with irrelevant information. But the function call efficiency hit can be minimized by using an IoC approach in the classes that actually need to use the UI module. | |
| May 13, 2021 at 14:04 | comment | added | Robert Bräutigam | @marstato Even if you have a singleton motor controller, that doesn't really prevent you using the pins elsewhere, right? In my (hobby) arduino projects, I just declare all the hardware in one place, so I can see the pins I use at one glance. If you don't want to do that, you can always use some additional objects to manage the pins, make sure there are no conflicts, and require all hardware objects to get pins from that object. | |
| May 13, 2021 at 13:58 | comment | added | Robert Bräutigam | @PeterM My wording was maybe a bit imprecise. Singletons are looked up every time they are used. So while they are "at" a single place, or the code used to look it up is at a central place, the lookup/usage is not. Does that make more sense? | |
| May 13, 2021 at 13:35 | comment | added | marstato | I agree that in typical desktop and server development the Singleton pattern is almost never useful. But e.g. when working with hardware/low level code I think it is well suited. E.g. you only have one motor connected to a microcontroller. In that microcontrollers code there is no use for more than one instance of a controller class for that motor. You don't want two to accidentally have two instances sending conflicting commands, leading to damage to physical things. So I wouldnt paint it this black-and-white | |
| May 13, 2021 at 13:05 | comment | added | Peter M | isn't the purpose of a singleton simply to "Just create one instance in some central place" (and also does so via lazy loading)? | |
| May 13, 2021 at 12:58 | history | answered | Robert Bräutigam | CC BY-SA 4.0 |