Atomic Habits The Surprising Power of Atomic Habits Study cards
Attribution: Atomic Habits: Tiny Changes, Remarkable Results by James Clear

The {{c1::aggregation of marginal gains}} is a strategy of searching for a tiny margin of improvement in everything that you do. Break down everything that you can think of that goes into something, make each thing better by 1%, and when you put it all together it will improve the overall result greatly: {{c1::aggregation of marginal gains}}.

Small habits make a big difference. Do not undervalue making small improvements on a daily basis. Improving by 1% is not very noticeable but is meaningful in the long run.

Habits are the compound interest of self-improvement. The effects of your habits multiply as you repeat them.

Small changes do not seem to matter very much in the moment. Unfortunately, the slow pace that habits cause effects make it easy to let bad habits slide. When we repeat 1% errors day after day, the small choices compound into bad results. A slight change in your habits can guide your life to a different destination. Success is the product of daily habits.

What matters is your current trajectory. Your outcomes are a lagging measure of your habits. Follow the curve of tiny gains or tiny losses and see how your daily choices will compound over a long time. {{c1::Time}} magnifies the margin between success and failure. With {{c1::good habits}}, {{c3::time}} is your ally, and with {{c2::bad habits}}, it is your enemy. Productivity compounds: automating old tasks or mastering new skills allows you to free your brain to focus on other things. A commitment to life-long learning can be transformative because knowledge builds up like compound interest. People reflect your behavior back to you. By helping others, people will help you too.

A {{c1::breakthrough moment}} is often the result of many previous small actions that increased the potential of a sudden change happening. Consider an ice cube melting as the critical temperature threshold is reached. There can be a valley of disappointment where progress seems slow at first. The most powerful outcomes will be delayed: this is one of the reasons why it is hard to build {{c1::good habits}}. You will not see results immediately, so it's easy to let good habits go. You must cross the plateau of latent potential. People will see it as an overnight success, but in fact it is the result of a lot of work that happened way back when it seemed no progress was being made at all.

All big things come from small beginnings. Breaking a bad habit is like uprooting a tree, and forming a habit is like cultivating a flower.

How can we survive the plateau of latent potential? Focus on systems instead of goals. Results have a lot more to do with the systems being followed than the goals that were set.

{{c1::Systems}} are the processes that lead to the results. If you want better results, focus on your system. Goals are good for setting a direction, but systems make progress. Spend more time designing your systems than setting your goals.

If successful and unsuccessful people share the same goals, then it cannot be the goals that separate the successful from the unsuccessful.

Achieving a goal is only a momentary change. Do not treat symptoms without addressing the cause. The results are not the problem. What needs to change is the systems. Solving problems at the results level is temporarily.

Goals restrict your happiness. The implicit assumption behind a goal is that happiness is put off by achieving the goal. Happiness is not something for your future self to enjoy. Goals create an either-or conflict. This is misguided. It is unlikely your path will match your exact journey you set out at any time. A systems first mentality is an antidote. Fall in love with the process, not the product.

Goals are at odds with long term progress. It can create a yo-yo effect. As soon as you achieve the goal, you may have nothing to push you forward. True long-term thinking is goalless thinking. Endless refinement and continuous improvement.

Bad habits repeat themselves again and again because you have the wrong system. {{c1::Atomic habits}} are small habits that build a larger system that will deliver remarkable results in the long term. Each is a fundamental unit that contributes to your overall improvement. They build on each other and fuel bigger wins. A regular practice or routine that is small and easy to do and a component of the system of compound growth.

Habits are the compound interest of self-improvement but are a double-edged sword. It is therefore essential to understand them. Small changes appear to make no difference until a critical threshold. The most powerful outcomes of a compounding process will be delayed. To get better results: focus on your system. You fall to the level of your systems.
What is the philosophy of searching for a tiny margin of improvement in everything, in order to improve each individual thing to make the overall result better?
How does the effect of time generally change with respect to if you have good versus bad habits?
What is more important than where you currently are (Atomic Habits)?
Atomic habits notes that your outcomes are what?
What is the period of time where small good habits do not yield noticeable results while trying to improve at something?
What is the essential way to survive the plateau of latent potential?
What is the difference between goals and systems (Atomic Habits)?
Since successful and unsuccessful people often share the same goals, it cannot be the goals themselves that make some people successful. What should you do?
What is an alternative way to think to not have goals restrict your happiness?
What are small, easy to do things that contribute to your overall improvement and system of compound growth?
What is a way you can avoid having your progress slow down when you achieve a goal?
[...] magnifies the margin between success and failure.
Break down everything that you can think of that goes into something, make each thing better by 1%, and when you put it all together it will improve the overall result greatly: [...].
A [...] is often the result of many previous small actions that increased the potential of a sudden change happening.
The [...] is a strategy of searching for a tiny margin of improvement in everything that you do.
With [...], [...] is your ally, and with [...], it is your enemy.
The most powerful outcomes will be delayed: this is one of the reasons why it is hard to build [...].
[...] are small habits that build a larger system that will deliver remarkable results in the long term.
[...] are the processes that lead to the results.
Atomic Habits How your habits shape your identity and vice versa Study cards
The first mistake in trying to change habits is trying to change the wrong thing. There are three levels at which changes occur. The first is the outcomes. The second is changing the process (habits and systems). Most habits are at this level. The third and deepest level at which changes to daily habits occur is changes to your identity: changes to your beliefs, world view, self-image, judgements. To build habits that last, the problem is not that one level is better or worse. The direction of change is the problem. Start by focusing on who you wish to become rather than outcomes.

Behind every system of actions is a system of beliefs. There are a set of beliefs and assumptions behind the system. Behaviors that are inconsistent with the identity will not last. It is hard to change your habits without changing the underlying beliefs. The ultimate form of intrinsic motivation to perform a behavior or habit is when it is a part of your identity. Pride in an aspect of your identity will help you maintain habits related to that aspect. True habit change is a result of identity change. Improvements are only temporary until they become part of who you are. To say that the goal is to be a reader rather than read a book is an example of how habit changes are related to identity. When a person believes in an aspect of their identity, they will act in alignment with the belief.

Identity change can also work against you: your allegiance to it may make it difficult to change your habits. "I'm not a morning person. I'm bad at math. I'm bad at using technology. I'm bad at remembering names." You might resist taking steps forward if it would be against your identity. In some cases, the biggest barrier to positive change can be conflicts with the identity. It will be difficult to create good habits if they conflict with your identity. You must continuously change your beliefs to upgrade and expand your identity--do not get too attached to one version.

The two step process to changing your identity.


Some aspects of your identity do not change over time, like your height, but the way you think about your height can change over time. Habits are important in the formation of your identity simply because repeating a behavior over and over provides a lot of evidence for what it is.

Your habits are not the only thing that influence your identity. They are just one of the most important things that do. Repeated actions accumulate evidence which changes your self image. One off experience can have an effect but it will not be as prolonged. So, building happens is the same process as changing yourself or becoming a different person. We continually are undergoing microevolutions of the self. Habits are suggestions of who you are: every action you take is a vote for the type of person you become.

