Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Software Architecture with Python

You're reading from   Software Architecture with Python Design and architect highly scalable, robust, clean, and high performance applications in Python

Arrow left icon
Product type Paperback
Published in Apr 2017
Publisher Packt
ISBN-13 9781786468529
Length 556 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
 Balachandran Pillai Balachandran Pillai
Author Profile Icon Balachandran Pillai
Balachandran Pillai
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Software Architecture with Python
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Principles of Software Architecture FREE CHAPTER 2. Writing Modifiable and Readable Code 3. Testability – Writing Testable Code 4. Good Performance is Rewarding! 5. Writing Applications That Scale 6. Security – Writing Secure Code 7. Design Patterns in Python 8. Python – Architectural Patterns 9. Deploying Python Applications 10. Techniques for Debugging Index

Refactoring Code


Now that we have seen how static tools can be used to report a wide range of errors and issues in our Python code, let us do a simple exercise of refactoring our code. We will take our poorly written metric test module as the use case (the first version of it), and perform a few refactoring steps.

Here are the rough guidelines we will follow when doing the refactoring:

  1. Fix complex code first: This will get a lot of code out of the way, as typically, when a complex piece of code is refactored, we end up reducing the number of lines of code. This overall improves the code quality, and reduces code smells. You may be creating new functions or classes here, so it always helps to perform this step first.

  2. Do an analysis of the code now: It is a good idea to run the complexity checkers at this step, and see how the overall complexity of the code—class/module or functions—has been reduced. If not, iterate again.

  3. Fix code smells next: Fix any issue with code smells—class, function...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images