Leanpub Header

Skip to main content

Craft Your Code : Second Edition

Mastering the Foundations of Code Quality in the Era of AI Assistants

Unlock the power of code craftsmanship with "Craft Your Code." According to a study, the 10 to 1 rule of writing and programming, good software and good writing requires every line to be rewritten, on an average of 10 times. Get ready to unlock the secrets of clear, concise, and comprehensible code with "Craft Your Code".

Minimum price

$19.99

$24.99

You pay

$24.99

Author earns

$19.99
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.
PDF
39
Readers
500
Pages
About

About

About the Book

"Craft Your Code" explores the evolving programming landscape for professional programmers. Recent advancements in AI coding assistants have revolutionized coding, creating new opportunities. This book empowers modern programmers with the essential knowledge and skills needed to thrive in this new AI era.

The affordability of hardware

The rising affordability of hardware, driven by technological progress, has made greater computing power accessible to programmers at lower costs. "Craft Your Code" investigates how this evolution is transforming software development, empowering developers to utilize increasingly robust machines and consequently optimize their code for superior performance.

The proliferation of programming languages and features:

"Craft Your Code" offers a comprehensive exploration of the numerous programming languages introduced since 2000, each with unique features and capabilities. The book details the strengths, weaknesses, and practical applications of this diverse set of languages. By examining everything, this work reveals how these contemporary innovations can fundamentally transform your coding methodology.

The growth of the developer community and companies:

The software development field is a vibrant, expanding ecosystem, marked by significant growth in both the number of developers and companies. "Craft Your Code" is designed to help readers navigate the unique challenges and opportunities within this environment. The book offers essential guidance for building successful software solutions, managing projects effectively, and fostering strong collaboration, making it a valuable resource for programmers at any stage of their career, from beginner to experienced professional.

The evolution of IDEs with new and powerful features:

Modern Integrated Development Environments (IDEs) have undergone substantial evolution, now offering numerous new features and tools to optimize the coding process. The book, "Craft Your Code," is a guide to effectively utilizing these advanced development environments, exploring the latest IDE technology. By detailing everything from intelligent code completion and debugging tools to smooth version control integration, this resource is designed to help you fully leverage the capabilities of cutting-edge IDEs.

"Craft Your Code" is a comprehensive programming guide designed for the professional developer, recognizing the dynamic evolution of the industry. The book ensures programmers remain leaders in their field by exploring key areas of change: the evolving hardware landscape, the diversity of programming languages, the growth of the developer community, advancements in IDE technology, and the rich ecosystem of extensions. Prepare for a transformative and exciting journey as you master and refine your coding expertise.

The persistent challenge of high software development costs is often exacerbated by poor code quality. This lack of quality significantly increases defects and amplifies expenses across development and maintenance cycles. For those seeking tangible solutions to these problems, "Craft Your Code" offers a definitive path to success. This comprehensive guide provides practical strategies, enabling you to tackle these complex challenges with renewed confidence and efficiency.

In "Craft Your Code" Srihari Sridharan draws upon his extensive experience to guide you in writing cleaner and maintainable code within a diverse, polyglot programming environment.

Through this book, you will gain invaluable insights into:

  • Writing clear and concise code that enhances readability and maintainability.
  • Simplifying loops and logic structures to improve code efficiency and understandability.
  • Applying fundamental concepts from functional and object-oriented programming paradigms.
  • Employing effective strategies for dividing and conquering complex subproblems.
  • Emphasizing loose coupling and high cohesion to achieve modular and robust code.
  • Implementing continuous monitoring techniques to ensure ongoing code quality.
  • Developing sustainable unit tests that validate code functionality and support maintainability.
  • Cultivating practices for writing more maintainable code that facilitates future enhancements.
  • Mastering code review processes to identify and address potential issues.
  • Utilizing feature toggles to improve code cleanliness and enhance development flexibility.
  • Writing clean, concurrent, and asynchronous code for improved performance and responsiveness.

The examples featured in this book span multiple programming languages, including C# (within the context of .NET), JavaScript (both ES5 and ES6 for Node.js and browser), TypeScript, Java, Python, Go, CSS, and HTML. These concepts and solutions are applicable to a wide range of programming languages such as Clojure, Scala, Perl, and more.

Derived from a series of technical talks on "Code Quality" delivered in various organizations, "Craft Your Code" is the culmination of real-world experience and expertise. Equip yourself with the essential knowledge and practices necessary to elevate your coding craftsmanship and produce high-quality software solutions.

Share this book

Installments completed

25 / 25

Author

About the Author

Srihari Sridharan

