Digital Library

The Art of Code The surprising power of beauty in software development (Sandrine Banas) (z-library.sk, 1lib.sk, z-lib.sk)

Sandrine Banas

The Art of Code The surprising power of beauty in software development (Sandrine Banas) (z-library.sk, 1lib.sk, z-lib.sk)

Author Sandrine Banas

代码

Software development is an inherently creative activity, and yet we regularly reduce it to the formulaic or mechanical. This book reveals how aesthetics can be important in programming and why elegant code often yields profound practical benefits. By prioritizing code beauty you raise the standards of your entire codebase. You make it easier to maintain, extend, and onboard developers, even (or especially) when you’re doing agentic coding. This guide for developers discusses how artful coding directly reduces bugs and increases system durability. It will deeply enhance your personal satisfaction as a developer. At the heart of this book lies the “rosette model,” a structural framework that maps eight interlocking dimensions of code quality. It places durability as the foundation, with creativity at the center supported by overlapping traits like simplicity, expressiveness, and sustainability. As reviewer Oliver Forral from Reason Benefit Corporation notes, “The rosette model gives ‘beauty’ a concrete structure instead of leaving it as a vague aspiration, illustrating its power through brilliant before-and-after refactorings.” To bring narrative structure to your classes, the book introduces a genuinely original “five fundamental plots” framework. This unique design tool elevates enterprise business logic from a list of instructions into a readable story structured around Delivering, Cleaning, Defense, Archiving, and Transformation. Concise yet complete, this book’s 10 comprehensive chapters and rich practical appendixes present a cohesive, masterfully written roadmap. It equips you with actionable green design patterns, error-handling strategies, and elegant data modeling principles that bridge the gap between high-level architectural theory and everyday coding practice. In today's era of agentic AI coding, human design judgment matters more than ever. AI tools mirror the surrounding code quality. Clean code yields clean generation, while messy files propagate fl

Format PDF
Size 11.1 MB
4
Views
0
Downloads
0.00
Total Donations

