Mais conteúdo relacionado Semelhante a How To Think Like A Programmer (20) How To Think Like A Programmer2. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
How To Think
Like A Programmer
KASSANDRA KEETON, Passionate Pythonista @ Cisco
3. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Today’s Intention
To provide you with tools & techniques to
minimize frustration, required time to code,
and code refactoring needs while
inviting opportunities for collaboration.
4. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
What We Will Cover Today
• Mini Background About Me
• Why You Made A Wise Decision To Be Here
• What To Consider Before Writing Code
• Process For A “Bare Bones” Script
• Additional Resources
• Example Walkthrough:
Rock Paper Scissors Game
• Recap
5. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
About Me
• May 2008 – Bachelors of Science
(Computer Science) @ TCU
• Jan 2014 – Cisco CUCM TAC
• June 2016 – Collaboration Scripting
Augmentation Lead
• Case Backlog Management Tool
• Global Bi-Weekly Coding Hour
• Trained TAC COL Engineers In Python
• Data Science & Analytics For Metrics
6. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Why You Made A Wise Decision To Be Here
• Python is the language of tech future (HOT job market)
• Being able to automate the boring has many benefits:
• Minimizes human error
• Provides opportunity to expand abilities & do more with less
• Frees up your time to focus on more important matters
• Enables you to beef up your resume
• Consistent uniform standards improve readability and code maintenance
7. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Why You Made A Wise
Decision To Be Here
• Habit (settled tendency or practice)
• Skill (ability to do something well)
“Repetition is the mother of skill.”
- Tony Robbins
*original signer of the Agile Manifesto &
creator of the Extreme Programming series
8. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Bad VS Good Habits
BAD HABITS
• Not cleaning up your code
• Not being “modular”
• Not leaving “breadcrumbs”
GOOD HABITS
• Clear, concise code
• Comments for additional clarification
• Following style and coding guidelines
9. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
What To Consider
Before Writing Code
• Have you ever been frustrated
because a program didn’t work
in your best interest?
• Ever had code crash for
no apparent reason?
• Who is your target audience?
• What is it they are ultimately
looking for?
• How will their experience
be affected by your code?
10. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
What To Consider
Before Writing Code
• What is your timeframe
and required milestones?
• How can you break it down?
• How can you provide opportunities
for collaboration?
• Who will come behind you?
• How to make it future proof?
• How to make code minimalistic?
11. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Why “Bare Bones”?
• Every big idea or structure
starts with a blueprint
• Lack of vision could lead to
missed deadlines & “death” of projects
• Easier troubleshooting
• Collaboration opportunities
• Code more flexible &
easier to navigate
• Efficiently fix bugs faster
12. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
What Is The
“Bare Bones” Process?
13. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
The “Bare Bones” Process:
1. Gather Requirements
14. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1 - Requirements
• Overall intention
• Time constraints
• Immediate iterable deliverables
• Need vs Nice-To-Have
• Additional resources required
• Part of something bigger?
• How often will you meet with
programmers? With BU?
• What’s the user experience look like?
15. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1. Gather Requirements
2. Determine All Required Functions
The “Bare Bones” Process:
16. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
2 - Determine All Required Functions
• What can be reused later by other programs?
• What might be reused later by this program?
• Breakup into smaller functions (15 lines per function is pythonic)
• Create space for the nice-to-haves
• Think each section through and what it would take to complete
17. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
2 - Determine All Required Functions
Nice To Have
• What can be reused later by other programs?
• What might be reused later by this program?
• Breakup into smaller functions (15 lines per function is pythonic)
• Create space for the nice-to-haves
• Think each section through and what it would take to complete
18. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1. Gather Requirements
2. Determine All Required Functions
3. Create “Bare Bones” Infrastructure
Part 1: Create Function Outlines
The “Bare Bones” Process:
19. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1. Gather Requirements
2. Determine All Required Functions
3. Create “Bare Bones” Infrastructure
Part 1: Create Function Outlines
4. Create “Bare Bones” Infrastructure
Part 2: Tie Functions Into __main__
The “Bare Bones” Process:
20. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1. Gather Requirements
2. Determine All Required Functions
3. Create “Bare Bones” Infrastructure
Part 1: Create Function Outlines
4. Create “Bare Bones” Infrastructure
Part 2: Tie Functions Into __main__
5. Create “Bare Bones” Infrastructure
Part 3: Test The Logic
The “Bare Bones” Process:
21. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
1. Gather Requirements
2. Determine All Required Functions
3. Create “Bare Bones” Infrastructure
Part 1: Create Function Outlines
4. Create “Bare Bones” Infrastructure
Part 2: Tie Functions Into __main__
5. Create “Bare Bones” Infrastructure
Part 3: Test The Logic
6. Assign Functions To Team
The “Bare Bones” Process:
22. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Additional Resources
• Utilize Pylint (OpenSource on GitHub) for static code analysis to:
• Enforce coding standards
• Look for programming errors
• Ability to extend this for your own needs (more advanced)
• Utilize pytest (OpenSource on GitHub) to help you write better programs using testing
• Full code & additional information for this speech: http://bit.ly/CiscoLive-HTLAP
23. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
24. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
EXAMPLE:
Rock, Paper, Scissors Game
25. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 1: Requirements
The business unit has requested that you make a
rock, paper, scissors game that employees' kids
can play when they visit their parents.
And they want it done in a month.
26. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 1: Requirements / Features
• At least 1 player and 1 computer
• Some number of combinations for a tie and winner
• At minimum 3 choices per player
• Some way to know the winner
27. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 1: Requirements / Features
• At least 1 player and 1 computer
• Some number of combinations for a tie and winner
• At minimum 3 choices per player
• Some way to know the winner
Nice To Have
28. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
29. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 2:
Determine All
Required Functions
30. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 3:
Create Function
Outlines
31. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 4:
Tie Into
__main__
32. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Quick tip:
update
documentation
as you go
33. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
STEP 5:
Test it!
34. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
35. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
What We Covered Today
• Mini Background About Me
• Why You Made A Wise Decision To Be Here
• What To Consider Before Writing Any Code
• Process For A “Bare Bones” Script
• Additional Resources
• Example Walkthrough:
Rock Paper Scissors Game
36. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
How To Think
Like A Programmer
KASSANDRA KEETON, Passionate Pythonista @ Cisco
37. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
How To Contact
kkeeton@cisco.com
prosperousheart
kkeeton
http://bit.ly/CiscoLive-HTLAP