Meaningful change does not require radical change. A few good small habits are still a meaningful change because they give evidence to change your identity. The most practical way to change who you are is to change what you do. When you work out, you are an athlete. When you encourage others, you are a leader. When the evidence begins to change, the story you tell yourself will also change. Every time you perform a bad habit, it is a vote for a worse version of yourself. But it is okay for a few votes go to the bad outcome. An election does not require every vote to go one way to win.

The two-step process to change your identity: decide the type of person you want to be, and then prove it to yourself with small wins. What are your principles and values and who do you wish to become? It is easier to think about the results you want. Work backward from the results you want to the type of person who could get the outcome that you want. "What would a healthy person do?" may be a question that if you ask yourself throughout the day, you will lose weight.

There is a feedback loop between habits and identity--let your values, principles, and identity drive the loop.

Why habit changes matter


Identity change is the north start of habit change. The first step is who. You need to know who you want to be. You have the power to change your beliefs about yourself. Choose the identity you want to reinforce today with the habits that you choose today. Building better habits is fundamentally about becoming someone. Habits matter because they help you become the person you want to be. You become your habits.

The most effective way to change your habits is to focus on your desired identity and then cast votes for it. To become the best version of yourself, you must continuously edit your beliefs and upgrade and expand your identity. Habits can change your beliefs about yourself. The habits are like votes for the person you become.
Atomic Habits points out that true, long-lasting changes in habits are a result of what?
What are the three layers that you can focus on change in (Atomic Habits)?
What is the deepest layer at which habit change can happen?
What is the optimal direction of change in the 3 layers in the habit change onion?
Behavior that is what will not last according to Atomic Habits?
What may be the biggest barrier to positive change when trying to form good habits?
To become the best version of yourself, what must you always be doing?
Each time you repeat a habit is like a vote for what?
What is the simple two step process to change your identity according to Atomic Habits?
What is the North Star of habit change?
What contributes a lot to the formation of your identity purely due to how often they contribute to the evidence of who you are?
Atomic Habits How to Build Better Habits in 4 Simple Steps Study cards
Behaviors followed by satisfying consequences are likely to be repeated, and those followed by unpleasant consequences are less likely to be repeated.

A {{c1::habit}} is a behavior that has been repeated enough times to become automatic. The process begins with trial and error. Given a new situation, you will not know what to do, so you try things out to see what works. You make conscious decisions about how to act. Occasionally, you stumble across a solution. Exploring, exploring, exploring leads to stumbling a reward and your brain will catalogue the events that preceded the reward. With practice, the useless movements fade away, and the useful actions get reinforced (that is a habit forming). When a problem is faced repeatedly, the brain automates the process of solving it. Habits are a series of automatic solutions to regular problems. They are reliable solutions to recurring problems in our environment. As habits are created, the level of activity in the brain decreases. More information can be tuned out because you know what is relevant to focus on. These cognitive scripts can be followed automatically when the situation is appropriate. A habit is a memory of the steps you previously followed to solve a problem in the past. Given the right conditions, you draw on the memory and apply the solution. The conscious mind is the bottleneck of the brain. When possible, the conscious mind can pawn tasks off to the nonconscious mind to do automatically. Habits reduce cognitive load and free mental capacity to allocate attention to other tasks.

Habits do not restrict freedom, they create it (consider the effects good financial, health, and learning habits). Mental space is created for free thinking and creativity by getting the basics of life handled automatically by habits.

The backbone of every {{c1::habit}} is four steps: {{c2::cue}}, {{c3::craving}}, {{c4::response}}, and {{c5::reward}}.

Cue, craving, response, and reward are the four steps that can be translated into laws into building habits. This is the backbone of every habit.

The cue triggers the brain to initiate a behavior. It is some information that predicts a reward. It is the first indication that we are close to a reward and lead to a craving. Craving is the reason to act. What you crave is the change in state delivered by the habit. Cues are meaningless until they are interpreted. The response is the performance of the habit. Whether a response occurs depends on motivation, friction, and ability. The response delivers a reward, the end goal of every habit. Rewards serve two purposes: they satisfy us, and they teach us. The first purpose is to satisfy your craving. Rewards teach us which actions are worth remembering in the future. Rewards close the feedback loop. If the reward fails to satisfy, there is no reason to do it again in the future. This can be called the habit loop. Cure, craving, response, reward allows you to create habits.

This is an endless feedback loop that happens constantly. It can be split into two phases: the problem phase and the solution phase. The solution phase is the response and reward. All behavior is driven by the desire to solve a problem, which might be just that you notice something good and want to achieve it.

We need to put the four steps into a practical framework: the four laws of behavior change.

Each law can be thought of as a lever. When the levers are in the right positions, creating new habits is effortless.

To make a good habit: Make the cue obvious. Make the craving attractive. Make the response easy. Make the reward satisfying.

Invert the laws to break a habit. Make the cue invisible. Make the craving unattractive. Make the response difficult. Make the reward unsatisfying. 
What are behaviors that have apparently been repeated enough times to become automatic?
Given a new situation where you do not know what to do, naturally you use trial and error and make conscious decisions, occasionally stumbling on something that works. Over time, the useless actions fade away, and the more useful actions that work get reinforced. This is a description of what?
What might be called automatic solutions to regular problems?
What might be considered reliable solutions to recurring problems in our environment?
What are like cognitive scripts that can be followed automatically when the situation is appropriate, memories of steps you previously followed to solve problems in the past?
What are useful because they reduce cognitive load to allocate attention to other tasks?
What four steps are the backbone of every habit and can be translated into laws for building habits?
What is the step related to a habit where some information that predicts a reward is close is noticed?
What is the step in a habit where there is a reason to act (an interpretation of a cue)?
What is the step related to a habit which is the performance of the habit?
What is the step related to a habit which is the end goal of the habit (what is delivered by the response)?
What are the two purposes of the rewards in habit performing/forming?
To make a good habit, what should you make the cue?
To make a good habit, what should you make the craving?
To make a good habit, what should you make the response?
To make a good habit, what should you make the reward?
To break a bad habit, what should you make the cue?
To break a bad habit, what should you make the craving?
To break a bad habit, what should you make the response?
To break a bad habit, what should you make the reward?
The backbone of every [...] is four steps: [...], [...], [...], and [...].
A [...] is a behavior that has been repeated enough times to become automatic.
Atomic Habits The Man Who Didn't Look Right Study cards
The {{c1::brain}} is a prediction machine that notices with repeated experiences what is important and encodes the relevant cues. With enough practice, you can pick up on the cues that predict certain outcomes. We cannot explain what it is we are learning, but we are learning. The foundation for every habit is the ability to notice the relevant cues in a given situation. We underestimate how much we can do without thinking. You are much more than your conscious self. Appetite and hunger are governed non-consciously. You do not need to be aware of the cue for the habit to begin. This makes habits useful and also dangerous. Actions come under the direction of the automatic mind, and you can fall into the pattern of old habits without even realizing. The more you repeat them, the less likely you are to question what you are doing. Cues can be so common that they are essentially invisible. We must begin the process of change with awareness. We need to get a handle on our current habits before we form new ones.