Text Preview (First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
M A N N I N G The surprising power of beauty in software development Sandrine Banas the art of
Page 2
The Art of Code THE SURPRISING POWER OF BEAUTY IN SOFTWARE DEVELOPMENT SANDRINE BANASMANN I NG SHELTER ISLAND Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 3
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: orders@manning.com ©2026 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. The authors and publisher have made every effort to ensure that the information in this book was correct at press time. The authors and publisher do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause, or from any usage of the information herein. Manning Publications Co. Development editor: Rebecca Johnson 20 Baldwin Road Technical editor: Jean-François Morin PO Box 761 Review editor: Dunja Nikitović Shelter Island, NY 11964 Production editor: Kathy Rossland Copy editor: Lana Todorovic-Arndt Proofreader: Mike Beady Typesetter: Dennis Dalinnik Cover designer: Marija TudorISBN: 9781633434929 Printed in the United States of America Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 4
For my smart, strong, and beautiful daughter For my family—thank you for your unconditional and loving supportLicensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 5
iv brief contents 1 ■ The aesthetics of code 1 2 ■ Narrative code 13 3 ■ The complex art of simplicity 38 4 ■ Expressing clarity of intent through elegant data modeling 59 5 ■ Expressiveness 83 6 ■ Embracing purity with functional programming 95 7 ■ Handling failure with grace 119 8 ■ Sustainability 142 9 ■ Durability in software design 169 10 ■ Creativity in code and problem-solving 188 A ■ Appendix 209 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 6
contents preface ix acknowledgments xi about this book xiii about the author xvii about the cover illustration xviii 1 The aesthetics of code 1 1.1 The patterns of beautiful code 2 Storytelling 4 ■ Simplicity 4 ■ Clarity of intent 4 Expressiveness 4 ■ Purity 5 ■ Sustainability 5 Durability 5 ■ Creativity 5 1.2 A simple example of beautiful code 5 Modeling absence 7 ■ From absence to beauty 10 2 Narrative code 13 2.1 The plot 14 The delivering 14 ■ The cleaning 15 ■ The defense 16 The archiving 17 ■ The transformation 18 2.2 Code typography 19 2.3 High-level storytelling 20v Working with legacy code 21 ■ Understanding the story 22 Simplifying the story 23 ■ Levels of narrative: Action, scene, Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 7
CONTENTSvi chapter, and table of contents 25 ■ Choosing where to break the story 28 2.4 The characters 31 2.5 The ending 33 3 The complex art of simplicity 38 3.1 Complexity 39 Code complexity 39 ■ Measuring cognitive complexity 40 3.2 Simplicity 46 The Prevent lever 46 ■ The Organize lever 49 ■ The Reduce lever 49 ■ The Hide lever 53 ■ The Investigate lever 56 The Endure lever 57 4 Expressing clarity of intent through elegant data modeling 59 4.1 The pain of working with data in traditional object-oriented languages 61 The risk of mutable data 61 ■ Understanding the burden of encapsulation 63 4.2 Data-oriented approach 67 Beauty in record time 68 ■ Practical uses for small data carriers 71 4.3 Elegant data modeling principles 78 5 Expressiveness 83 5.1 Understanding expressiveness 84 Traditional switch in Java 85 ■ Java’s enhanced switch 86 ■ Kotlin if/else 87 ■ Kotlin when with a sealed hierarchy 88 ■ Haskell pattern matching and direct domain modeling 89 5.2 The limits of expressiveness 90 6 Embracing purity with functional programming 95 6.1 Programming paradigms 96 Imperative programming 96 ■ Functional programming 97 6.2 Functions 100 Lambda expressions 101 ■ Composition 103 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 8
CONTENTS vii 6.3 Pipelines 104 Understanding functional pipelines 105 ■ Exception handling, or not 109 ■ Ugly pipelines 112 ■ Immutability in pipelines 113 6.4 Final match, imperative vs. declarative 115 7 Handling failure with grace 119 7.1 Categorizing failure 120 Business logic errors 120 ■ Technical problems 121 Programming errors 122 ■ Fatal errors 122 7.2 Antipatterns in failure handling 124 Failing to defend the entry points 124 ■ Lazy catch 125 Logging gone wrong 127 ■ Flawed error handling 131 8 Sustainability 142 8.1 The three pillars of sustainability 143 8.2 The environmental impact of digital technology 143 The carbon cost of electricity 144 ■ The hidden lifecycle cost of digital devices 145 8.3 The craft of green software 146 8.4 Green design patterns 147 Frugality pattern 148 ■ Lean packaging pattern 150 Lean storage pattern 151 ■ Lean communication pattern 153 Efficient execution pattern 156 ■ Memory efficiency pattern 158 Carbon-aware pattern 160 8.5 Tools 163 Estimating carbon footprint 164 ■ Tools for developers 164 9 Durability in software design 169 9.1 Designing for change 170 The balance between cohesion and coupling 171 ■ SOLID 174 Design patterns 175 9.2 Resilience 178 9.3 Testing and the discipline of doubt 179 9.4 Designing for trust 183 Designing stable contracts 183 ■ Evolving without breaking trust 184 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 9
CONTENTSviii 10 Creativity in code and problem-solving 188 10.1 Creativity in programming 189 Coding, but not all of it 189 ■ Problem-solving 190 Creative foresight 190 10.2 Creative thinking in coding 191 Exercise: Practicing creativity through constraints 191 Solutions 192 10.3 The creative problem-solving methodology 198 Knowledge 200 ■ Clarifying 200 ■ The creative problem- solving loop 204 ■ Implement and reflect 206 appendix 209 index 223Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 10
preface “Wow, that code is ugly,” my former tech lead muttered. He was clearly shocked. I had just walked him through a tricky piece of legacy code written by previous maintainers, helping him navigate it faster. I had previously worked on the same module and spent hours untangling its intricate logic. The code was buried in low-level implementation details, with no clear flow to follow. To be fair, it addressed a complex scenario, but any changes risked introducing side effects. For this reason, developers were reluctant to touch it at all. After his frustrated remark, I stepped back and let him work through the code to implement a new feature. He worked quietly for hours, fully absorbed. I was stunned when he finally called me back to validate his changes. I expected a patch. Instead, he rewrote the structure entirely. What was once an indecipherable mess had become readable, simple, and elegant in its design. He hadn’t changed the logic, only the way it was told. He rewrote the code as a story, splitting it into small, simple steps, giving each one a meaningful method name and making the overall purpose easy to under- stand. The difference in readability and maintainability was stark. I’ve often reflected on that moment. Writing code that was merely bug-free, func- tional, and maintainable was no longer enough for me. I began to seek a higher stan- dard, one where solving a complex problem with elegance and simplicity brought deep intellectual satisfaction. It was no longer enough to create programs that pro- duced the expected results; the code itself needed to become its own purpose, a finelyix crafted algorithm, something closer to a work of art that would deliver more than just functionality—lasting quality. Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 11
PREFACEx It took me years to articulate this pursuit, and only recently did I dare to use a word that still sparks mixed reactions among developers: beautiful. Beauty in code goes beyond indentation or coding conventions. It emerges from deliberate design choices that make code easier to understand and more durable. This book is for developers who want to shift their thinking, approach their work like artists, and, in doing so, improve both the quality of their work and the joy they find in writing code.Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 12
acknowledgments I would like to express my gratitude to the many people who supported and guided me throughout this journey. First, I thank my development editor, Rebecca Johnson, for her thoughtful advice and constant encouragement. Her guidance played a key role in shaping both the structure and clarity of this book. I am also grateful to my technical editor, Jean- François Morin, for his thorough technical reviews and valuable feedback, which helped ensure the accuracy and rigor of the content. Jean-François is a senior Java developer and architect at Laval University in Quebec City, Canada. My sincere thanks go to Michael Stephens, associate publisher, for believing in this book and for his guidance and direction throughout the project. His perspective con- sistently challenged me to refine and sharpen my definition of beautiful code, helping transform an initial idea into a coherent and grounded work. I also thank everyone at Manning who contributed behind the scenes to the devel- opment, production, and publication of this book. I am deeply thankful to all the reviewers whose detailed comments and suggestions helped improve the quality, clarity, and correctness of the material: Abe Taha, Allen Ding, Andy Keffalas, Bhagvan Kommadi, Bruce Park, Catalin Roman, Chaitanya Sharma, Claudia Maderthaner, Conor Redmond, Cristina Kiss, Erin Colvin, Greg Wagner, Ilkka Seppälä, Johan Smarius, John Montgomery, Jon Skeet, Jonathan Eastmael Salatan, Juan José Durillo Barrionuevo, Kyle Laverty, Mark Elston, Michael Krimgen,xi Nancy Al Kalach, Oliver Forral, Orlando Mendez, Oscar Gil, Pax Williams, Rachit Jain, Ramya Boorugula, Robert Delwood, Rohit Purswani, Ruslan Vidzert, Stephen Griese, Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 13
ACKNOWLEDGMENTSxii Steven Jenkins, Troi Eisler, Uttam Kumar, and Yev Bronshteyn. Their feedback was invaluable in refining the final manuscript. I am grateful to my colleagues who shared coding experiences, discussions, and countless merge requests with me over the years. These exchanges continuously shaped my thinking as a developer. I owe special thanks to my colleague Thnouremi Pen, whose shared passion for Java and thoughtful technical discussions consistently challenged my ideas, and who inspired the very first code example that appears in this book. On a more personal note, I want to thank my family. I am deeply grateful to my daughter for her patience, enthusiasm, and support throughout the long process of writing this book. I also thank my parents, whose unconditional support made every- thing possible. By buying our first computer at a time when computers were still far from common in households, they unknowingly gave me my first exposure to pro- gramming and set me on the path that led to this book. Finally, I thank my big brother, who patiently shared that first computer as we learned BASIC on an Amstrad CPC, making those early programming discoveries even more meaningful.Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 14
about this book The Art of Code is a book for developers who aspire to create software that is both beau- tiful and enduring. In an era where AI is reshaping the landscape of programming, it refocuses attention on the uniquely human aspects of code: skills, creativity, and beauty. It also explores the broader requirements of modern enterprise software, including failure handling, resilience, security, durability, and sustainability. Here, beauty is not an abstract ideal. It’s the intentional result of concrete design choices that emphasize simplicity, clarity of intent, purity, expressiveness, and storytell- ing. Together, these qualities lead to higher-quality software by making code easy to understand, safe to refactor, reliable in production, and durable over time. Throughout the book, I demonstrate how these principles can be translated into reusable prompts and skills that assist developers in their daily tasks. They can help generate higher-quality code and review existing code. However, they still require human judgment to validate the result, understand the tradeoffs, and take responsi- bility for the final design. Regardless of whether you hand-write code or use AI tools, speed must be bal- anced with human craftsmanship. You bear responsibility for its security and reliabil- ity, especially in the most critical and risky parts of a system. Ensuring that your code is both functional and beautiful may require more time upfront, but that investment is repaid many times over by making systems easier to maintain and extend in the long term.xiii Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 15
ABOUT THIS BOOKxiv Who should read this book This book is written primarily for intermediate to senior developers who care about the long-term quality of their code. It is aimed at developers who want to adopt mod- ern coding practices that make systems more durable and sustainable. Tech leads, senior engineers, and architects will also find this book useful as a mento- ring tool. The book provides a shared language and concrete examples to help guide junior developers toward higher-quality code by teaching them how to reason about code and design decisions rather than applying rigid practices or checklists blindly. While this book is not a beginner’s guide to programming, motivated junior devel- opers can still benefit from it. Although some chapters may be challenging, others pro- vide value early in a developer’s journey. For example, chapter 7 on failure handling and chapter 10 on creativity and problem-solving can help beginners learn how to han- dle failure scenarios, approach unfamiliar problems, and work within constraints. Read- ing this book early can help shape durable habits and a thoughtful mindset. How this book is organized: A road map This book is organized around the rosette of beautiful code, a model that brings together the key dimensions of high-quality software. It contains 10 chapters that pro- gressively explore how these dimensions apply to real-world programming, from local code structure to system-level concerns. Here is a brief overview of each chapter: Chapter 1 introduces the concept of beautiful code and presents a guiding model built around eight dimensions: storytelling, simplicity, clarity of intent, expressiveness, purity, sustainability, durability, and creativity. It explains why beauty in code matters and how it supports higher code quality. Chapter 2 introduces narrative code as a way to bring storytelling into code, show- ing how programs often repeat the same stories through recurring plots such as Delivering, Cleaning, Defending, Archiving, and Transformation. It demonstrates how to organize code into actions, scenes, chapters, and a table of contents to reduce cognitive load and make the plot of the code clear at a glance. Chapter 3 delves into the challenge of simplicity. It examines where code com- plexity comes from, how it can be measured, and presents practical ways to reduce it and improve long-term maintainability. Chapter 4 focuses on clarity of intent through data modeling. It explains how mutable data and excessive encapsulation obscure intent, and how a data-ori- ented approach makes code easier to understand. Chapter 5 explores expressiveness in code. It clarifies what expressiveness means in practice and shows how modern language features reduce boilerplate, while increasing readability and safety. Chapter 6 explores purity and functional programming. It shows how limiting side effects and favoring immutability make behavior more predictable and help structure code as clear, composable transformations. Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 16
ABOUT THIS BOOK xv Chapter 7 addresses failure handling as a transversal concern. It examines how different categories of failures require different strategies, and why thoughtful error handling, logging, and fallback design are essential for building resilient systems. Chapter 8 focuses on sustainability. It examines how software consumes compu- tation, memory, storage, network bandwidth, and hardware resources, and how green design patterns can reduce both operational costs and environmental impact. Chapter 9 focuses on durability. It explains how principles such as separation of concerns, cohesion, coupling, testing, resilience, and stable public contracts help build modern enterprise software that can adapt to change, withstand real- world constraints, and earn long-term trust. Chapter 10 explores creativity as a practical engineering skill. It examines how creativity applies to coding, problem-solving, and foresight, and how external constraints can shape solutions and drive better design decisions. It’s better to read this book sequentially on a first pass, as each chapter builds on con- cepts introduced earlier. However, experienced developers can also approach individ- ual chapters independently, depending on their interests and current challenges. About the code This book contains many examples of source code, both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes code is also in bold to high- light code that has changed from previous steps in the chapter, such as when a new feature is added to an existing line of code. In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in this book. In rare cases, even this was not enough, and listings include line-continuation markers (➥). Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts. You can get executable snippets of code from the liveBook (online) version of this book at https://livebook.manning.com/book/the-art-of-code. Source code for the examples in this book is available for download from the Manning website at https:// www.manning.com/books/the-art-of-code and from GitHub at https://github.com/ Cosjava/theArtOfCode. liveBook discussion forum Purchase of The Art of Code includes free access to liveBook, Manning’s online reading platform. Using liveBook’s exclusive discussion features, you can attach comments to the book globally or to specific sections or paragraphs. It’s a snap to make notes for yourself, ask and answer technical questions, and receive help from the author and Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 17
ABOUT THIS BOOKxvi other users. To access the forum, go to https://livebook.manning.com/book/the-art- of-code/discussion. Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We sug- gest you try asking the author some challenging questions lest her interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 18
about the author SANDRINE BANAS is a senior Java expert, tech lead, and passionate software crafts- woman with over 25 years of experience. As an Oracle Certified Professional, she has spoken at leading French conferences including Devoxx, Volcamp, MiXiT, Snowcamp, and Agile Grenoble. When she’s not exploring the elegance of Java or mentoring fellow developers, she finds inspiration in reading, writing, meditation, and a good cup of tea. She lives in France with her daughter and sees programming not just as problem-solving, but as a fulfilling creative process where simplicity, clarity, and care come together to form something both functional and beautiful.xvii Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 19
about the cover illustration The figure on the cover of The Art of Code is “Femme Greque de l’Asie” or “Greek Woman from Asia Minor,” taken from George Arents Collection, Album of Turkish Costume Paintings (1808–1826). Each illustration is finely drawn and colored by hand. In those days, it was easy to identify where people lived and what their trade or sta- tion in life was just by their dress. Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional cul- ture centuries ago, brought back to life by pictures from collections such as this one.xviii Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 20
The aesthetics of codeYou are an artist whose medium is code. Your tools are logic and syntax. Your purpose is to shape ideas into code. The result of your art is robust, high-quality software. Thinking of code as art is not an aesthetic luxury as it has profound practical benefits. Beautiful code improves the whole codebase, making it easier to under- stand, maintain, and extend while reducing the risk of bugs. Such quality matters even more when code passes through many hands across different skill levels, under tight deadlines and shifting business demands, while still being expected to remain durable and reliable over time. Thinking of yourself as an artist also expresses the need not just to produce code, but to find meaning in your craft by creating something you’re proud to This chapter covers How to define beautiful code Eight dimensions of code quality The basics of the rosette model Modeling absence without null How to preserve judgment in agentic coding1 leave behind, especially today, as AI and agentic coding are reshaping the role of the developer. This book provides a systematic approach to deliberately creating Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List