- D3.js 4.x Data Visualization(Third Edition)
- ?ndrew Rininsland Swizec Teller
- 198字
- 2021-07-02 23:20:23
What happened to all the classes?
The second edition of this book contained quite a number of examples using the class feature that is new in ES2015. The revised examples in this edition use factory functions instead, and the class keyword never appears. Why is this, exactly?
ES2015 classes are essentially just syntactic sugaring for factory functions. By this I mean that they ultimately transpile down to factory functions anyway. Although classes can provide a certain level of organization to a complex piece of code, they ultimately hide what is going on underneath it all. Not only that, using OO paradigms, such as classes, is effectively avoiding one of the most powerful and elegant aspects of JavaScript as a language, which is its focus on first-class functions and objects. Your code will be simpler and more elegant using functional paradigms than OO, and you'll find it less difficult to read examples in the D3 community, which almost never use classes.
There are many, much more comprehensive arguments against using classes than I'm able to make here. For one of the best, refer to Eric Elliott's excellent The Two Pillars of JavaScript pieces at:
www.medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3.
- 移動UI設計(微課版)
- ThinkPHP 5實戰
- C#編程入門指南(上下冊)
- Vue.js快跑:構建觸手可及的高性能Web應用
- Julia機器學習核心編程:人人可用的高性能科學計算
- Kinect for Windows SDK Programming Guide
- Kali Linux Wireless Penetration Testing Beginner's Guide(Third Edition)
- Oracle從入門到精通(第5版)
- Solutions Architect's Handbook
- Visual C++開發寶典
- UML基礎與Rose建模實用教程(第三版)
- C語言程序設計教程
- 軟硬件綜合系統軟件需求建模及可靠性綜合試驗、分析、評價技術
- Mastering XenApp?
- Magento 2 Developer's Guide