Software Architecture with Python
eBook - ePub

Software Architecture with Python

Anand Balachandran Pillai

Share book
  1. 556 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Software Architecture with Python

Anand Balachandran Pillai

Book details
Book preview
Table of contents
Citations

About This Book

Architect and design highly scalable, robust, clean, and highly performant applications in PythonAbout This Bookโ€ข Identify design issues and make the necessary adjustments to achieve improved performanceโ€ข Understand practical architectural quality attributes from the perspective of a practicing engineer and architect using Pythonโ€ข Gain knowledge of architectural principles and how they can be used to provide accountability and rationale for architectural decisionsWho This Book Is ForThis book is for experienced Python developers who are aspiring to become the architects of enterprise-grade applications or software architects who would like to leverage Python to create effective blueprints of applications.What You Will Learnโ€ข Build programs with the right architectural attributesโ€ข Use Enterprise Architectural Patterns to solve scalable problems on the Webโ€ข Understand design patterns from a Python perspectiveโ€ข Optimize the performance testing tools in Pythonโ€ข Deploy code in remote environments or on the Cloud using Pythonโ€ข Secure architecture applications in PythonIn DetailThis book starts off by explaining how Python fits into an application architecture. As you move along, you will understand the architecturally significant demands and how to determine them. Later, you'll get a complete understanding of the different architectural quality requirements that help an architect to build a product that satisfies business needs, such as maintainability/reusability, testability, scalability, performance, usability, and security.You will use various techniques such as incorporating DevOps, Continuous Integration, and more to make your application robust. You will understand when and when not to use object orientation in your applications. You will be able to think of the future and design applications that can scale proportionally to the growing business.The focus is on building the business logic based on the business process documentation and which frameworks are to be used when. We also cover some important patterns that are to be taken into account while solving design problems as well as those in relatively new domains such as the Cloud.This book will help you understand the ins and outs of Python so that you can make those critical design decisions that not just live up to but also surpass the expectations of your clients.Style and approachFilled with examples and use cases, this guide takes a no-nonsense approach to help you with everything it takes to become a successful software architect.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on โ€œCancel Subscriptionโ€ - itโ€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youโ€™ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoโ€™s features. The only differences are the price and subscription period: With the annual plan youโ€™ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weโ€™ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Software Architecture with Python an online PDF/ePUB?
Yes, you can access Software Architecture with Python by Anand Balachandran Pillai in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Python. We have over one million books available in our catalogue for you to explore.

Information

Year
2017
ISBN
9781786467225
Edition
1

Software Architecture with Python


Table of Contents