Pointing and calling is a safety system that reduces errors and accidents used in the Japan railway system. It raises the level of awareness by using eyes, hands, mouth, and ears. The more automatic a behavior is, the less likely we are to think about it, and we may be more likely to overlook things. Failures in performance can be attributed to a lack of self-awareness. We should maintain awareness of what we are actually doing. This is the origin of the habit score card. Make a list of your daily habits. Look at each behavior in the full list and figure out if each is good, neutral, or bad. Habits being good or bad may depend on what you are working toward. It can be a little more complex because good and bad habits are inaccurate labels. Really, it is about if they are effective or not. Consider how they will affect you in the long run when classifying them as good or bad. Does this behavior help me become the type of person I wish to be? Is it a vote for the type of person I want to be? First, notice what is actually going on. Acknowledge what is currently happening. The first step to get rid of bad habits is to look out for them. Say out loud: I am about to eat this cookie, but I do not need too. Make the consequences more real by saying this, which adds weight to the action. Pointing and calling, and the habit score card, are about figuring out what the habits are and their cues.
What is a strategy for getting rid of bad habits that is to simply point to and declare that the habit is about to happen when the cue is noticed?
If you were trying to lose weight and noticed yourself about to eat a cookie, and said out loud "I am about to eat this cookie, but I do not need to" this would be an example of what strategy?
If you wanted to be a person who did not lay in bed for a long time in the morning, and were about to start looking at your phone, but said "I am about to start scrolling on my phone while laying in bed which will delay starting my day" this would be an application of what strategy?
If you were trying to break the habit of picking at your fingernails, and as you were about to do so, noticed and said "I am about to ruin the look of my fingernails to satisfy some kind of anxiety" this would be doing what?
To make a list of all of your daily habits, and score them as good, bad, or neutral based on if they will help you to become the type of person you want to be in the long run, is what strategy?
In constructing a habit score card, what is the criteria for a habit to be considered a good habit?
Pointing and calling and the habit score card are strategies for essentially doing what?
The [...] is a prediction machine that notices with repeated experiences what is important and encodes the relevant cues.
Atomic Habits The Best Way to Start a New Habit Study cards
An implementation intention is a plan of how to implement a particular habit.

Cues can have a very wide range of forms. The two most common are time and location. Implementation intentions leverage both of these. The format is "When x arises, I will perform response y." Studies have shown that implementation intentions are effective: they increase the odds of sticking with habits. Voter turnout can be increased by forcing people to create them. People who make a specific plan for where and when they will perform a new habit are more likely to follow through. Telling yourself "I am going to be healthier" without making a concrete plan will not be as effective. People may think they lack motivation, but they may really lack clarity. Once the implementation intention is set, you do not need to wait for the right moment. Simply follow your predetermined plan.

I will x [behavior] at y [time] in z [location]
I will meditate for 1 minute at 7 am in my kitchen.
I will exercise for 1 hour at 5 pm in my local gym.

Another benefit is that it can help you to say no to things that will pull you off course. If you have vague dreams, you can rationalize little exceptions all day long and not see the actual things you need to do to succeed. You want to get the urge to do the right thing at the right time even if you do not remember why. You might start to get antsy around the time of day you do not work out if you do not go the gym, for example.

Habit stacking


The Dittero effect: obtaining a new possession often creates a spiral of consumption that leads to additional purchases. Many human behaviors follow a similar pattern where the next action follows naturally from the last action. The previous action was the cue. Identify a current habit, and then stack a new behavior after. It is a special form of an implementation intention. Pair the new habit with an existing habit. This can be used to design an obvious cue for any habit.

After current habit x, I will new habit y.
After I pour my cup of coffee, I will meditate for 1 minute.

The key is to tie your desired behavior into something you already do each day. Then you can take advantage of the natural momentum, like a positive version of the Dittero effect. You can also insert new behaviors into the middle of current routines. For example, place a book on your pillow between getting out of bed and going into the shower. The key is selecting the right cue to kick off the behavior. Brainstorm and search for the best place to insert new behaviors into your lifestyle.

Habit stacking works best when the cue is highly specific and immediately actionable. The more tightly bound the habit to a specific cue, the more likely you are to act. Remember the first law is to make it obvious. Implementation intentions and habit stacking are strategies to make it obvious. 
What is a plan of how to implement a particular habit?
Increasing voter turnout by having people create a specific plan for where and when they will vote is an example of the effectiveness of what?
What is the basic format of an implementation intention that leverages two common forms of cues, time and location?
What is the effect where one purchase leads to a spiral of consumption and additional purchases?
What technique is a special form of an implementation intention where a current habit is identified and then a new behavior is performed after it?
Implementation intentions and habit stacking are strategies that both help to do what?
Atomic Habits Motivation is Overrated; Environment Often Matters More Study cards
People often choose things because of where they are. Your habits change with the cues around you and certain behaviors arise in certain environments. We are changed by the world around us. Habits are context dependent.

Behavior is a function of the person in their environment.
B = f(P, E)

Suggestion impulse buying is triggered when a product is seen for the first time and a customer visualizes a need for it. Expensive brand names will be found on the end caps and shelves at eye level. The more obviously available something is, the more likely you are to buy or try it. Our choices may not be driven by drive and choice but by the most obvious option.

We perceive the world with the senses but also with other ways. You can notice falling off balance or when a storm is about to happen. The most powerful sensory ability is vision. We are more dependent on vision than any other sense and so visual cues are the biggest thing to focus on. It is important to live and work in environments filled only with productive cues and devoid of unproductive ones.

You can be the architect of your environment. Every habit is initiated by a cue. We are more likely to notice cues that stand out. It's easy to not practice guitar when it is hidden. Creating obvious visual cues can draw your attention toward good habits. Redesign the environment. Put your apples in an obvious place and you will be more likely to eat them. Put your pill bottle right next to the bathroom counter. To drink more water, put full water bottles around the house. Make the cue a big part of your environment. The most consistent behaviors usually have multiple cues (consider smoking). Sprinkle triggers for good habits throughout the surroundings. Make the best choice the most obvious one. Environment design is powerful too because it is something you rarely do. Increase exposure to positive cues and remove negative ones. Be the designer of your world.

The cues that trigger a habit can start specific but over time the trigger becomes a bigger context. Habits are mentally assigned to the locations in which they occur. You establish a particular relationship. Our behavior is not defined by the objects. It is our relationship to them. Stop thinking of the environment as objects and think in terms of relationships and how you interact with places around you. Different people can have different memories and thus habits associated with the same place. Insomniacs should not stay in bed if they are not tired. This will help to associate the bed with the action of sleeping, rather than browsing their phone with the environment there. Habits can be easier to change in a new environment too. Create a new routine in a new place.

