Teaching Data Science Students to Write Clean Code (Episode 37) - Todd Iverson
Bài giảng này trình bày cách dạy sinh viên Khoa học Dữ liệu viết mã sạch, tập trung vào các nguyên tắc như đặt tên tốt, hàm nhỏ, kiểm thử đơn vị và tái cấu trúc mã. Bài giảng sử dụng câu chuyện về một sinh viên tên Doug để minh họa các khái niệm.
正在生成预览...
Teaching Data Science Students to Write Clean Code Todd Iverson, Winona State University Slides/Code: https://bit.ly/2WgFIbI Episode 37 Doug Wants an A The Hero I NEED an A! The Villain Hi! I’m Doug Grrr Doug? An A? HA! His code stinks! Doug “Crazy Legs” Ervison “Mean” Dr. Iverson Doug will demonstrate 1. Good names 2. Small functions 3. Unit tests 4. Refactor code, specifically 1. Extract functions 2. Split loops Opening Scene - The Assignment But Dr. Iverson is SO mean! Kaggle is Kool! Kaggle assignment! https://www.kaggle.com/c/spooky-author-identification/data (…this assignment require unit tests!…) Doug’s Original code (…F!…) Iverson loves Bag of Words! I am going to get an A for sure! It looks like our hero is doomed to an F! Then just in the nick of time … … Doug remembers unit tests! You MUST have unit tests. What are unit tests? Captures/maintain intended behavior Helpful when changing code Should be automated Doug writes some unit tests Original behavior New behavior That was easy! And my code passed! (…with names like that …) Doug’s Original code (…a C at best…) Remembered the Unit Tests! I am going to get an A for sure! Luckily, Doug remembers to think about names Names are important! They should express intent! Good names… Reveal intent Use the proper parts of speech Have the proper length for their scope Avoids disinformation and encodings Data: What is it? Function: What does it do? Good names… Reveal intent Use the proper parts of speech Have the proper length for their scope Avoids disinformation and encodings Variable: Noun Function: Verb Boolean: Predicate Doug inspects his names These names are bad. What’ ews again?? Doug finds some better names ews hold the words for Edgar Allen Poe Maybe I should just use poe_words A+ for sure! (…D at best…) poe_words is better than ews (…see the bug?…) The other names are better too! It looks like our hero is doomed with D! Then just in the nick
… 下载原始文件以阅读完整文档。
- 文档名称
- Teaching Data Science Students to Write Clean Code (Episode 37) - Todd Iverson
- 作者(文档中)
- Todd Iverson
- 内容
- Tài liệu hướng dẫn sinh viên khoa học dữ liệu viết mã sạch thông qua các ví dụ thực tế về đặt tên, chia hàm, unit test và tái cấu trúc. Câu chuyện về sinh viên Doug minh họa cách áp dụng các kỹ thuật này để cải thiện chất lượng mã.
- 目录
- Episode 37
- Doug Wants an A
- The Hero
- The Villain
- Doug will demonstrate
- Opening Scene - The Assignment
- Doug’s Original code
- Then just in the nick of time …
- What are unit tests?
- Doug writes some unit tests
- Luckily, Doug remembers to think about names
- Good names…
- Doug inspects his names
- Doug finds some better names
- The other names are better too!
- Then just in the nick of time …
- What else would Iverson complain about?
- Doug imagines Iverson’s feedback
- and Doug even remembers refactoring!
- Common Refactoring Technique
- The DRY principle
- Test after each change!
- Extract Functions
- Extract Another Function
- Common Refactoring Technique
- Split Loop
- Doug makes the blocks identical …
- … carefully splits the loop …
- … and extracts a function
- What did Iverson say about efficiency?
- The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.
- Doug’s Final Product
- Doug’s code is demonstrably better
- He clearly took Iverson’s clean code lectures to heart
- His solution consists of many small functions with g
- 页数
- 52 页
- 上传者
- Giang Le
常见问题
此文档免费吗?
是的。“Teaching Data Science Students to Write Clean Code (Episode 37) - Todd Iverson”是免费的 — 只需登录并点击“下载”即可获取原始文件。
这份文档有多少页?
该文档共有 52 页。您可以在下载前进行在线预览。
我可以在下载前预览吗?
是的。您可以通过在线阅读器直接在本页面预览此文档,然后再决定是否下载。

评论 (0)
暂无评论。快来抢沙发吧!