官术网_书友最值得收藏!

Reactive versus proactive

So what is reactive programming?

An easy way to get the idea behind it is to use an analogy with people's behavior: someone who is proactive is somebody who takes initiatives. A proactive person will propose ideas or test things before somebody asks him to do so. On the other hand, a reactive person is somebody who waits for information before doing something. So,  a proactive person acts on his own while a reactive person reacts to external changes. There are pros and cons to each behavior: a proactive person proposing solutions ahead of time is great, but may have difficulties dealing with unexpected changes. On the other hand, a reactive person may be very efficient in dealing with very dynamic environments.

Reactive programming can be considered as implementing a behavior in a similar way to a reactive person. A reactive system reacts on external events and provides a result that depends only on the event it has received. So why would reactive programming be better than sequential programming? Better is always a matter of preferences and context, so reactive programming may not be the solution most adapted to all the problems you will encounter. However, as you will see through this book, reactive programming shines at implementing event-driven code.

Reactive programming is inherently asynchronous. So it makes it easier to deal efficiently with inputs and outputs than with synchronous paradigms. Reactive programming favors composition. Each component is completely independent from another and can be plugged in with other components. This also makes testing quite easy and, as a consequence, it also helps to refactor existing code. Moreover, it is quite engaging, and with experience you will see that almost everything is a flow of events.

主站蜘蛛池模板: 若尔盖县| 突泉县| 沭阳县| 青冈县| 黄山市| 永泰县| 柘荣县| 二连浩特市| 新津县| 西华县| 城口县| 登封市| 栾城县| 庆阳市| 临武县| 济南市| 平泉县| 康马县| 上杭县| 大方县| 遂昌县| 斗六市| 宜都市| 岑巩县| 临沭县| 时尚| 资中县| 惠州市| 乳山市| 石林| 清丰县| 资阳市| 邯郸市| 新巴尔虎右旗| 九龙县| 镇沅| 利辛县| 望城县| 仪陇县| 盐源县| 宣汉县|