Have a clear dividing line between work life and personal life. Avoid mixing the context of one habit with another. The easier one will usually win. For example, you can use your phone to do nearly anything. You can be productive with it but also check social media. If your space is limited, divide the room into activity zones. Every habit should have a home. Each context will become associated with a specific habit and mode and thought. Focus can come automatically when sitting at the work desk. If you want behaviors that are stable and predictable, the environment must be so too.

Every habit is initiated by a cue. Make the cues of good habits obvious in the environment. Soon the entire context will become the cue.
What is the equation for behavior given in Atomic Habits?
What should you sprinkle into your environment according to Atomic Habits?
What matters more than motivation according to Atomic Habits?
Atomic Habits The Secret to Self-Control Study cards
Addictions may be able to spontaneously dissolve during a drastic change in the environment. There were high levels of heroin use by soldiers in the Vietnam war, but the majority of them returning home did not continue to use heroin. This challenges the notion of bad habits as a moral weakness such as not having discipline. When analyzing people who appear to have tremendous self-control, it turns out they are better at structuring their lives in a way that it does not require willpower and self-control. It is easy to practice self-constraint when you rarely need to use it.

An encoded habit is ready to be used whenever the situation arises. The urge to act follows whenever the environmental cues appear. Cue induced wanting: an external trigger causes a compulsive craving to repeat a bad habit. Quickly showing addicts a picture of cocaine sparks desire. It is too fast for the brain to register. Once the mental grooves of a habit are carved, they stay. Resisting temptation is possible in the short term but the real thing for the long run is to change the environment. Also, cut bad habits off at the source. Reduce exposure to the cue that causes it. Make the cue invisible. By removing the cue, the entire habit may fade away. You can resist temptation once or twice but will not be able to raise the necessary willpower every time. Energy is better spent optimizing the environment.
What does Atomic Habits say about the conclusion when people who appear to have tremendous self-control are analyzed?
Since the mental grooves of an encoded habit are basically permanent, what is the long-term solution to get rid of a bad habit?
Atomic Habits argues that your energy that could be put into willpower to avoid performing a bad habit is better used on what?
What happened with the majority of soldiers using heroin in the Vietnam war after they returned home?
What condition does Atomic Habits point out makes it easy to practice self-constraint in life?
Atomic Habits How to Make a Habit Irresistable Study cards
A {{c1::supernormal stimulus}} is a heightened version of reality that elicits a stronger response than usual: junk food. Foods high in sugar, salt, fat, and dynamic contrast in texture to excite your brain to the maximum extent possible. More palatable foods that are more satisfying to your brain make it easy to make it a habit to eat those foods.

If you want to increase the odds that a behavior will occur, you need to make it attractive. Not every good {{c1::habit}} can be transformed into a {{c2::supernormal stimulus}}, but we can still make them more enticing.

The start of the {{c2::craving}} of a habit can be tracked by measuring {{c1::dopamine}} (this makes mice behave like crazy). Habits are a feedback loop involving dopamine (which plays roles in motivation, learning and memory, punishment and aversion, and voluntary movement). {{c1::Dopamine}} is released when anticipating pleasure in addition to the pleasure itself (Atomic Habits). Dopamine increases when anticipating a reward and this is what gets us to take action. The system that is activated when you receive a reward is the same as the anticipation. This is the difference between wanting and liking. More neural circuitry is allocated for wanting than liking rewards. 100% of the {{c1::nucleus accumbens}} is active during wanting but only 10% during liking (Atomic Habits). Desire is the engine that drives behavior.

We need to make our habits attractive because it is the expectation of a rewarding experience that motivates us to act.

Temptation bundling


Temptation bundling works by linking an action you want to do with something you need to do. Businesses do this a lot. ABC launched a Thursday night television lineup where every Thursday, the company aired 3 shows by the same screenwriter, branded it, and encouraged viewers to enjoy the evening with popcorn and wine. The brilliance is that they associated the thing they wanted the viewers to do with the things the viewers wanted to do anyway (drink wine and eat popcorn). The habit of turning on the TV becomes more attractive. Something will be more attractive if you get to do something you like to do anyway at the same time. Temptation bundling is a way of applying the Premack Principle: more probable behaviors will reinforce fewer probable behaviors.

After [habit I need], I will [habit I want].

Doing the thing you need to do will mean getting to do the thing that you want to do. It creates a heightened version of a habit you want by linking it to an already attractive habit.
What is a heightened stimulus that elicits a stronger response than is natural (e.g. junk food engineered to have the optimal amounts of salt, sugar, fats, and dynamic contrast to excite your brain to the maximum extent possible)?
What chemical plays important roles in motivation, learning/memory, punishment/aversion, voluntary movement, anticipating pleasure, and pleasure itself?
What neurotransmitter increases during the anticipation of a reward according to Atomic Habits?
Atomic Habits discusses the rise of dopamine when anticipating a reward to argue what?
What technique is to link an action that you want to do with something that you need to do?
What principle says that more probable behaviors will reinforce less probable behaviors?
What is the format of the implementation intention when using the temptation bundling technique?
What is a technique that applies the Premack principle to create a heightened version of a habit you want to have by following it with a rewarding (possibly even bad) habit?
Not every good [...] can be transformed into a [...], but we can still make them more enticing.
The start of the [...] of a habit can be tracked by measuring [...] (this makes mice behave like crazy).
A [...] is a heightened version of reality that elicits a stronger response than usual: junk food.
100% of the [...] is active during wanting but only 10% during liking (Atomic Habits).
[...] is released when anticipating pleasure in addition to the pleasure itself (Atomic Habits).
Atomic Habits The Role of Family and Friends in Shaping Your Habits Study cards
Everyone wants to belong and so going along with the group is natural. Behaviors can be attractive when they help us fit in. Having a strong desire to fit in means we often have habits aligned with the culture we live in.

We imitate the habits of three groups: the close, the many, and the powerful.

The close


Proximity has a powerful effect on our behavior. We pick up habits from the people around us. The closer you are to someone, the more likely you are to imitate some of their habits. We soak up the qualities and practices of those around us. You should join a culture where the habits are your desired habits. Culture sets the expectation for what is normal. Surround yourself with people with habits that are the same as those you want yourself.

The many


When we are unsure how to act, we scan the environment and see what others are doing. It can be a smart strategy. However, the normal behavior of the group can overpower the desired behavior of the individual. Change is attractive when it means fitting in.

The powerful


People in general want power and to be recognized. We can copy the habits of successful people in order to become successful ourselves.
What are the three groups whose habits we imitate according to Atomic Habits?
Since you tend to pick up habits from the people close to you, what kind of people should you surround yourself with?
Atomic Habits How to find and fix the causes of your bad habits Study cards
One way to quit smoking would be to reframe every {{c1::cue}} to begin doing it as an undesirable, unattractive, or even stupid thing to do.

