Tag Info

New answers tagged


OK, here is a different take on the question. An object oriented principle is to minimize coupling. I agree that it is often a good idea. But another important programming principle is to minimize complexity. The answer by cricket_007 does a good job of reducing coupling, but it does add more code. I don't know the specifics of your application, but ...


Create an interface, say Coinable, with a single insertCoin() method. interface Coinable { insertCoin(); } Then you can make n Object(s) that implement Coinable (and, some may delegate). And by programming to the interface, you can use various instances interchangeably.

Top 50 recent answers are included