Rules, Principles, and Values
To do your best is not enough. First you must know what to do, and then do your best.
– W. Edwards Deming
What is the difference between rules, principles, and values?
Here is what the dictionary says:
- Rule: One of a set of explicit or understood regulations or principles governing conduct or a procedure within a particular area of activity. A principle that operates within a particular sphere of knowledge, describing or prescribing what is possible or allowable. A code of practice and discipline for a religious order or community.
- Principle: A fundamental truth or proposition that serves as the foundation for a system of belief or behavior or for a chain of reasoning. A general scientific theorem or law that has numerous special applications across a wide field. A fundamental source or basis of something.
- Value: The regard that something is held to deserve; the importance, worth, or usefulness of something. Principles or standards of behavior; one's judgment of what is important in life.
We live in a world with rules everywhere. On the road, at work, at school, or at the movies: we have to respect the rules of the environment we are in.
Sometimes, we are overwhelmed by the number of rules. Most of the time, we don't really even know the exact rules, yet we are able to behave correctly in (almost) any situation. That's because when rules follow common principles and values (which together make up common sense), it's pretty easy to work out the most important ones.
For example, you don't need to memorize the rules of the cinema to understand that if your phone rings in the middle of the show, it would annoy those around you. Or, you don't need to consciously remember the rule of the road that requires you to stop at the red light; you just know it's a very wise thing to do. That's because sensible rules are expressions of principles and values valid in a specific context. In the cinema, we want to be nice and let everybody enjoy the show, so we try not to be noisy. On the street, we want everybody to travel safely, so we respect the convention of traffic lights at crossing points.
How Rules Can Lead to Intellectual Laziness
We are so used to having rules to observe that many of us seem to be lost without them. Rules are obviously useful, but can unfortunately lead to a dangerous habit for a software developer: switching off critical thinking.
The main problem is that there are very few rules valid in any situation (the infamous silver bullet). Most rules are tightly bound to a context and, if the context changes, the rules might not be relevant anymore. Furthermore, the habit of following rules without questioning the context can lead in the long run to intellectual laziness. In this case, it seems easier to blindly follow some rules instead of working them out (based on principles and values) for the particular context.
Our profession is about instructing a machine to follow rules written in the form of coding. Critical thinking is one of the most relevant and hard-to-emulate qualities that define the difference between human beings and the artificial intelligence way of thinking. Switching off critical thinking only moves you steadily down the path of uselessness. If it were just about following rules, since robots are much better then us in doing that, they would have already filled all the programming jobs available.
Use Rules as a Shortcut to Internalize Principles
Nevertheless, we use rules as shortcut in order to practice and learn how to behave in a particular scenario. The final goal should never be an exercise of the mere memorization of rules. The ultimate achievement of practicing a ruleset is the internalization of the basic principles underlying them.
In the following lessons, we will introduce several rulesets for different contexts. Please don't force yourself to memorize them. If you don't remember something, open the page and consult the book as a reference. Try to work out the rules in your mind, starting from the principles. Experiment with different variations and evaluate the pros and cons of each outcome. Exercise until you understand and remember the principles, not the rules.
Once you master most of the principles we discuss here, something very cool might happen: you will find yourself more naturally predisposed to think about software design using a particular subset of those principles. Or, even more cool, you might want to find your very own principles, those that work and make sense for you, driving every single line of your code.
Either way, congratulations. That means you have started to build your own set of software design values.
In the first lessons of the book, we focus mostly on rules and then slowly move into principles and values. Be patient. Just imagine you are a young driver: in the beginning, you focus on following the rules, but once you are an experienced driver, you are able to extract your own rules from internalized principles and your core values.
Learn the rules like a pro, so you can break them like an artist.
– Pablo Picasso
How This Book Is Organized
The content we present is structured like a journey. As with every journey into a new environment, the beginning is slow and safe, but it is crucial for setting the stage for what comes next. The adventure then gains momentum as confidence grows, learning new subjects that introduce new techniques and principles to advance more steadily. Finally, in the final lessons, we demonstrate how the learned principles can be applied in several contexts, converging to allow the best solutions.
This is why we have divided the journey in four main sections:
- First steps
- Walking
- Running
- Flying
Each part is divided into several lessons with a common structure:
- New principles: New concepts are added on top of the previous materials.
- Katas: Exercises for you to spend some time practicing the new material.
- Great habits: We build up a collection of good practices step by step.
- Where we are in the big picture of OO software design?
A bird's eye view of where the lesson practices belong in the world of software design. It relates lesson practices with other practices, rules, and principles.
- When I should move to the next lesson?
A few questions to help you decide whether you are ready to move on.
- Resources: In case you want to go deeper into the material presented, the Resources sections provide web links and recommended books.
How to Get the Most out of This Book
To perform the katas, you will need access to a computer with your favorite development environment configured.
This book does not focus on any languages or tools in particular. We firmly believe that habits, principles, and values are the most crucial part of a developer's knowledge and that they are technologically agnostic. Hence, you are welcome to choose the ones that best suit you.
We have organized and presented the information in this book in a logical sequence. We strongly feel that practice and exercise are the fundamental resources needed for this journey. That's why you will find code challenges and katas at every lesson. They were selected to stimulate critical thinking about the subjects, leading you on a fun and pragmatic step-by-step learning path.
Mastery is applied knowledge, and even the most talented person can't skip practicing to reach it. Spend time going through the exercises to master the concepts and practices presented.
Caution
Our brain is addicted to information. Resist the urge to read this book without performing the exercises. Information per se is not very useful.
Programming is a skill best acquired by practice and example rather than from books.
– Alan Turing
Asking for Help or Feedback
If you want to get feedback or help from the community about the topics presented in this book, go to the book's community page at http://community.agiletechpraxis.com/.
Helping Others
Ideally, you should work on the exercises as a pair. Even better, have a journey companion. Either working on your own or with a pair, we strongly encourage you to join the community.
As soon as you feel confident, you can help others along the path. Help by answering questions and sharing your experience. Helping others is a great way to challenge your knowledge and internalize what you have learned!
Feedback about This Book
We would love to hear your feedback about this book:
- What you liked?
- What inspired you?
- What you learned?
- What we missed?
- What we could have explained better?
- What you disagree with?
We value your opinions and feelings about this work, and we will be always thankful if you decide to share them with us. You can go to Our Quick Feedback Form at http://www.agiletechpraxis.com/feedback or send us an email at info@agiletechpraxis.com
.
Resources
Web
- Extreme Programming: A Gentle Introduction: http://www.extremeprogramming.org/.
- What is extreme programming, Ron Jeffries: http://ronjeffries.com/xprog/what-is-extreme-programming/.
Books
- Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman, Dave Hoover, Adewale Oshineye: https://www.goodreads.com/book/show/5608045-apprenticeship-patterns.
- The Clean Coder: A Code of Conduct for Professional Programmers, Robert C. Martin: https://www.goodreads.com/book/show/10284614-the-clean-coder.
- Extreme Programming Explained: Embrace Change, Kent Beck: https://www.goodreads.com/book/show/67833.Extreme_Programming_Explained.
- The Passionate Programmer: Creating a Remarkable Career in Software Development, Chad Fowler: https://www.goodreads.com/book/show/8393116-the-passionate-programmer.
- The Pragmatic Programmer: From Journeyman to Master, Andy Hunt and David Thomas: https://www.goodreads.com/book/show/4099.The_Pragmatic_Programmer.
- Pragmatic Thinking and Learning: Refactor Your Wetware, Andy Hunt: https://www.goodreads.com/book/show/3063393-pragmatic-thinking-and-learning.
- The Software Craftsman: Professionalism, Pragmatism, Pride, Sandro Mancuso: https://www.goodreads.com/book/show/23215733-the-software-craftsman.
- Software Craftsmanship: The New Imperative, Pete McBreen: https://www.goodreads.com/book/show/1035377.Software_Craftsmanship.