Hacker News new | ask | show | jobs
by ryanthejuggler 4110 days ago
Also, singletons are great in robotics control software. It removes a lot of complexity if you have one singleton corresponding to one device.
1 comments

What happens if you add a second camera?

The actor/CSP model makes each device a separate process, which can be hooked together with processing nodes works wonderfully.

> What happens if you add a second camera?

You call it TheSecondCamera, duh.

If there's the potential for multiples then I'll have a CameraManager (TheCameraManager) that finds out what's connected to the system and provides enumeration and access. I'll generally try to make the cameras look like a singleton and hide the Camera class. Sort of like a factory, except you'll only ever get N instances of your Camera class for N cameras.
TheCameraArray[1]