Every behavior has a surface level {{c1::craving}} and a deeper underlying motive (Atomic Habits). For example, somewhere, deep down, you eat tacos because you have to eat to survive even if the specific craving is for a taco. Underlying motives: conserve energy, reduce uncertainty, connect and bond with others, achieve status, find food and water, find a mate, reproduce.

Cravings are specific manifestations of deeper underlying motives. The brain did not evolve to smoke cigarettes, check social media, or play video games. At a deeper level, you want to reduce some anxiety for example. Products that are habit forming tend to latch onto the underlying motives. Find love and reproduce might mean Tinder. Status and prestige could come from video games.

Habits are like modern day solutions to ancient problems. There are many different ways to address the same underlying motive. You could smoke a cigarette or go for a run to deal with anxiety.

Current habits are not necessarily the best solution to a problem. The brain continually notices cues and makes predictions about what to do next. See a cue, categorize it based on prior experience, and determine what to do. Life is predictive: you make your best guess at what to do based on historical information. Behavior is heavily dependent on the interpretations of the cues. The same cue can spark a good or bad habit. The prediction that comes before the habit is the cause.

Cravings are typically described as feelings that transform signals into things that prompt us to act: a gap between the current state and the desired state that provides a reason to act. What you really want is to feel different.

When emotion and feelings are impaired, we lose the ability to make decisions according to what neurologists have discovered. The specific cravings you feel and habits you perform are meant to address underlying motives. Habits are attractive when we associate them with positive feelings. It is emotion that allows you to mark things as good, bad, or neutral.

To make hard habits more attractive, learn to associate them with a positive experience. Replace "have to" with "get to" to see behaviors as opportunities instead of burdens. Both are true. You can find evidence for the mindset that you choose. Highlight the benefits of your habits to make them seem more attractive. Exercise could be viewed as a way to develop skills and build you up. "It's time to build endurance and get fast." "Living below my current means increases my future means." See distractions popping into your mind during meditation as chances to practice returning to your state of meditation. "I am excited and getting an adrenaline rush to help me concentrate" instead of "I am nervous."

Reframe the associations you have about bad habits. Reprogram your predictions. Highlight the benefits of avoiding bad habits.
Atomic Habits describes a different book that helps people quit smoking by doing what?
What are the two reasons behind every behavior according to Atomic Habits?
What are specific manifestations of deeper underlying motives?
What might be described as modern day solutions to ancient problems?
What are like gaps between the current state and a desired state, or a want to feel different that is triggered by a signal?
What can you use to mark things as good, bad, or neutral (as a tactic to make yourself enjoy good habits or hard things)?
To make hard habits more attractive, you must do what?
To some people, distractions during meditation could be frustrating, but an alternative way to frame them could be what?
If someone is angrily getting into an argument with you, how should you frame this cue?
If you find yourself trying to look at the past or future, how should you frame this cue?
One way to quit smoking would be to reframe every [...] to begin doing it as an undesirable, unattractive, or even stupid thing to do.
If you are feeling dissatisfied with your current self in some context (feelings of inferiority), how should you frame this cue?
Every behavior has a surface level [...] and a deeper underlying motive (Atomic Habits).
Atomic Habits Walk Slowly, But Never Backward Study cards
Two groups of students taking a college course were divided into a quantity group and quality group for taking photos. At the end of the course, the quantity group had produced all of the photos of the highest quality.

Motion vs. taking action. Motion is planning, strategizing, and learning. Action is the behavior that delivers an outcome. It is the difference between reading about diet and eating a healthy meal. Motion sometimes allows us to feel that we are making progress without the risk of failure. It can allow us to delay failure.

The key to mastering a habit is to start with repetition and practice. Just get reps in.

Habit formation may be related to {{c1::long-term potentiation}} (with each repetition, neural connections tighten--Atomic Habits). Hebb's law: neurons that fire together wire together. Repetition of a habit leads to clear physical changes in the {{c1::brain}}. Brain regions adapt similar to how muscles change with weightlifting.

Great difficulty is felt when learning something completely new. Repetition and engaging in active practice are essential to forming new habits. The students that took lots of photos spend time getting in reps in action and it resulted in them taking the best photos.

Automaticity is the ability to perform a behavior without thinking about each step. It occurs when the nonconscious mind takes over. A habit that is repeated more and more gradually becomes more and more automatic. Habits form based on frequency, not time. "How many?" is a better question to ask about forming a new habit than "how long?" What matters is the rate at which you perform the behavior. Take the actions you need to take to make progress. To build a habit, you need to practice it.
What outcome was a result of a study where college students taking a course were divided into a quantity group and quality group for taking photos over a semester?
What is the difference between motion and action in Atomic Habits?
The difference between reading about healthy dieting and eating a healthy meal demonstrates the difference between what?
What is the key to mastering a new habit?
What could be summarized as "neurons that fire together wire together?"
How is long-term potentiation related to repetitions and practice causing a behavior to gradually become automatic?
What is the ability to perform a behavior without thinking about each step?
Automaticity, being able to do something without thinking about each step involved, means what is taking over?
Essentially, to build a new habit, you must do what (one word)?
Habit formation may be related to [...] (with each repetition, neural connections tighten--Atomic Habits).
Repetition of a habit leads to clear physical changes in the [...].
Atomic Habits The Law of Least Effort Study cards
Conventional wisdom holds that motivation is the key to habit change. The truth is our motivation is to be lazy. It is human nature to follow the law of least effort. People naturally gravitate towards the path that requires less work. We want the most value for the least effort. Every action requires a certain amount of energy. The less energy that a habit requires, the more likely it is to occur. It is crucial to make your good habits so easy that you can do them when you don't feel like it. Some days you feel like putting in a lot of work and other days you will not. The less friction you engage, the easier it will be for your stronger self to emerge.

Making your habits simple and easy reduces the friction. Environment design is one easy way to reduce friction to make actions easier (in addition to making cues of good habits obvious). Choose a place to perform a habit that already fits in to the flow of your life. Pick a gym that is on the path of your normal commute, for example. Reduce the friction within your home or office. Do not try to write a book in a chaotic household.

Addition by subtraction: remove every point of friction possible. Remove points of friction that sap our time and energy. Successful companies produce products that automate, eliminate, or simplify as many steps as possible. Make creating an account take as few clicks as possible, for example. Create an environment where doing the right thing is as easy as possible. Reduce friction to do good habits, and increase the friction required to perform bad ones.

