Deep Dive Python: Techniques and Best Practices for Developers

Deep Dive Python: Techniques and Best Practices for Developers

Deep Dive Python: Techniques and Best Practices for Developers
Автор: Divakaran Adarsh
Дата выхода: 2025
Издательство: Apress Media, LLC.
Количество страниц: 769
Размер файла: 2.7 MB
Тип файла: PDF
Добавил: Федоров_АИ
 Проверить на вирусы

Contents

Introduction

Section 1: Auditing

What's Covered?

Planning Your Auditing Strategy

Getting Into the Right Mindset

Recording Your Findings

Automated Tooling

PHP Insights

Enlightn

Larastan

Style CI

Code Coverage

Manual Auditing

Investigating "raw" Database Queries

Finding Incorrect Authorisation

Checking Validation

Finding "Fake Facades"

Finding Business Logic in Helpers

Finding N+1 Queries

Finding Controllers That Use Other Controllers

Finding Logic and Queries in Blade Views

Finding Hard-Coded Credentials

Check Open Package Routes

Reviewing Project Documentation

Section 2: Testing

What's Covered?

Planning Your Testing Strategy

The Benefits of Writing Tests

Spotting Bugs Early

Making Future Work and Refactoring Easier

Changing the Way You Approach Writing Code

Tests-As-Documentation

Prove That Bugs Exist

Structuring Your Tests

Directory Structure

Choosing What To Test

Test Structure

Data Providers

Writing the Tests

Prioritising Mission-Critical Tests First

Writing the Rest of the Tests

Benefits of Writing the Easy Tests First

Preventing Test Fatigue

Testing Your UI with Laravel Dusk

Installation

Testing a Simple Form

Dusk Pages and Selectors

Running Failed Tests and Groups

Creating a CI Workflow Using GitHub Actions

Using an .env.ci File

Running the Test Suite

Larastan

Laravel Dusk

Output

Section 3: Fixing

What's Covered?

Planning Your Fixing Strategy

Using an Error Reporting System

Types of Errors

The Benefits of an Automated Error Reporting System

Error Reporting Using Flare

Uptime Checking, Queue Monitoring, and Scheduler Monitoring

Uptime Monitoring with Oh Dear

Scheduler Monitoring with Oh Dear

Queue Monitoring with Oh Dear

Updating PHP, Laravel, and Packages

Upgrading in Small Increments

Automating the Upgrade Using Laravel Shift

Planning Upgrades Early

Using a Suitable Local Development Environment

Using Tests to Fix Bugs

What is Test-Driven Development?

The Advantages of Test-Driven Development

The Disadvantages of Test-Driven Development

Fixing a Real Bug Using Test-Driven Development

Safely Removing Dead Code

Checking the Version Control History

Scream Test

Logging or Reporting the Usage

Removing the Code with an Atomic Commit

Section 4: Improving

What's Covered?

Planning Your Improvement Strategy

Making the Most of PHP's Type System

Using Type Hints and Return Types

Union Types

Type Hints and Return Types in Closures

DRYing Up Your Code

Advantages of DRYing Up Your Code

When to DRY Up Your Code

Refactoring Conditions

Reducing Indented Code

Replacing if and elseif with match

Using the Nullsafe Operator

Using Database Transactions

Adding the Database Transactions

Manually Using Database Transactions

Tips for Interacting with Third-Party Services

Using Automatic or Manual Transactions

Dispatching Queued Jobs inside Database Transactions

Improving the Testability of Your Code

Using Objects Over Arrays

Final Words

Discount Codes

Flare

Oh Dear

StyleCI

Laravel Security In Depth

Take your programming skills to the next level by expanding real-world Python applications in open-source code. This book is an essential guide for experienced developers looking to enhance their Python proficiency.

Using code examples from popular open-source projects you’ll master Python concepts and see how they are applied in production-level code. By understanding code from established projects, you’ll develop a deeper appreciation for Python’s capabilities and learn best practices that have been battle-tested in the real world. You’ll gain the confidence to tackle complex projects, optimize your code, and implement advanced Python features effectively.

You’ll also examine typing, generators, iterators, the itertools module, multithreading, multiprocessing, and asyncio. This will equip you to build production-ready Python programs and libraries. Whether you’re building large-scale applications, contributing to open-source projects, or solving intricate programming challenges, Deep Dive Python will provide you with the knowledge and practical experience to excel in your Python development journey.

What You Will Learn

  • Master Python's core data structures and how to use them effectively.

  • Implement decorators, descriptors, metaclasses, and abstract base classes in your code

  • Enhance your code with functional programming techniques using the functools module

  • Improve iteration with generators, iterators, and the itertools module

  • Select the best Python concurrent programming models to use for optimal performance

  • Apply best practices for code organization, packaging, and creating maintainable Python projects

Who This Book Is For

Experienced Python developers who want to expand their programming skils


Похожее:

Список отзывов:

Нет отзывов к книге.