Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the point of Boost::Signals?

Firstly, I am an absolute beginner in programming, so don't make fun of me too much.
The only thing that I have seen signals used for are GUI toolkits, and GUI toolkits all come with their own signaling. So, can Boost:Signals even be used with these GUI toolkits? Would this be a good idea? What other applications do signals have?

like image 798
Patrick Avatar asked Dec 10 '22 12:12

Patrick


2 Answers

Signals is an event messaging implementation, much like Smalltalk/Objective C Messages or Events in various other (e.g. C#) lanugages.

You can use them for a wide variety of tasks, take a look at the Observer Pattern

Why would you use the Observer Pattern?

The benefits are largely organisational, when you work with large applications it's is important to apply patterns of reuse that help maintain development team coherence.

When the implementation of a particular pattern becomes de facto (or close to) it's especially useful because it means that lead up times for new team members are likely to be expedited, not only if they have used the implementation before, but also because the popularity of the implementation will mean that there are widespread resources, and documentation available to speed learning.

From a pure code perspective, ALL patterns appear as bloat, but when you begin to understand that upwards of 60% of the costs involved in software development are in maintenance life-cycle, it is well worth the additional code to gain coherence.

The other benefit is to aid in software reuse, depending on the style of implementation, the Observer Pattern can assist in modularising and decoupling classes from one another. I would suggest that this is also an organisational benefit, in as much that different teams can build components more easily, or simply because components are easier to replace.

like image 134
ocodo Avatar answered Dec 24 '22 12:12

ocodo


Just my two cents, signals are not only used in (or for) GUI toolkits. They are used in contexts where you want to decouple the producer of a datum with the receiver of it (the observer pattern mentioned above, for example). If you mix that idea with threads, you can implement actors easily, an interesting pattern for concurrent tasks (Erlang and Scala use actors, for instance).

like image 42
Diego Sevilla Avatar answered Dec 24 '22 12:12

Diego Sevilla