Organizing a space for its intended purpose makes the future actions there easier. Resetting the room every time before you move to the next room is a way to always make sure the environment is primed for immediate use. Set out your workout clothes ahead of time. Chop up fruits and veggies on the weekend and pack them for the week. These are just examples of easy ways to make good habits have less friction. You can also do the opposite with bad habits. Leave your phone in a different room if you don't want to be distracted by it. Just a little friction can be used to stop undesirable behavior. Design the world and your life where the actions that matter most are the actions that are easiest to do.
What does conventional wisdom hold is the key to habit change (and what might the truth about that answer really be)?
How can you design your good habits so that they are easy to do even when you don't feel like it?
What can reduce friction to make good habits easier in addition to make the cues of good habits obvious?
If you were choosing a place to perform a good habit, what type of place should you choose?
Atomic Habits How to stop procrastinating by using the two minute rule Study cards
A {{c1::habit}} can have a powerful influence by determining what follows for minutes or even hours afterward if it acts as a {{c2::decisive moment}}.

There are a handful of moments every day that are decisive moments: forks in the road between spending time doing your homework or playing video games.  A {{c1::decisive moment}} is a times where an action or decision sets the options available to your future self. Walking into a restaurant is a {{c1::decisive moment}} that decides what food options you will have to eat. The first choice determines the options for the future choice. Every day has many moments but a few of them determine how you spend larger chunks of time and are decisive moments.

The 2-minute rule: when you start a new habit, it should take less than 2 minutes to do. Any habit can be scaled into a less than 2-minute activity. Read for 2 minutes before bed. It makes habits as easy as possible to start. Once you have started doing the right thing, it is much easier to continue to do it. Make gateway habits that naturally leads you down a more productive path. Putting on your running shoes is a gateway habit to running a marathon. The point is not to do one small thing, it is to master showing up to do it. If you can't do that, you will never get to optimizing all the right details. The first 2 minutes simply become a ritual at the beginning of a hard routine. You will be making it easier to slip into a state of deep focus. Make the first action mindless. The rest hopefully will follow.

A {{c1::gateway habit}} is a good habit that naturally leads you down a more productive path. Use the {{c1::2-minute rule}} to scale a new good habit into ones that can take hold and act as a {{c2::gateway habit}} into a longer period of productive behavior.

It can be good to always keep it below the point where it feels like work. For a habit like writing, stopping before it starts to feel like work will help you associate with it positive emotions and reinforce your identity. Even these small actions confirm the type of person who you want to be. One minute of reading is better than never picking up a book.

Stopping a good habit like writing when it is still going well can help you associate it with positive emotions and reinforce your {{c1::identity}}.

Nearly any larger life goal can be transformed into 2-minute behaviors that can be mastered one at a time. Making your habits take less than 2 minutes is a simple way to make your habits easy. When you start a new habit, it should take less than 2 minutes to do. Standardize before you optimize. You cannot improve a habit that does not exist.
That checking your phone for just a moment can lead to a significant time wasted shows what?
What are the everyday moments where your choice/behavior determines the set of options available to your future self?
The moment you choose between starting your homework or playing a video game is an example of what?
What is the 2-minute rule (Atomic Habits)?
Habits that start you down a certain path of spending your time could be called what?
You will never get to optimizing all the right details in an activity if you never do what?
A [...] can have a powerful influence by determining what follows for minutes or even hours afterward if it acts as a [...].
Stopping a good habit like writing when it is still going well can help you associate it with positive emotions and reinforce your [...].
Use the [...] to scale a new good habit into ones that can take hold and act as a [...] into a longer period of productive behavior.
Walking into a restaurant is a [...] that decides what food options you will have to eat.
A [...] is a good habit that naturally leads you down a more productive path.
Atomic Habits How to make good habits inevitable and bad habits impossible Study cards
A {{c1::commitment device}} is a present choice that locks in desirable behavior in the future and makes bad habits impractical.

Sometimes success is more about making bad habits hard. Make your bad habits more difficult by creating a commitment device. It is a choice you make in the present to lock in future behavior (restrict you from bad habits). E.g. throw all of your clothes away so you cannot leave your home and must focus on finishing writing your book. Reduce overeating by not buying food in bulk. Ask to be added to the banned list at casinos. Leave your wallet at home so you will not be tempted to buy fast food. Automate cutting off the Internet every night so everyone goes to bed. They allow you to prevent yourself from falling for temptation. The key is to change the task such that it requires more work to get out of the good habit.

The best way to break a bad habit is to make it impractical to do. Some actions can pay off again and again. Nutrition: buy a water filter. Use smaller plates. Sleep: buy a good mattress. Blackout curtains. Productivity: set your phone to silent. Delete games and social media. Happiness: get a dog. General health: buy good shoes. Get vaccinated. Finance: enroll in an automatic savings plan. Automatic bill paying. These one-time actions make good habits easier. Technology can transform actions that were once hard to habits that are simple. Particularly, behaviors that are not repeatedly frequently enough to become a habit. Automate as much of your life as possible to free up time and energy to do the things that the machines can't yet. Extend the number of operations you can perform without thinking about them.

Commitment devices, one-time choices, and technology are ways to guarantee the right behaviors.
What is a choice made in the present that locks in future behavior (restricting your future self from bad habits)?
To throw away all of your clothes so that you cannot leave your home and must focus on writing would be an example of using what?
A [...] is a present choice that locks in desirable behavior in the future and makes bad habits impractical.
Atomic Habits The Cardinal Rule of Behavior Change Study cards
We are more likely to repeat a behavior when it is satisfying. Pleasure teaches your brain that a behavior is worth repeating. Positive emotions cultivate habits. Making it satisfying increases the odds that a behavior will be repeated next time. It is immediate satisfaction that we need to make it satisfying.

We live in a delayed return environment. It is only recently that society shifted to this kind of environment. Compared to the age of the brain, modern society is extremely new. Human nature has changed comparatively little. It made sense in the past to place value on immediate gratification. The brain evolved to value the present more than the future. A reward certain right now may be worth more than a possible future one. The consequences of bad habits are delayed while the rewards are immediate: smoking a cigarette, eating unhealthy food, having unsafe sex. Bad habits: the immediate outcome is enjoyable, but the ultimate outcome is bad. Good habits can be the opposite.

As a general rule, the more immediate pleasure you get from an action, the more you should question if it is aligned with your long-term goals. The brain tends to underestimate distance threats and overestimate immediate threats. What is immediately rewarded is repeated, and what is immediately punished is avoided. The road less travelled is the road to delayed gratification. The last mile is always the least crowded. People who are better at delaying gratification have better outcomes in many different ways. Success in most fields requires you to delay gratification.

Add a little bit of immediate pleasure to habits that pay off in the long run. Add a little bit of pain to those that will not.

Immediate rewards keep you excited while the delayed rewards form in the background. Reinforcement uses an immediate reward to increase the rate of a behavior. It can be useful when trying to break a bad habit that is simply avoiding doing something like not spending extra money.

The more a habit becomes a part of your life, the more it becomes a part of your identity, and the more likely it will last and deliver the delayed rewards.
What is the law of behavior change (Atomic Habits) that is unlike the other laws in that it increases the odds that a habit will be repeated next time?
What are habits where the immediate outcome is enjoyable but the ultimate and delayed outcome is bad?
As a general rule, the more immediate pleasure you get from an action, the more you should what?
Atomic Habits How to stick with good habits every day Study cards
The paperclip strategy: use a visual measurement of your progress to make it more satisfying.