Srihari Sridharan is a seasoned Software Architect and Engineer with a hands-on approach. He is a renowned speaker, conducting courses and delivering talks on software craftsmanship and writing clean code. Srihari's areas of expertise encompass refactoring, design patterns, enterprise application architectural patterns, integration patterns, and cloud-native design patterns. He possesses practical knowledge in a wide range of technologies. He is a firm believer in Agile methodologies, Extreme Programming (XP), Test-Driven Development (TDD), and the principles of writing clean code and refactoring.

Apart from his role in a leading company that provides premium software services to global clients, Srihari is an esteemed reviewer and a senior technical proof-reader for Manning Publications Co.

Contents

Table of Contents

Preface

  1. Who Should Read This Book
  2. Why I Wrote This Book
  3. Navigating This Book
  4. Conventions Used In This Book
  5. Using Code Samples

Acknowledgements

About the Author

Introduction

  1. History of Enterprise Application Development and Cloud Providers

Part I Mastering the Fundamentals

Chapter 1: The Significance of Coding Standards: Building Solid Foundations

  1. What is a coding standard?
  2. The Significance of Coding Standards
  3. The Consequences of Neglecting Coding Standards
  4. Identifying Code Smells
  5. Indicators of Deteriorating Design
  6. A Quick Note on Static Code Analyzers
  7. Upcoming Chapter

Chapter 2: Unveiling the Power of Names

  1. The Significance of Naming in Programming
  2. Specificity in Variable Names
  3. Enhancing Names of Loop Index Variables
  4. Simplifying Names
  5. Adding Context to Names
  6. Coding in the Language of the Domain
  7. Maximizing Clarity and Minimizing Ambiguity
  8. Upcoming Chapter

Chapter 3: Essence of Aesthetics

  1. Why is Aesthetics Important?
  2. Quick Note on Code Layout
  3. Improving Aesthetics - An Example
  4. Reducing Noise in Code
  5. Vertical Formatting
  6. Horizontal Formatting
  7. Individual vs. Team: Striving for Consistency
  8. Useful Tools
  9. Upcoming Chapter

Chapter 4: Comments: The Bridge Between Code and Understanding

  1. Importance and Necessity of Comments
  2. Recording thoughts throughout the coding process
  3. Enhancing Code Readability with Comments
  4. Mastering Precision and Conciseness in Code Comments
  5. Closing Remarks
  6. Upcoming Chapter

Chapter 5: Simplifying Control Flow - Keep It Simple and Streamlined (KISS)

  1. Chapter Overview
  2. Optimizing Conditional Expressions: Leveraging Argument Order for Readability
  3. Harnessing the Power of the Conditional (Ternary ?:) Operator
  4. Improving Code Readability with Early Method Exits
  5. End of Part I Mastering the Fundamentals

Part II Mastering Control Flow and Programming Paradigms

Chapter 6: Practical Strategies for Handling Large Expressions

  1. The Power of Explanatory Variables
  2. Applying De-Morgan’s Law in Coding
  3. Enhancing Readability with Summary Variables
  4. DRY - Don’t Repeat Yourself
  5. Eliminate Duplication through Function Extraction
  6. Summary
  7. Upcoming Chapter

Chapter 7: Unlocking Readability: Tips for Clear and Understandable Code

  1. Striking a balance between variables and readability
  2. Streamlining code by eliminating intermediate results
  3. Streamlining code by eliminating control flow variables
  4. Harnessing the power of JavaScript closures
  5. Optimizing readability by moving declarations close to usage
  6. Realizing the benefits of immutability
  7. Upcoming Chapter

Chapter 8: Enforcing Code Cohesion: The Law of Demeter Explained

  1. Design violating the Law of Demeter
  2. Design adhering to the Law of Demeter
  3. Upcoming Chapter

Chapter 9: Functional Programming

  1. What is functional programming?
  2. What is referential transparency?
  3. First-class and higher-order functions
  4. Pure functions
  5. Coding Styles in various languages
  6. Incorporating Functional Programming into Non-Functional Languages
  7. Crafting functional code
  8. Summary
  9. Upcoming Chapter

Chapter 10: Object-Oriented Programming

  1. Classes, Objects, and Interfaces
  2. Key Concepts
  3. Summary
  4. End of Part II Mastering Control Flow and Programming Paradigms

Part III Revamping Your Codebase

Chapter 11: Breaking Down Problems: A Divide and Conquer Approach

  1. Utilizing Utility Code for Consistency and Efficiency
  2. Extracting Project-Specific Functionality
  3. Refactoring and Simplifying an Interface
  4. A Note of Caution!
  5. Upcoming Chapter

