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.
Génération de l'aperçu...
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
… Téléchargez le fichier original pour lire le document complet.
- Nom du document
- Teaching Data Science Students to Write Clean Code (Episode 37) - Todd Iverson
- Auteur (dans le document)
- Todd Iverson
- Contenu
- 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ã.
- Table des matières
- 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
- Pages
- 52 pages
- Téléversé par
- Giang Le
Foire aux questions
Ce document est-il gratuit ?
Oui. « Teaching Data Science Students to Write Clean Code (Episode 37) - Todd Iverson » est gratuit — il suffit de vous connecter et de cliquer sur Télécharger pour obtenir le fichier original.
Combien de pages compte ce document ?
Le document contient 52 pages. Vous pouvez le prévisualiser en ligne avant de le télécharger.
Puis-je prévisualiser avant de télécharger ?
Oui. Vous pouvez prévisualiser ce document directement sur cette page avec le lecteur en ligne, puis décider de le télécharger ou non.

Commentaires (0)
Aucun commentaire pour le moment. Soyez le premier !