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

Identifying problems with our current approach

Aside from the lines of code responsible for building the user interface, our program is roughly 48 lines long.

The core of the program resides in the share-price and avg functions, which are responsible for querying the price service and calculating the average of a list of n numbers, respectively. They represent only six lines of code. There is a lot of incidental complexity in this small program.

Incidental complexity is complexity that's caused by code that is not essential to the problem at hand. In this example, we have two sources of such complexity: the thread pool and the rolling buffer function (we are disregarding UI-specific code for this discussion). They add a great deal of cognitive load to someone reading and maintaining the code.

The thread pool is external to our problem. It is only concerned with the semantics of how to run tasks asynchronously. The rolling buffer function specifies a detailed implementation of a queue and how to use it to represent the concept.

Ideally, we should be able to abstract over these details and focus on the core of our problem; Compositional Event Systems (CES) allow us to do just that.

主站蜘蛛池模板: 新巴尔虎左旗| 平舆县| 田东县| 滁州市| 邻水| 山阳县| 古交市| 井陉县| 陈巴尔虎旗| 清新县| 贵阳市| 乌苏市| 大洼县| 丹阳市| 新昌县| 辽宁省| 山西省| 鹤庆县| 彭州市| 淅川县| 苏尼特左旗| 乌鲁木齐市| 鹤山市| 济阳县| 抚宁县| 武宣县| 吴桥县| 凤冈县| 广德县| 澎湖县| 离岛区| 肥西县| 车险| 隆安县| 镇坪县| 扎鲁特旗| 西充县| 巴马| 北川| 奈曼旗| 上杭县|