Chapter 12: Focusing on One Responsibility at a Time

  1. Example - Order Processing
  2. Upcoming Chapter

Chapter 13: From Mind to Machine: The Path of Translating Thoughts to Code

  1. Improving Clarity
  2. Don’t Reinvent the Wheel
  3. Knowing Language Features
  4. Knowing Features Provided By Libraries
  5. Upcoming Chapter

Chapter 14: Less is More: The Elegance and Effectiveness of “No Code”

  1. YAGNI
  2. Questioning and Evaluating Requirements or Problems
  3. Keeping a Watchful Eye on Codebase Size
  4. Getting Acquainted with Libraries and Codebase
  5. Upcoming Chapter

Chapter 15: Reviewing Code : Examining, Refining, and Elevating Quality

  1. The Significance of the Code Review Process
  2. Evolution of the Code Review Process
  3. Enhancing Code Quality through Collaborative Excellence: Pair Programming and Code Reviews
  4. Team Code Reviews
  5. Code Review Checklist
  6. Categorizing Code Review Comments
  7. Sustaining the Progress
  8. Tips and Tricks
  9. Leveraging Pre-Commit Hooks
  10. Summary
  11. Upcoming Chapter

Chapter 16: The SOLID Foundations: Writing Code that Stands the Test of Time

  1. Credits
  2. Introduction
  3. Single Responsibility Principle
  4. Open-Closed Principle
  5. Liskov Substitution Principle
  6. Interface Segregation Principle
  7. Dependency Inversion Principle
  8. Conclusion
  9. Upcoming Chapter

Chapter 17: Cohesion and Coupling: Guiding Principles for Modular Code

  1. Credits
  2. Introduction
  3. Cohesion
  4. Coupling
  5. Package Architecture Principles
  6. Package Cohesion Principles
  7. The Package Cohesion Tug of War
  8. Package Coupling Principles
  9. An Important Note
  10. End of Part III Revamping Your Codebase

Part IV Beyond the Basics

Chapter 18: A Systematic Approach to Refactoring

  1. Quick introduction to refactoring
  2. Prerequisites
  3. Refactoring in action
  4. Handling method-level code smells
  5. Handling class-level code smells
  6. Handling application-level code smells
  7. Iterative approach to refactoring
  8. End to end tests for UI Refactoring
  9. Distill the Core Domain from Your Legacy App
  10. Conclusion

Chapter 19: Test-Driven Development

  1. Introduction
  2. What is TDD?
  3. Red - Green - Refactor
  4. Writing Effective Tests
  5. Environment Setup
  6. Requirements
  7. Writing your first test (before writing actual code)
  8. RED
  9. GREEN
  10. RED #2
  11. GREEN #2
  12. RED #3
  13. GREEN #3
  14. REFACTOR
  15. More tests to cover edge cases
  16. Exploring further using TDD

Chapter 20: Sustainable Unit Tests and TDD

  1. Observing unit tests
  2. Improving test readability
  3. Building the test data
  4. Summary

Chapter 21: Version Control Strategies

  1. Helpful Version Control Practices
  2. A possible version control strategy
  3. Command-line vs. GUI based tools
  4. Trunk Based Development
  5. Summary

Chapter 22: Feature Toggles and Clean Code

  1. What are feature toggles?
  2. Identifying Appropriate Use Cases for Feature Toggles
  3. Categories of feature toggles
  4. Implementation considerations
  5. Toggle configuration and approaches for managing toggle configuration
  6. Overriding toggle configuration
  7. Best Practices for Working with Feature Toggles
  8. Managing the Cost of Feature Toggles
  9. Buy vs. Build
  10. Inputs to and outputs from an enterprise feature flagging platform
  11. Summary

Chapter 23: Handling Technical Debt

  1. People
  2. Process
  3. Software Tools
  4. A final note of caution

Chapter 24: Craft Your Career

  1. Monitoring and Evaluating Progress
  2. Creating Content and Enhancing Your Reputation
  3. The Triangle of Technical Knowledge
  4. Learning and Note-Taking
  5. Career Tips from Experience
  6. Becoming a generalizing-specialist?
  7. Crafting an Impressive Resume
  8. Summary

Architects’ Bookshelf

Appendix: Comprehensive Reference

Appendix A: What did they say?

Appendix B: Code Smells

Appendix C: Broken Windows Theory

Appendix D: Cost of Owning Technical Debt

Appendix E: Recollecting the Boys Scout Rule

Appendix F: Philosophies for Effective Programming

Appendix G: The 30 seconds rule explained!

Appendix H: Object-Oriented Programming Terminology

Thank You

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 earned over $14 million writing, 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

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub