Practices of the Python Pro

Practices of the Python Pro

by Dane Hillard
Practices of the Python Pro

Practices of the Python Pro

by Dane Hillard

Paperback(1st Edition)

$39.99 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores

Related collections and offers


Overview

Professional developers know the many benefits of writing application code that’s clean, well-organized, and easy to maintain. By learning and following established patterns and best practices, you can take your code and your career to a new level.
With Practices of the Python Pro, you’ll learn to design professional-level, clean, easily maintainable software at scale using the incredibly popular programming language, Python. You’ll find easy-to-grok examples that use pseudocode and Python to introduce software development best practices, along with dozens of instantly useful techniques that will help you code like a pro.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.



Professional-quality code does more than just run without bugs. It’s clean, readable, and easy to maintain. To step up from a capable Python coder to a professional developer, you need to learn industry standards for coding style, application design, and development process. That’s where this book is indispensable.



Practices of the Python Pro teaches you to design and write professional-quality software that’s understandable, maintainable, and extensible. Dane Hillard is a Python pro who has helped many dozens of developers make this step, and he knows what it takes. With helpful examples and exercises, he teaches you when, why, and how to modularize your code, how to improve quality by reducing complexity, and much more. Embrace these core principles, and your code will become easier for you and others to read, maintain, and reuse.




  • Organizing large Python projects
  • Achieving the right levels of abstraction
  • Writing clean, reusable code Inheritance and composition
  • Considerations for testing and performance





For readers familiar with the basics of Python, or another OO language.



Dane Hillard has spent the majority of his development career using Python to build web applications.



Table of Contents:

PART 1 WHY IT ALL MATTERS

1 ¦ The bigger picture

PART 2 FOUNDATIONS OF DESIGN

2 ¦ Separation of concerns

3 ¦ Abstraction and encapsulation

4 ¦ Designing for high performance

5 ¦ Testing your software

PART 3 NAILING DOWN LARGE SYSTEMS

6 ¦ Separation of concerns in practice

7 ¦ Extensibility and flexibility

8 ¦ The rules (and exceptions) of inheritance

9 ¦ Keeping things lightweight

10 ¦ Achieving loose coupling

PART 4 WHAT’S NEXT?

11 ¦ Onward and upward

Product Details

ISBN-13: 9781617296086
Publisher: Manning
Publication date: 01/14/2020
Edition description: 1st Edition
Pages: 248
Sales rank: 1,108,531
Product dimensions: 7.10(w) x 9.10(h) x 0.60(d)

About the Author

Dane Hillard has spent the majority of his development career using Python to build web applications.

Table of Contents

Preface xiii

Acknowledgments xv

About this book xvii

About the author xxi

About the cover illustration xxii

Part 1 Why It All Matters 1

1 The bigger picture 3

1.1 Python is an enterprise language 4

The times they are a-changin' 5

What I like about Python 5

1.2 Python is a teaching language 5

1.3 Design is a process 6

The user experience 7

You've been here before 8

1.4 Design enables better software 8

Considerations in software design 9

Organically grown software 10

1.5 When to invest in design 11

1.6 New beginnings 12

1.7 Design is democratic 12

Presence of mind 13

1.8 How to use this book 15

Part 2 Foundations of Design 17

2 Separation of concerns 19

2.1 Namespacing 20

Namespaces and the import statement 20

The many masks of importing 23

Namespaces prevent collisions 24

2.2 The hierarchy of separation in Python 25

Functions 26

Classes 32

Modules 37

Packages 37

3 Abstraction and encapsulation 41

3.1 What is abstraction? 42

The "black box" 42

Abstraction is like an onion 43

Abstraction is a simplifier 45

Decomposition enables abstraction 46

3.2 Encapsulation 47

Encapsulation constructs in Python 47

Expectations of privacy in Python 48

3.3 Try it out 48

Refactoring 50

3.4 Programming styles are an abstraction too 51

Procedural programming 51

Functional programming 51

Declarative programming 53

3.5 Typing, inheritance, and polymorphism 54

3.6 Recognizing the wrong abstraction 56

Square pegs in round holes 56

Clever gets the cleaver 57

4 Designing for high performance 58

4.1 Hurtling through time and space 59

Complexity is a little … complex 59

Time complexity 60

Space complexity 63

4.2 Performance and data types 64

Data types for constant time 64

Data types for linear time 65

Space complexity of operations on data types 65

4.3 Make it work, make it right, make it fast 68

Making it work 68

Making it right 68

Making it fast 71

4.4 Tools 72

Timeit 72

CPU profiling 73

4.5 Try it out 75

5 Testing your software 77

5.1 What is software testing? 78

Does it do what it says on the tin? 78

The anatomy of a functional test 78

5.2 Functional testing approaches 79

Manual testing 80

Automated testing 80

Acceptance testing 80

Unit testing 82

Integration testing 83

The testing pyramid 84

Regression testing 85

5.3 Statements of fact 86

5.4 Unit testing with unittest 86

Test organization with unittest 86

Running tests with unittest 87

Writing your first test with unittest 87

Writing your first integration test with unittest 90

Test doubles 92

Try it out 93

Writing interesting tests 96

5.5 Testing with pytest 96

Test organization with pytest 97

Converting unittest tests to pytest 97

5.6 Beyond functional testing 98

Performance testing 98

Load testing 99

5.7 Test-driven development: A primer 99

It's a mindset 100

It's a philosophy 100

Part 3 Nailing Down Large Systems 101

6 Separation of concerns in practice 103

6.1 A command-line bookmarking application 104

6.2 A tour of Bark 105

The benefits of separation: Reprise 105

6.3 An initial code structure, by concern 106

The persistence layer 107

The business logic layer 115

The presentation layer 119

7 Extensibility and flexibility 127

7.1 What is extensible code? 127

Adding new behaviors 128

Modifying existing behaviors 130

Loose coupling 131

7.2 Solutions for rigidity 133

Letting go: Inversion of control 133

The devil's in the details: Relying on interfaces 136

Fighting entropy: The robustness principle 137

7.3 An exercise in extension 138

8 The rules (and exceptions) of inheritance 143

8.1 The inheritance of programming past 143

The silver bullet 144

The challenges of hierarchies 144

8.2 The inheritance of programming present 146

What is inheritance for, really? 146

Substitutability 147

The ideal use case for inheritance 148

8.3 Inheritance in Python 150

Type inspection 150

Superclass access 151

Multiple inheritance and method resolution order 152

Abstract base classes 155

8.4 Inheritance and composition in Bark 157

Refactoring to use an abstract base class 157

A final check on your inheritance work 159

9 Keeping things lightweight 160

9.1 How big should my class/function/module be? 161

Physical size 161

Single responsibility 161

Code complexity 162

9.2 Breaking down complexity 166

Extracting configuration 166

Extracting functions 168

9.3 Decomposing classes 170

Initialization complexity 171

Extracting classes and forwarding calls 173

10 Achieving loose coupling 177

10.1 Defining coupling 177

The connective tissue 178

Tight coupling 178

Loose coupling 181

10.2 Recognizing coupling 184

Feature envy 184

Shotgun surgery 184

Leaky abstractions 185

10.3 Coupling in Bark 186

10.4 Addressing coupling 188

User messaging 189

Bookmark persistence 191

Try it out 192

Part 4 What's Next? 197

11 Onward and upward 199

11.1 What now? 199

Develop a plan 200

Execute the plan 201

Track your progress 203

11.2 Design patterns 204

Ups and downs of design patterns in Python 206

Terms to start with 206

11.3 Distributed systems 206

Modes of failure in distributed systems 207

Addressing application state 208

Terms to start with 208

11.4 Take a Python deep dive 208

Python code style 208

Language features are patterns 209

Terms to start with 210

11.5 Where you've been 210

There and back again: A developer's tale 210

Signing off 212

Appendix Installing Python 213

Index 217

From the B&N Reads Blog

Customer Reviews