A habit tracker is a thing where you track performing a habit. For example, marking days on a calendar. Ben Franklin had a booklet that he used to track how well he acted with 13 different virtues.

Habit tracking is obvious: it creates a trigger that naturally builds visual cues. Looking at the streak reminds you to act again.

Habit tracking keeps you honest. It helps you to really understand what is happening by putting the evidence right in front of you.

Habit tracking is attractive. The signal that we are making progress can have an addicting effect on motivation which can be very useful on a bad day, for example.

Habit tracking is satisfying. This is the most important benefit. Habit tracking becomes a reward on its own. It helps you stay focused on the process, rather than the result (focus on systems instead of goals).

Habit tracking provides visual proof you are becoming the type of person who you wish to become.

To make habit tracking easier, automate as much of it as possible. Manual tracking should be limited to your most important habits. Record each measurement immediately after the habit/behavior is performed. This combines habit stacking with habit tracking: after [habit], I will [habit tracking habit]. Even just a few weeks of measurements can be insightful.

No matter how consistent you are, it is inevitable that life will interrupt you at some point. The rule to follow is to never miss twice. You can miss a workout. Do not miss two in a row. The first mistake is not the one that will ruin you. Missing twice is the start of a new habit. Anyone can have a bad performance. Successful people rebound quickly when they fail. Do not fall into an all or nothing cycle with your habits. It is valuable to just show up on your bad or busy days. The first rule of compounding: never interrupt it unnecessarily. Bad workouts continue to accrue the compounding. It's also about being the type of person to not miss workouts. It is crucial to show up when you don't feel like it.

It is inevitable that life will interrupt your streak when habit tracking: showing up when you don't feel like it and never missing twice in a row are crucial to reinforcing the good identity you are or want to become.

Another potential danger is measuring the wrong thing. If you were running a restaurant and only tracked revenue, the food could be getting worse as you were putting more effort into marketing, and you wouldn't realize that the food was getting worse. Do not care more about taking 10,000 steps than being healthy. We tend to optimize for what we measure. Goodhart's law: when a measure becomes a target, it ceases to be a good measure. It's crucial to keep habit tracking in its proper place. Think of "non-scale victories" in weight loss while the scale doesn't budge. Habit tracking is a simple way to make your habits more satisfying.
What provides you with visual proof of progress toward becoming the type of person that you want to become?
No matter how consistent you are, it is inevitable that life will interrupt you at some point. The rule to follow is:
What should you do if you miss a workout?
What is a potential pitfall to avoid with habit tracking?
What is the most important benefit of habit tracking?
Atomic Habits The Truth About Talent
You should choose the right things to become great at. It is best if it aligns with your natural abilities or interests. Competence is highly dependent on context. If you want to be truly great, selecting the right place to focus is crucial.

The big 5 personality traits: openness to experience, conscientiousness, extraversion, agreeableness, and neuroticism. Our genes nudge us in a certain direction. Build habits that work for your personality.

If you are winning: exploit, exploit, exploit. If you are losing: explore, explore, explore. But even if you are mostly exploiting, spend some time exploring too. Work that hurts you less than it hurts others is the work you are meant to do. Flow is when you are so focused on the task at hand that the rest of the world fades away. If you are experiencing flow, you are finding it satisfying. When you feel authentic and genuine, you are moving in the right direction. When you can't win by being better, you can win by being different, by combining skills. A great player creates a new game that favors their strengths and avoids their weaknesses.

Until you work as hard as those you admire, do not attribute their skill to luck.
Atomic Habits The Goldilocks Rule Study cards
The way to maintain motivation and interest is to work on tasks of just manageable difficulty. The brain likes a challenge, but only in an certain optimal zone of difficulty.

Humans experience peak motivation when working on tasks just at the edge of their current abilities. This is called the Goldilocks rule.

When starting a new habit, make it easy. This is to make it stick even on hard days. Once the habit is established, you must continue to advance in small ways. This is to keep you engaged and reach a flow state (being fully immersed in an activity). To achieve a state of flow, the task must be roughly 4% beyond your current ability.

Really successful people feel the same boredom but continue to practice despite their boredom. The greatest barrier to success to boredom. Progress cna be derailed by seeking novelty as the habits become ordinary.

Many habit forming products provide continuous forms of novelty. This is known as a variable reward. Slot machines are a common real world example. The pace of the reward varies which leads to a great spike in dopamine, memory recall, and habit formation. They amplify cravings by reducing boredom. Working on challenges of just manageable difficulty is a good way to keep things interesting.

Eventually, you will need to fall in love with boredom. If you stick to a habit long enough, there will be days you will not feel like doing it simply due to boredom. Steeping up is the difference between a professional and an amateur. Professionals know what is important and work toward it with purpose. The greatest threat to success is boredom. 
What does Atomic Habits say is the way to maintain motivation and interest in something?
What does Atomic Habits say is the characteristic of a task that will allow a flow state to be achieved?
What is the greatest barrier to success according to Atomic Habits (not identity conflict which is just a barrier to forming positive habits)?
How do successful people react when they start to get bored practicing according to Atomic Habits?
What does Atomic Habits say you will eventually need to fall in love with in order to become really successful at something?
Atomic Habits The downside of creating good habits Study cards
Habits are the foundation of mastery. Knowing the simple movements so well that you can perform them without thinking frees you to think about more advanced details. However, falling into mindless repetition can make doing it better not possible. You get used to doing things a certain way and miss that you are making errors. You can be reinforcing your current habits rather than improving them. In fact, mastery can cause a slight decline in performance. For certain habits, good enough is good enough (brushing your teeth). To achieve elite levels, you cannot be blind. You need a combination of automatic habits and deliberate practice. Automatic habits + deliberate practice is what results in mastery. It is precisely when things start to feel automatic, you must avoid slipping into complacency. Establish a system of review.

The way to be successful: learn to do things right, and then do them right every time. Reflection and review enables the long-term improvement of all habits. It helps you to find paths to improvement. Top performers engage in various types of reflection and review. Improvement is not only forming habits but also focusing on the right things and improving habits. Do not continue practicing a habit if it is ineffective. Reflect on progress: what went well? what didn't go well? what did I learn? An integrity report can help you see how well you lived in alignment with your core values and as the type of person you want to be. What are the core values that drive me? How am I living with integrity now? How can I set a higher standard in the future? Consider how your habits are helping you become the type of person you wish to be. You might need to draw back on certain things and focus more on fundamentals. Do not lose sight of the bigger picture. Periodic reflection and review let you see the changes you can make without missing the bigger picture. Periodic reflection and review of your habits to see if they are being effective is also an ideal time to revisit your identity.

