Object-oriented programming for self-taught programmers, from the perspective of a data scientist. The presentation covers a conceptual overview of what OOP actually is, some worked examples of how to use it and some good and bad reasons for using OOP in your work.
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Mozaic Works
Talk delivered by Aki Salmi at I T.A.K.E. Unconference in Bucharest, 2014.
The presentation shows two example cases of introducing new features to the project. The first is a story of adding a search criteria to a list of 15 parameters.
The other example is total refactoring of handling files transferred to the system using FTP. It included both changes to the supported file types and the structure of the code.
In both examples, the end results are highlighted from both maintainability perspective and from business perspective.
Lightening Talk I gave at Inaka in April 2014.
I was in charge of investigating test-driven development for our iOS mobile team. Since I realized it was such a big concept, after having gathered enough information and having played with it enough, I decided to introduce my fellows on the topic by presenting it in a formal talk with slides. The aim was teaching them a different way of developing, which, for us, at that moment, was completely new and controversial.
I gave this talk at the code.talks 2015 conference in Hamburg, Germany: https://www.codetalks.de/2015/programm/there-is-no-javascript.
JavaScript is a truly bizarre language: at once interpreted and compiled, functional and mutative, prototypal and syntactically poor, chaotic and elegant. It is the lowest high-level language of the amorphous operating system known as the web. It has evolved rapidly, sidelining all competition and building up a huge ecosystem of libraries and tools and symbiotic users.
And yet, its very popularity is bringing about its demise, whether by the introduction of the low-level WebAssembly or innumerable higher-level languages or even the reimagined ECMAScript 6 and other descendants. In this talk, we will explore JavaScript's evolution from a mere amoeba in Brendan Eich's bubbling pool to a dinosaur in John Resig's slightly more recent Mesozoic lair and all the way to its inevitable disappearance into civilized ubiquity.
Object-oriented programming for self-taught programmers, from the perspective of a data scientist. The presentation covers a conceptual overview of what OOP actually is, some worked examples of how to use it and some good and bad reasons for using OOP in your work.
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Mozaic Works
Talk delivered by Aki Salmi at I T.A.K.E. Unconference in Bucharest, 2014.
The presentation shows two example cases of introducing new features to the project. The first is a story of adding a search criteria to a list of 15 parameters.
The other example is total refactoring of handling files transferred to the system using FTP. It included both changes to the supported file types and the structure of the code.
In both examples, the end results are highlighted from both maintainability perspective and from business perspective.
Lightening Talk I gave at Inaka in April 2014.
I was in charge of investigating test-driven development for our iOS mobile team. Since I realized it was such a big concept, after having gathered enough information and having played with it enough, I decided to introduce my fellows on the topic by presenting it in a formal talk with slides. The aim was teaching them a different way of developing, which, for us, at that moment, was completely new and controversial.
I gave this talk at the code.talks 2015 conference in Hamburg, Germany: https://www.codetalks.de/2015/programm/there-is-no-javascript.
JavaScript is a truly bizarre language: at once interpreted and compiled, functional and mutative, prototypal and syntactically poor, chaotic and elegant. It is the lowest high-level language of the amorphous operating system known as the web. It has evolved rapidly, sidelining all competition and building up a huge ecosystem of libraries and tools and symbiotic users.
And yet, its very popularity is bringing about its demise, whether by the introduction of the low-level WebAssembly or innumerable higher-level languages or even the reimagined ECMAScript 6 and other descendants. In this talk, we will explore JavaScript's evolution from a mere amoeba in Brendan Eich's bubbling pool to a dinosaur in John Resig's slightly more recent Mesozoic lair and all the way to its inevitable disappearance into civilized ubiquity.
This slide created for shared internal and for everyone interesting clean code. Why we needed? Why you should use it?
Ps. Sorry if my grammar is very bad :D
How I Learned to Stop Worrying and Love Legacy Code.....Mike Harris
Legacy Code. I never wrote it; everybody else did!
How many times have you waded through an ageing, decaying, tangled forrest of code and wished it would just die?
How many times have you heard someone say that what really needs to happen is a complete rewrite?
I have heard this many times, and, have uttered that fatal sentence myself.
But shouldn’t we love our legacy code?
Doesn’t it represent our investment and the hard work of ourselves and our predecessors?
Throwing it away is dangerous, because, before we do, we’ll need to work out exactly what it does, and we’ll need to tweeze out that critical business logic nestled in a deeply entangled knot of IF statements. It could take us years to do, and we’ll have to maintain two systems whilst we do it, inevitably adding new features to them both. Yes we get to reimplement using the latest, coolest programming language, instead of an old behemoth, but how long will our new cool language be around, and who will maintain that code, when it itself inevitably turns to legacy?
We can throw our arms in the air, complaining and grumbling about how we didn’t write the code, how we would never have written it the way it is, how those that wrote it were lesser programmers, possibly lesser humans themselves, but the code still remains, staring us in the face and hanging around for longer that we could possibly imagine. We can sort it out, we can improve it, we can make it testable, and we can learn to love our legacy code.
A dispute on probably the most controversial feature in ES2016 leads us back to age old questions at the base of the most common practices of the development universe.
Do the “sacred laws” still apply?
jsDay 2016 closing keynote (http://2016.jsday.it/talk/a-class-action/)
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجیsaber tabatabaee
یک پروژه کوچیک اوپن سورس از گیت هاب پیدا کنیم و اون رو باز کنیم و معماری لاراول رو بررسی کنیم و روی سرور مون هاست کنیم و به کمک و واسطه گیت اون رو راه اندازی کنیم
More Related Content
Similar to teaching data science students to write clean code
This slide created for shared internal and for everyone interesting clean code. Why we needed? Why you should use it?
Ps. Sorry if my grammar is very bad :D
How I Learned to Stop Worrying and Love Legacy Code.....Mike Harris
Legacy Code. I never wrote it; everybody else did!
How many times have you waded through an ageing, decaying, tangled forrest of code and wished it would just die?
How many times have you heard someone say that what really needs to happen is a complete rewrite?
I have heard this many times, and, have uttered that fatal sentence myself.
But shouldn’t we love our legacy code?
Doesn’t it represent our investment and the hard work of ourselves and our predecessors?
Throwing it away is dangerous, because, before we do, we’ll need to work out exactly what it does, and we’ll need to tweeze out that critical business logic nestled in a deeply entangled knot of IF statements. It could take us years to do, and we’ll have to maintain two systems whilst we do it, inevitably adding new features to them both. Yes we get to reimplement using the latest, coolest programming language, instead of an old behemoth, but how long will our new cool language be around, and who will maintain that code, when it itself inevitably turns to legacy?
We can throw our arms in the air, complaining and grumbling about how we didn’t write the code, how we would never have written it the way it is, how those that wrote it were lesser programmers, possibly lesser humans themselves, but the code still remains, staring us in the face and hanging around for longer that we could possibly imagine. We can sort it out, we can improve it, we can make it testable, and we can learn to love our legacy code.
A dispute on probably the most controversial feature in ES2016 leads us back to age old questions at the base of the most common practices of the development universe.
Do the “sacred laws” still apply?
jsDay 2016 closing keynote (http://2016.jsday.it/talk/a-class-action/)
هاستینگ و راه اندازی یک پروژه لاراول - آنالیز و امکان سنجیsaber tabatabaee
یک پروژه کوچیک اوپن سورس از گیت هاب پیدا کنیم و اون رو باز کنیم و معماری لاراول رو بررسی کنیم و روی سرور مون هاست کنیم و به کمک و واسطه گیت اون رو راه اندازی کنیم
آشنایی اولیه با لاراول
سلام دوستان
فردا شب 9 به وقت ایران پرزنت امکانات لاراول 8 رو داریم برای بکند کارهای دات نت و ... که بدونند با چه فریم ورک هلویی طرف هستند و همه کاری این فریمورک براشون انجام میده و حقوقشون ضربدر 2 میشه توی ایران. از بس که استارت آپ ها رفتند سراغ لاراول و ما در کشور به سه برابر ظرفیت کنونی لاراول_کار نیاز داریم
البته که هر چی تقاضا زیاد باشه و عرضه کم باشه کالا و خدمات گرون تر میشه 藍 ولی کارآفرینی و شاغل شدن متخصصین، اولویت اول مملکته و باید در نشر دانش و تجربیات و فرصت ها به هموطنامون در این شرایط اقتصادی کوشا باشیم.
موفق موید باشید.
راستی سه تا موضوع رو میگیم.
1- امکانات فوق العاده لاراول
2- نگاه طراحی و معماری این فریم وورک عالی
3- طریقه سوییچ کردن از هر زبان برنامه نویسی فرانت یا بک به سمت لاراول
مکان: اسکایپ
زمان: 9 شب به وقت ایران
لینک:جوین: در پایان همین متن.
لطفا دوستان خودتون رو با خبر کنید از لینک های زیر وارد بشوند. بهترین برنامه نویسان ایرانی در جهان در این گروه دور هم جمع شدند و برای انتقال تجربه و سوال و پرسش ظرفیت و نعمت عالی هستش.
تلگرام:تبادل اطلاعات و مباحث و پروژه و نیرو
https://t.me/+FNzFN-h_P4VjZTcy
گروه اسکایپ
اطلاع رسانی های عمومی teamwork :
https://join.skype.com/k92PQjhxlWBL
Backend
https://join.skype.com/INHiAPvaqX23
Frontend
https://join.skype.com/Hw5YaofL8ISh
Architecture -Software
https://join.skype.com/C6jlC32bb0mi
PMP: (Project management)
https://join.skype.com/GWKLGIDIsSc4
میلاد حضرت عیسی مسیح رو به همه یکتاپرستان و مسلمونا و مسیحیان عزیزم تبریک تهنیت عرض میکنم. (heartwitharrow)
(heartwitharrow)
(heartwitharrow)
(heartwitharrow)
(heartwitharrow)
(heartwitharrow)
(heartwitharrow)
(heartwitharrow)
(dizzysymbol)
(bang)
(angersymbol)
پیشاپیش آغاز سال 2022 رو هم تبریک میگم.
Launch Your Streaming Platforms in MinutesRoshan Dwivedi
The claim of launching a streaming platform in minutes might be a bit of an exaggeration, but there are services that can significantly streamline the process. Here's a breakdown:
Pros of Speedy Streaming Platform Launch Services:
No coding required: These services often use drag-and-drop interfaces or pre-built templates, eliminating the need for programming knowledge.
Faster setup: Compared to building from scratch, these platforms can get you up and running much quicker.
All-in-one solutions: Many services offer features like content management systems (CMS), video players, and monetization tools, reducing the need for multiple integrations.
Things to Consider:
Limited customization: These platforms may offer less flexibility in design and functionality compared to custom-built solutions.
Scalability: As your audience grows, you might need to upgrade to a more robust platform or encounter limitations with the "quick launch" option.
Features: Carefully evaluate which features are included and if they meet your specific needs (e.g., live streaming, subscription options).
Examples of Services for Launching Streaming Platforms:
Muvi [muvi com]
Uscreen [usencreen tv]
Alternatives to Consider:
Existing Streaming platforms: Platforms like YouTube or Twitch might be suitable for basic streaming needs, though monetization options might be limited.
Custom Development: While more time-consuming, custom development offers the most control and flexibility for your platform.
Overall, launching a streaming platform in minutes might not be entirely realistic, but these services can significantly speed up the process compared to building from scratch. Carefully consider your needs and budget when choosing the best option for you.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
AI Genie Review: World’s First Open AI WordPress Website CreatorGoogle
AI Genie Review: World’s First Open AI WordPress Website Creator
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-genie-review
AI Genie Review: Key Features
✅Creates Limitless Real-Time Unique Content, auto-publishing Posts, Pages & Images directly from Chat GPT & Open AI on WordPress in any Niche
✅First & Only Google Bard Approved Software That Publishes 100% Original, SEO Friendly Content using Open AI
✅Publish Automated Posts and Pages using AI Genie directly on Your website
✅50 DFY Websites Included Without Adding Any Images, Content Or Doing Anything Yourself
✅Integrated Chat GPT Bot gives Instant Answers on Your Website to Visitors
✅Just Enter the title, and your Content for Pages and Posts will be ready on your website
✅Automatically insert visually appealing images into posts based on keywords and titles.
✅Choose the temperature of the content and control its randomness.
✅Control the length of the content to be generated.
✅Never Worry About Paying Huge Money Monthly To Top Content Creation Platforms
✅100% Easy-to-Use, Newbie-Friendly Technology
✅30-Days Money-Back Guarantee
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIGenieApp #AIGenieBonus #AIGenieBonuses #AIGenieDemo #AIGenieDownload #AIGenieLegit #AIGenieLiveDemo #AIGenieOTO #AIGeniePreview #AIGenieReview #AIGenieReviewandBonus #AIGenieScamorLegit #AIGenieSoftware #AIGenieUpgrades #AIGenieUpsells #HowDoesAlGenie #HowtoBuyAIGenie #HowtoMakeMoneywithAIGenie #MakeMoneyOnline #MakeMoneywithAIGenie
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
Do you want Software for your Business? Visit Deuglo
Deuglo has top Software Developers in India. They are experts in software development and help design and create custom Software solutions.
Deuglo follows seven steps methods for delivering their services to their customers. They called it the Software development life cycle process (SDLC).
Requirement — Collecting the Requirements is the first Phase in the SSLC process.
Feasibility Study — after completing the requirement process they move to the design phase.
Design — in this phase, they start designing the software.
Coding — when designing is completed, the developers start coding for the software.
Testing — in this phase when the coding of the software is done the testing team will start testing.
Installation — after completion of testing, the application opens to the live server and launches!
Maintenance — after completing the software development, customers start using the software.
Transform Your Communication with Cloud-Based IVR SolutionsTheSMSPoint
Discover the power of Cloud-Based IVR Solutions to streamline communication processes. Embrace scalability and cost-efficiency while enhancing customer experiences with features like automated call routing and voice recognition. Accessible from anywhere, these solutions integrate seamlessly with existing systems, providing real-time analytics for continuous improvement. Revolutionize your communication strategy today with Cloud-Based IVR Solutions. Learn more at: https://thesmspoint.com/channel/cloud-telephony
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Łukasz Chruściel
No one wants their application to drag like a car stuck in the slow lane! Yet it’s all too common to encounter bumpy, pothole-filled solutions that slow the speed of any application. Symfony apps are not an exception.
In this talk, I will take you for a spin around the performance racetrack. We’ll explore common pitfalls - those hidden potholes on your application that can cause unexpected slowdowns. Learn how to spot these performance bumps early, and more importantly, how to navigate around them to keep your application running at top speed.
We will focus in particular on tuning your engine at the application level, making the right adjustments to ensure that your system responds like a well-oiled, high-performance race car.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
3. Doug “Crazy Legs” Ervison “Mean” Dr. Iverson
Hi! I’m
Doug
Grrr
The Hero The Villain
I NEED
an A!
Doug?
An A?
HA!
His code
stinks!
4. Doug will demonstrate
1. Good names
2. Small functions
3. Unit tests
4. Refactor code, specifically
1. Extract functions
2. Split loops
5. Opening Scene - The Assignment
https://www.kaggle.com/c/spooky-author-identification/data
Kaggle
is Kool!
Kaggle
assignment!
But Dr. Iverson is
SO mean!
6. Doug’s Original code
(…this assignment
require unit tests!…)
Iverson
loves Bag of
Words!
I am going to
get an A for
sure!
(…F!…)
10. What are unit tests?
• Captures/maintain intended behavior
• Helpful when changing code
• Should be automated
11. Doug writes some unit tests
Original behavior
New behavior
That was
easy!
And my code
passed!
12. Doug’s Original code
(…with names
like that …)
Remembered
the Unit Tests!
I am going to
get an A for
sure!
(…a C at
best…)
13. Luckily, Doug remembers to think about names
Names are
important!
They should
express
intent!
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?
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
33. … and extracts a function
Now extract
a function
and replace
blocks with a call
Tests pass,
But isn’t this
inefficient?
34. What did Iverson say about efficiency?
97% of your code
doesn’t impact overall
speed
Optimize the other
3% … after profiling
Blah blah …
Donald Knuth
… Blah blah
35. 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.
- Donald Knuth
Iverson is always
talking about Knuth
What a fanboy!
(…he’s not wrong …)
44. What are unit tests?
• Captures/maintain intended behavior
• Helpful when changing code
• Should be automated
45. 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?
46. 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
47. Refactoring
What is it?
• Reorganize your code
• Break it into different
parts
• Change composition
Why use it?
• Understand the code
• Clean the code
• Allow new features
50. The DRY principle
• Don’t repeat yourself!
• Find similar code
• Make it exactly the same
• Extract a function!
51. Advice for teaching clean code
• Require unit tests and good names.
• Don’t just teach it, live it!
• Allow students to see you clean your messy code.
• Teach/reinforce important concepts.
• DRY
• Refactoring
• Efficiency concerns and profiling
• Projects that require 100’s of lines of code.
52. Clean Code Resources
• These slides: https://bit.ly/2WgFIb
• Clean Code, by Robert Martin
• www.cleancoders.com, videos by Robert Martin
and friends
• Refactoring Code, by Martin Fowler
Editor's Notes
(click) The hero of our drama, Doug Ervison, budding data science major with a penchant to messy code .
(click) The villain in this drama is the mean Dr. Iverson, who always complains about Doug’s code. He sometimes even says it stinks.
Over the last few years, I have been doing some research on software engineering techniques that will help our students. In this talk I will highlight a few; namely picking good names, using small functions that do one thing, using unit tests to ensure our code is correct, and refactoring our code to make it more modular and readable.
But more importantly, this talk tells the story of Doug.
Doug has a problem.
(click) He was assigned a Kaggle assignment for class and he thinks he has a nice solution, but he knows that Dr. Iverson is going to dock points for messy code.
Doug solution is based on the word distributions of each author.
(click)Surely this solution will get Doug that elusive A.
(click)Unfortunately, Doug forgot to look over the requirements for the assignment, which included unit tests for all functions.
It looks like our hero is doomed
to an F!
Then just in the nick of time …
Doug recalls this assignment requires unit tests. What was it that Iverson said in class about unit test?
Doug looks back at his notes. So tests should be automated and capture the behavior of the code.
Ok, unit tests. First, he makes some examples data and the intended output.
(click) Then write an automated test that checks that his main function works.
(click)
(click) Finally, run the test and make sure the original function passes.
Initially, Doug is happy with this code.
(click) Surely this solution will get Doug that elusive A.
(click) but then he remembers losing points for poor names on previous assignments
He thinks back to a lecture on picking good names, remembering that names should express the intent of your code.
Doug looks over his nores.
(click) So data should say what it is
(click) and functions should say what they do.
Doug notices that next slide talks about using the correct parts of speech.
(click) variables are nouns
(click) functions verbs
(click) and something about Booleans.
Doug looks over his names. What would Iverson say?
He definitely wouldn’t like ews and hws. He decides to use new names that use the authors last names.
Doug continues to change names, replaces the name for each variable, trying to better capture the indent of the code.
(click) He is now confident in getting an A!
(click) Unfortunately, there is a bug in his code, and Iverson gives code that crashes a D.
It looks like our hero is doomed with D!
Then just in the nick of time …
Doug remembers to test.
(click) the code fails the test
(click) and he figures out that he forgot to change to “a”s to “author”
(click) he fixes the problem
(click) and verifies the code passes his tests.
That was close. So what other changes should he make?
He remembers that Iverson likes programs with many small functions.
(click) and he has one large function.
This reminds him of one of his favorite lectures on extracting functions.
He looks over his notes on extracting functions.
(click) so he should find a block that does something
(click) extract the code into a function with a good name
(click) and replace the original block with a function call.
He also sees that this technique is related to the DRY principle. Whatever!
Doug looks at his code, looking for blocks that do something.
(click) He finds some code that replaces hyphens with a space,
(click) so he extracts that code to a function called replace_hythen and
(click) replaces the original code with a function call.
(click) Doug has learned his lesson after almost forgetting to test his name changes. He runs his unit test. They pass.
(click) He also find some code that removes punctuation, and extracts a functions for that as well. Again his code passes the unit tests.
(click) Turns out Doug likes to refactor.
This is fun! Doug decides to extract another function.
(click) This part cleans and splits each block of text.
He extracts this function as well and reruns the tests.
(click)
(click)
(click)
Doug really does like to refactor
(click)
What other refactoring can he do?
(click) Remembers that nesting is a sign that a function does to much.
(click) and that he should look for repeated blocks of code
He remembers something from class about refactoring a loop that does more than one thing.
Doug looks over his notes on splitting a loop.
(click) you find a loop that does more than one thing
(click) then split it into multiple loops that each do one thing.
Doug applies this technique
(click) changing the if/else to separate if statements
(click) and replacing a temporary variable with separate queires.
Then he splits the 1 loop into 3 loops.
(click) one for each author.
Now he can extract a loop into a function.
(click)
And replace each loop with function call
(click)
Now that he’s done it, splitting the loop just feels wrong. His old code only passed over the data one time, while the new code scans the data three times. Isn’t this needlessly inefficient?
Doug thinks back to what Iverson said in class on efficiency. So not all parts of your code really matter, and you won’t know which parts matter until after you run your code. He also remembers that Iverson went on-and-on about some guy named Knuth.
Doug finds that Knuth guy’s quote in his notes. Hmm, “root of all evil”? That IS strong language. Ok, so maybe he shouldn’t worry so much about efficiency until he sees that his code is slow.
Doug looks over his code one more time. Everything looks good and he has to admit that it is clean and easier to read.
Doug’s code is demonstrably better
He clearly took Iverson’s clean code lectures to heart
And his code consists of small functions with good names
He clearly likes to refactor
He clearly likes to refactor
Unfortunately you will have to tune in next week to find out
Doug looks back at his notes. So tests should be automated and capture the behavior of the code.
Doug looks over his nores.
(click) So data should say what it is
(click) and functions should say what they do.
Doug notices that next slide talks about using the correct parts of speech.
(click) variables are nouns
(click) functions verbs
(click) and something about Booleans.
He looks over his notes on extracting functions.
(click) so he should find a block that does something
(click) extract the code into a function with a good name
(click) and replace the original block with a function call.
Doug looks over his notes on splitting a loop.
(click) you find a loop that does more than one thing
(click) then split it into multiple loops that each do one thing.
He also sees that this technique is related to the DRY principle. Whatever!