Motherhood: Separation of Concerns

Being a mother often means wearing several different “hats” based on who you’re with and where you go. Consider the following hats: counselor, chef, bestie, maid, playmate, doctor, event coordinator, seamstress. Oh, and of course, at some point you should take the hats off and just be yourself.
For some us, being a mother means wearing ALL the hats. ALL the time. If you are a mom, you know that’s a dangerous game. Without a little organization, you’re going to burn out almost immediately. So many new moms, myself included, try desperately to balance all the hats in the first few weeks of their little one’s life only to find themselves crying while staring at all the hats on the floor.
Let’s paint the scene shall we.
Nursing is a complete bust this morning because Baby won’t latch. Mom is stressed because it’s 2am and she’s tired which isn’t helping. Mom decides to warm up a bottle instead. Baby’s crying += 10 because Mom is within eyesight but food isn’t happening. Mom grabs Baby and decides to throw a load of laundry in the washing machine while bottle warms up. Baby’s crying += 10 because food still hasn’t happened. Big baby wakes up because Baby is crying. Big baby asks for food. Mom throws clothes in, adds detergent, and forgets to turn on washing machine. Mom pours a bowl of cereal for Big Baby. Baby’s crying += 10 because Big Baby is eating and Baby isn’t. Mom bounces baby and tries to sing song to calm baby down. Mom remembers that bottle is warming and rushes to grab it. Bottle is too hot. Baby’s crying += 10 when bottle is within eyesight but not within mouth. Mom’s crying begins. Big Baby asks mom what’s wrong. Mom’s crying += 10. Dad wakes up, comes into kitchen and asks Mom what’s wrong. Mom’s crying += 10. Dad offers to feed baby. Dad takes baby and bottle and tests bottle. Dad says “yikes honey. This bottle is way too hot.” Mom kills Dad, Baby, and Big Baby and then calls the police. Mom sits calmly on the couch watching tv and eating Big Baby’s cereal while waiting to be arrested. Mom’s crying = 0. Mom’s peace += 100.
Let’s retell this story with code. (Ruby is bae, so I’m using Ruby for our example.)
Let’s say we have a class called .Mom that initializes with a name and a baby. In that class we define one method named #do_all_the_stuff. That method is full of all of the actions society tells a mother she has to do and do well in order to be considered a “good” mom. The problem is that if we define it as we have above, she has to do them all at once. This breaks the mom. As a decent human being, we understand this. We don’t really expect her to do all the things at the same time. What we need as parents and as developers is what’s called “Separation of Concerns.”
Separation of Concerns, also known as the Single Responsibility Principle, is the principle that each method should have one task and one task only to complete. The two main benefits of this principle are that the method will run faster and any bugs in our program will be easier to track down.
Let’s break out some of Mom’s functionality.
Now when a new Mom is initialized, she can complete each task one at a time. This will also allow us to decide which methods to run and in which order.
For example, these days, I run new_mom.get_rest before I do anything else. When I don’t, the rest of my methods don’t run right. I know that’s where the bug is.
Notice that in our #make_breakfast method we have more than one concern. our new_mom has to gather ingredients and cook each of them differently. We could further break these out into different methods for even more separation of concerns. For example, we could create a #gather_ingredients method that has new_mom collect everything she needs to make breakfast before starting a #cook method. That would make the main concern of our #make_breakfast method to be determining which order to run those methods in, in order to successfully make breakfast. Once we have a group of methods that seem to have related tasks, we could simply create a new class to encapsulate those in.
Coding principles aside, research has shown that multi-tasking, the opposite of separation of concerns, is not only stress-inducing but fairly impossible. While you may think that you’re doing two things at once, what you’re actually doing is focusing on one thing and hoping that the other runs on auto-pilot without incident. This is why texting and driving is so dangerous. You’re either focused on the text and letting the car drive itself or you’re focused on driving and the letting the text write itself.
Here’s a few tasks you can break out into different methods for more separation of concerns in your life:
- Texting and driving. Please be safe! It can wait, I promise.
- Making pancakes and washing dishes. Perfect pancakes require your undivided attention! They can’t wait for you to dry your hands!
- Self-care and child-care. You may be tempted to bake cookies with the kids because you love baking. And don’t get me wrong, it’s fun, but it’s not the same as doing something purely because it’ll make you feel good. Wait until the little ones take a nap, and bake just enough cookies to not share. They’ll taste better.
- Parenting and romance. Set time aside to be a good parent. The world thanks you in advance for that. Also, set separate time aside dedicated to enjoying your partner. The easiest way to do this is to find a babysitter and actually leave the house. With no kids to wake up or chores staring you, you’ll find your partner is still as much fun as they used to be. My babydaddy and I love to hit the arcade without the kids. That way we don’t have to share tokens or waste tickets on prizes we don’t want.
- Studying and entertainment. A little music is alright if it doesn’t distract you. However, trying to watch television and study gives your brain too many inputs to process. Set aside some focused study time and then reward your diligence with an hour or two of Netflix. You’ll find you retain more of what you’ve studied and that you miss less details of your favorite show.
