Code Better in Delphi
Code Better in Delphi
The practice of writing maintainable, reliable, and scalable code in Delphi.
About the Book
It’s back, it’s bigger, it’s better, it’s the sequel to Alsiter Christie's previous book, it’s Code Better in Delphi.
After my last book, you can write code much faster, but without the skills to write code better, you might just end up being a highly efficient spaghetti coding machine. So stop writing that tightly coupled singleton full of duplicated code, and start reading this book.
This time, rather than looking at how fast and productive you can be, we look at quality and maintainability.
In this book, you’ll be introduced to a variety of ways you can make your code better
- How DRY is that code you just wrote?
- Is that class SOLID or crumblier than a very crumbly cookie?
- Will Refactoring improve the quality of your code?
- Are you reinventing the wheel, or should you use try Patterns?
- Will testing drive you mad?
- Are your bugs buggier than a giraffe stage beetle?
- Do you have a handle on those dependencies?
- Are your versions under control?
- What to do before disaster strikes or the zombie horde arrives?
- Are you Agile, or are you about to go over a waterfall?
- How do you calculate the Bus number for your project?
Find out the answer to these and many more questions in this book.
But wait, there’s more…
Plugins and Tools that
- Find areas of your code that might need improving.
- Tell you about Complex areas of code you can simplify.
- Where you are making common coding mistakes.
- Help remove redundancy and orphaned code.
- Let you know when code is leaker than a knitted canoe.
- Automate your testing
Table of Contents
- Copyright
- Table of Contents
- Dedication
- Foreword
- Preface
- Acknowledgements
- Introduction
- Conventions Used in this Book
- Scope
- More Information
- Code Samples
- Sections in this Book
- begin
- Make Code Maintainable
- The Enterprise Development Merry-Go-Round
- Write Code for Maintainability
- Write Code for Scalability
- Write Code for Reliability
- PART ONE - CODE
- Small Coding Tips
- Evil Comments
- Don’t Leave Commented-Out Code in Your Application
- Make Your Code More Stylish
- Let CTRL+D Be Your Friend
- Use a Good Naming Convention
- Stop Prefixing Variables with Their Type
- Variables are Nouns, Methods Verbs
- Parameters
- Parameter Overload
- Parameter Sets
- By Reference or By Value
- Side Effects
- Method Length - Size Really IS Important
- Ditch With
- FreeAndNil
- Global State
- Inject Your Dependencies
- Further Learning
- DRY Your Code
- When Not to DRY Your Code
- WET Code
- Use SOLID Code
- Single Responsibility
- Open-Closed
- Liskov Substitution
- Interface Segregation
- Dependency Inversion
- Further Learning
- Use the Law of Demeter
- Refactoring
- What is “refactoring”?
- Malodourous Source
- Further Learning
- Specific Refactorings
- Re-ordering Statements
- Rename Refactoring
- Automated Refactorings
- Extract Method
- Extract Method Object
- Split With
- Introduce Explaining Variable
- Summary
- Further Learning
- Design Patterns
- The Observer Pattern
- Anti-Patterns
- Redundant Code
- Language Features
- Bad Exception Blocks
- Use Guard Clauses Properly
- Premature Optimisation
- Architecture
- Further Learning
- PART TWO - THE RIGHT TOOL
- The Delphi IDE
- Hints and Warnings
- Have a Zero Hints and Warnings Policy
- Further Learning
- Audits and Metrics
- Toxicity Metrics
- Help Insight
- Third-Party Tools
- External Tools
- Source Monitor
- Pascal Analyzer
- Libraries
- FastMM
- Leak Detection
- Double Free
- Using a Freed Object
- Limit Usage to Debugging
- IDE Plugins
- Pascal Expert
- FixInsight
- Beyond Compare
- TestInsight
- Model Maker Code Explorer
- Other Plugins
- PART THREE - WORKING WITH CODE
- Testing Your Application
- Types of Testing
- Functional Testing
- Integration Testing
- What are Unit Tests?
- Test-Driven Development
- What is Test-Driven Development?
- Bowling Score Kata
- What’s a Kata?
- What is a Coding Kata?
- Bowling Score Kata
- How to Score Ten-Pin Bowling
- And the Kata Begins…
- About the project
- The unit tests
- Gui Runner
- Further Learning
- Debugging
- Debugging Basics
- BreakPoints
- Baby-Steps
- Instruction Pointer
- More Advanced Breakpoints
- Breakpoint Window
- Local Variables
- Call Stack
- Watch List
- Debug Inspector
- Evaluate/Modify
- Threads
- Modules
- CPU Windows
- Using the Debugger:
- Simultaneous Debugging
- Work Out the Pass Count
- Extreme Side Effects
- Fantastic Bugs and Where to Find Them
- Logging
- Platform Assistant
- Writing Code to Make Debugging Easier
- Test Your Bugs
- Further Learning
- Removing Dependencies
- Dependencies Between units.
- Dependencies Between Classes
- Dependency Injection
- Three Types of Dependency Injection
- Constructor Injection
- Property Injection
- Method Injection
- Interface Injection
- Further Learning
- Cleaning Up Uses Clauses
- cnWizards Uses Cleaner
- Pascal Analyser Usage Report
- Orphaned Code
- Removing Public Methods and Globals
- Pascal Analyzer Code Reduction Report
- Logging Example
- Remove Global Variable by Constructor Injection
- Create an Interface
- A New Logger
- Multiple Loggers - Polymorphism to the Rescue
- Method Logging Made Simple
- Final Notes
- Further Learning
- Settings Example
- TVirtualInterface to the Rescue
- Descending from TVirtualInterface
- Introducing Attributes
- Further Learning
- Working on Legacy Projects
- Further Learning
- PART FOUR - BEYOND DELPHI
- Version Control
- What is version control?
- Repository
- Update
- Merge
- Commit
- Branch
- Subversion
- SVN Tutorial
- Install a Server
- Install the Client
- Using SVN
- Checking Our Code In
- Making Our Second Commit
- Going Back to a Previous Version
- Diff
- SVN in Delphi
- Subversion in the Cloud
- Further Learning
- Git
- Configuring Git
- Git Tutorial
- Some Other Handy Hints
- Further Learning
- Bug / Issue / Ticket Tracking Systems
- Working in Teams
- What’s the Bus Number for Your Project
- Have a Successor
- Getting Along in a Team
- Outsourcing
- Team Scalability
- Peer Review
- Pair Programming
- Methodology, Process, and Project Management
- Waterfall
- Agile
- Sprints
- Team Size
- Stand-Ups
- Kanban Board
- Scrum
- Further Learning
- Lean
- Further Learning
- DevOps
- Infrastructure as Code
- Containerisation
- Continuous Integration
- Continuous Delivery
- Further Learning
- Preparing for Disaster
- Backups
- Virtual Machines
- What if Something Happens to You
- Other Options
- Zombie Apocalypse
- Further Learning
- finalization
- end.
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them