Break the beliefs that hold you back. Repeating a habit builds of evidence of your identity. The same beliefs might hold you back from the next level of growth. This can be a downside. The more sacred, and deep an idea is, the more it is attached to the identity, the more we defend it against criticism. Clinging to an identity makes it hard to grow beyond it. Keep your identity small. The more you let something define you, the less you will be able to adapt. The loss of that facet of your life would wreck you. Clinging too tightly to one identity means you become brittle. If you lose that, you will lose yourself. Someone who defines themselves in a way and then that disappears will wonder who they are. The key is to define yourself such that you get to keep important aspects of your identity even if your role changes. Instead of I am an athlete, I am mentally tough and enjoy a challenge. Instead of I am a CEO, I am the type of person who builds and creates things. Identities chosen effectively can be flexible and work with changing circumstances.

quote
Men are born soft and supple. Dead, they are stiff and hard.
Plants are born tender and pliant. Dead, they are brittle and dry.
Thus, whoever is stiff and inflexible is a disciple of death.
Whoever is soft and yielding is a disciple of life.
The hard and the stiff will be broken.
The soft and the supple will prevail.

Habits can lock us in to previous patterns and thinking. Life is constantly changing so you must check that your previous habits and beliefs are not holding you back.
What are the two things that result in mastery according to Atomic Habits?
In addition to automatic habits, what else is needed to achieve elite levels according to Atomic Habits?
What is the way to be successful according to Atomic Habits?
Atomic Habits Conclusion Study cards
The holy grail is not one single percent improvement. It is a thousand of them. In the beginning, small improvements may seem meaningless. One positive change is unlikely to deliver a noticeable difference. But as you gradually layer small changes on top of each other, the scales of life slowly tilt in your favor until a tipping point is reached. Success is an endless process to refine and improve. The secret to getting results that last is to never stop making improvements.
What does Atomic Habits say is the secret to getting results that truly last?
What is the holy grail in Atomic Habits?
What is success in Atomic Habits?
What will be the result if you never stop making improvements?
Atomic Habits 8. Testing Code Study cards

Testing Code


Untested software is bound to fail. Testing is a central construction technique.

Terminology - An error is something that you do wrong. It is a specific human action that results in software containing a fault. For example, forgetting to check a condition is an error. A fault is the consequence of an error. A failure is the departure of the program's operation from its requirements and may be the consequence of a fault. A bug is often used as a synonym for a fault.

Testing is a methodical process of providing the existence or lack thereof of faults in the software. Debugging is the act of tracking down the cause of this faulty behavior.

Good programming leads to more time spent testing than debugging.

QA: quality assurance. It is a name given to both a tribe of software factory inhabitants and a development practice. Testing is a small part of QA. QA is about prevention. QA ensures that the processes and development practices result in high-quality software.

An important thing to realize is that tests can only discover the presence of faults. It cannot prove the absence of faults.

Developers should not send code to QA that has not been tested. You must test every line of code that you write. Do not expect anyone else to do it for you.

Test code is the code we write to test the code. Code should be tested as it is written to catch errors at the first opportunity. This is also the time when the errors are easiest to fix and affect the fewest people. Testing early and thoroughly is the most effective way to ensure software quality.

Test-driven development advocates that you write the test code before the code being tested. This is a vital point to absorb into your programming routine. For each piece of code you write, do not move on until it is tested and you know that it works. Thinking about testing code at the same time as you think about writing some code will shape the way you design that code. Any fault that manages to slip past the existing tests must have a new test added to prove that the bug fix is correct. Write a test for every fault that you find.

Tests should be run as often as humanly possible and possibly even more often than that. This is embodied in a continuous integration strategy. Run your tests as often as you can.

The test harness must demonstrate these two things:
  • The correct output is generate for valid inputs
  • The appropriate failure behavior is generated for all invalid inputs

Read all code cynically. Do not accidentally read what you meant to write rather than what you wrote.

No matter how hard you test, you will miss something. Studies show that most carefully tested software contains 0.5 to 3 errors per 1000 LoC. Testing rarely proves that software is bulletproof. Only that it is adequate.

Types of tests


Unit tests are tests of atomic units: each class or function. Things are tested in strict isolation. Any untrusted external code with which the unit interfaces is replaced with a stub or simulator.

Component testing is a step up from unit testing. This validates the combination of one or more units into a full component. Often this is what people mean by unit tests.

Integration tests test the combination of components as they are brought together in the system.

Regression testing is retesting after fixes or modifications.

Load testing ensures that the code can handle the expected volume of data being thrown at it.

Stress testing throws a huge amount of data at the code within a short time to see what it does. Whereas load testing checks that code can meet expected demands, stress testing is about what will happen when it receives a real battering. It has to fail gracefully and recover well.

Soak testing involves a high load for a prolonged period of time. It may reveal faults that otherwise would go undetected.

Usability testing ensures that the software can be used easily by a shortsighted gerbil.

Black box testing, also known as functional testing, compares actual functionality against intended functionality.

White box testing is also known as structural testing. It is a code-coverage-based approach where each line of code is scrutinized to ensure correctness. Sometimes this is called glass box testing. There are static and dynamic methods of white box testing.

Remember that boundary cases are a rich source of error. Identify the highest and lowest inputs that are valid. Test behavior at the boundary, values above, and values below.

It can be a good idea to test randomly generate input data.

Always test for the zero case when the input is numeric.

The quality of unit tests you can write is largely determined by the quality of the interface you have to test. Testing is easier when the code is written thoughtfully and specifically designed to accommodate inspection and verification. You must design for tests up front.

Some design rules that lead to highly testable code: each section of code should be self-contained and without undocumented and tenuous dependencies on external things. Don't rely on global variables. Limit the complexity. Make the code observable.

The golden rule of testing is automate. Automate testing as much as possible.

Summary


Good programmers write tests for all their code. They test at the micro level so that macro level testing is not hindered by stupid mistakes. They care about product quality and take responsibility for it.

Bad programmers don't consider testing to be important. They release untested code. They make their lives more complicated by discovering problems too late.
What is bound to happen to untested software?
What is an error?
What is a specific human action that results in software containing a fault?
Can tests prove the absence of faults?
What is the code that we write to test the code called?
What should you always do when you fix a bug (related to test-driven development)?
What is a side effect of writing test code before or alongside the main code?
What is a case that should always be tested when the input is numeric?
What are the two things that must be demonstrated by the test harness?
Code Craft notes that what are a rich source of error and should be carefully tested?
How should all code be read according to Code Craft?
For each piece of code that you write, when should you move on?
What practice, and tribe that inhabits the software factory, ensures that the processes and development practices result in high-quality software?
What is the most effective way to ensure software quality?
A design rule for a section of code that leads to highly testable code:
What kind of tests stubs any untrusted external code with which the tested part interfaces?
What kind of tests validates the combination of one or more units into a full component?
What kind of test tests the combination of components?
What kind of test ensures the code can handle the expected volume of data as its input?
What kind of test throws a huge amount of data at the code within a short time to see what happens?
What kind of test involves a high load for a prolonged amount of time?
What largely determines the quality of unit tests?
What happens to bad programmers who don't consider testing to be important and release untested code?