Software Architecture with Python
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Principles of Software Architecture
Defining Software Architecture
Software Architecture versus design
Aspects of Software Architecture
Characteristics of Software Architecture
An architecture defines a structure
An architecture picks a core set of elements
An architecture captures early design decisions
An architecture manages stakeholder requirements
An architecture influences the organizational structure
An architecture is influenced by its environment
An architecture documents the system
An architecture often conforms to a pattern
Importance of Software Architecture
System versus enterprise architecture
Architectural quality attributes
Modifiability
Testability
Scalability
Performance
Availability
Security
Deployability
Summary
2. Writing Modifiable and Readable Code
What is modifiability?
Aspects related to Modifiability
Understanding readability
Python and readability
Readability - antipatterns
Techniques for readability
Document your code
Follow coding and style guidelines
Review and refactor code
Commenting the code
Fundamentals of Modifiability โ€“ Cohesion & Coupling
Measuring cohesion and coupling
Measuring cohesion and coupling โ€“ string and text processing
Exploring strategies for modifiability
Providing explicit interfaces
Reducing two-way dependencies
Abstract common services
Using inheritance techniques
Using late binding techniques
Metrics โ€“ tools for static analysis
What are code smells?
Cyclomatic complexity โ€“ the McCabe metric
Testing for metrics
Running Static Checkers
Refactoring Code
Refactoring code โ€“ fixing complexity
Refactoring code - fixing code smells
Refactoring code - fixing styling and coding issues
Summary
3. Testability โ€“ Writing Testable Code
Understanding testability
Software testability and related attributes
Testability โ€“ architectural aspects
Testability โ€“ strategies
Reduce system complexity
Improving predictability
Control and isolate external dependencies
White-box testing principles
Unit testing
Unit testing in action
Extending our unit test case
Nosing around with nose2
Testing with py.test
Code coverage
Measuring coverage using coverage.py
Measuring coverage using nose2
Measuring coverage using py.test
Mocking things up
Tests inline in documentation โ€“ doctests
Integration tests
Test automation
Test automation using Selenium Web Driver
Test-Driven Development
TDD with palindromes
Summary
4. Good Performance is Rewarding!
What is performance?
Software performance engineering
Performance testing and measurement tools
Performance complexity
Measuring performance
Measuring time using a context manager
Timing code using the timeit module
Measuring the performance of our code using timeit
Finding out time complexity โ€“ graphs
Measuring CPU time with timeit
Profiling
Deterministic profiling
Profiling with cProfile and profile
Prime number iterator class โ€“ performance tweaks
Profiling โ€“ collecting and reporting statistics
Third-party profilers
Line profiler
Memory profiler
Substring (subsequence) problem
Other tools
Objgraph
Pympler
Programming for performance โ€“ data structures
Mutable containers โ€“ lists, dictionaries, and sets
Lists
Dictionaries
Sets
Immutable containers โ€“ tuples
High performance containers โ€“ the collections module
deque
defaultdict
OrderedDict
Dropping duplicates from a container without losing the order
Implementing a Least Recently Used (LRU) cache dictionary
Counter
ChainMap
namedtuple
Probabilistic data structures โ€“ bloom filters
Summary
5. Writing Applications That Scale
Scalability and performance
Concurrency
Concurrency versus parallelism
Concurrency in Python โ€“ multithreading
Thumbnail generator
Thumbnail generator โ€“ producer/consumer architecture
Thumbnail generator โ€“ resource constraint using locks
Thumbnail generator โ€“ resource constraint using semaphores
Resource constraint โ€“ semaphore versus lock
Thumbnail generator โ€“ URL rate controller using conditions
Multithreading โ€“ Python and GIL
Concurrency in Python โ€“ multiprocessing
A primality checker
Sorting disk files
Sorting disk files โ€“ using a counter
Sorting disk files โ€“ using multiprocessing
Multithreading versus multiprocessing
Concurrecy in Python - Asynchronous Execution
Pre-emptive versus cooperative multitasking
The asyncio module in Python
Waiting for a future โ€“ async and await
Concurrent futures โ€“ high-level concurrent processing
Disk thumbnail generator
Concurrency options โ€“ how to choose?
Parallel processing libraries
Joblib
PyMP
Fractals โ€“ the Mandelbrot set
Fractals โ€“ Scaling the Mandelbrot set implementation
Scaling for the Web
Scaling workflows โ€“ message queues and task queues
Celery โ€“ a distributed task queue
The Mandelbrot set using Celery
Serving with Python on the Webโ€”WSGI
uWSGI โ€“ WSGI middleware on steroids
Gunicorn โ€“ unicorn for WSGI
Gunicorn versus uWSGI
Scalability architectures
Vertical scalability architectures
Horizontal scalability architectures
Summary
6. Security โ€“ Writing Secure Code
Information Security architecture
Secure coding
Common security vulnerabilities
Is Python secure?
Reading input
Evaluating arbitrary input
Overflow errors
Serializing objects
Security issues with web applications
Server Side Template Injection
Server-Side Template Injection โ€“ mitigation
Denial of Service
Cross-Site Scripting(XSS)
Mitigation โ€“ DoS and XSS
Strategies for security โ€“ Python
Secure coding strategies
Summary
7. Design Patterns in Python
Design patterns - Elements
Categories of design patterns
Pluggable hashing algorithms
Summing up pluggable hashing algorithm
Patterns in Python โ€“ Creational
The Singleton pattern
The Singleton โ€“ do we need a Singleton?
State sharing โ€“ Borg versus Singleton
The Factory pattern
The Prototype pattern
Prototype โ€“ deep versus shallow copy
Prototype using metaclasses
Combining patterns using metaclasses
The Prototype factory
The Builder pattern
Patterns in Python โ€“ Structural
The Adapter pattern
The Facade pattern
Facades in Python
The Proxy pattern
An instance-counting proxy
Patterns in Python โ€“ Behavioral
The Iterator pattern
The Observer pattern
The State pattern
Summary
8. Python โ€“ Architectural Patterns
Introducing MVC
Model Template View (MTV) โ€“ Django
Django admin โ€“ automated model-centric views
Flexible Microframework โ€“ Flask
Event-driven programming
Chat server and client using I/O multiplexing with the select module
Event-drive...

Table of contents