Teaching Data Science Students to Write Clean Code (Episode 37) - Todd Iverson

UN
Uni24h
0 lượt tải
52
0

Nội dung tài liệu

Trang 1

Teaching Data Science Students to Write Clean Code Todd Iverson, Winona State University Slides/Code: https://bit.ly/2WgFIbI

Trang 3

The Hero The Villain I NEED Hi! I’m Doug? an A! Doug Grrr An A? HA! His code stinks! Doug “Crazy Legs” Ervison “Mean” Dr. Iverson

Trang 4

Doug will demonstrate 1. Good names 2. Small functions 3. Unit tests 4. Refactor code, specifically 1. Extract functions 2. Split loops

Trang 5

Opening Scene - The Assignment But Dr. Iverson is SO mean! Kaggle is Kool! Kaggle assignment! https://www.kaggle.com/c/spooky-author-identification/data

Trang 6

(…this assignment require unit tests!…) Doug’s Original code (…F!…) Iverson loves Bag of Words! I am going to get an A for sure!

Trang 10

What are unit tests? • Captures/maintain intended behavior • Helpful when changing code • Should be automated

Trang 12

(…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!

Trang 14

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?

Trang 15

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

Trang 17

Doug finds some better names ews hold the words for Edgar Allen Poe Maybe I should just use poe_words

Trang 18

A+ for sure! (…D at best…) poe_words is better than ews (…see the The other bug?…) names are better too!

Hiển thị 18 trang đầu. Tải tài liệu để xem đầy đủ.

Bình luận (0)

Đăng nhập để tham gia bình luận

Chưa có bình luận nào. Hãy là người đầu tiên!