Subscribe via Email

Wednesday, April 20, 2016

Shower Thoughts [#1]: From Programming Practices to Life Practices: Establishing Healthy Habits

Last summer I took a course on programming practices in which outlined some of the fundamental concepts to keep in mind when programming. I've found especially throughout this year that many of these such topics manifest themselves in my own thought process. As a result, I feel it would be interesting for any general reader to perhaps get a few "life-hacks" from here, whereas a computer scientist may acquire more of an appreciation for the concepts outlined. For those curious, I'm referring largely to the comp2160 as well as comp2280 courses at the University of Manitoba. 


Basically...
  •     If you feel you don't achieve as much as you want, perhaps try following some of the stuff below
  •     If you are taking 2160 or have an exam tomorrow, read through to get a more broad/abstract understanding of what you're expected to know. (if your instructor is Michael Zapp you're probably best off using this time to write your Will instead)


#1 Design by Contract

In some sense, everything in life is a series of input and output values. 
For example Newton's first law of motion describes an object's tendency to remain in the same "state" of motion unless equal or opposing force is applied to it.
By "state" I'm referring to a snapshot of all relevant properties of something at a given moment in time. With regards to Newton's Law; the state of an object is it's relative velocity, acceleration, and so forth.

baby seals in a box
(artistic portrayal) 
So, let's say you encounter a box of baby seals (that are healthy, happy, and being transported to a safe habitat). Let's suppose you assume this box of baby seals is just an ordinary box of cute creatures that abides by the all governing universal laws that man has studied for centuries. That being said, you've made assumptions, you have conditions in which you assume hold about this box. You also know intuitively that when you push relatively light objects they will move, thus when you push this box of seals it acts exactly how you expect.  This is Design by Contract in a nutshell... or in a box I suppose. You have conditions, things that hold before and after something happens. You know that if the preconditions hold, and you make said action, you will most certainly get the result expected. 

This concept greatly assists in my decision-making process. 
If you ever find yourself waking up in the morning and planning to take on a big task; then simply spending endless waking hours doing essentially nothing, consider the state you are in that leads you to this (take a snapshot of all relevant parts of your life/internal thought). Following this, design a contract  with yourself, and more importantly with the world, make it public, make it something everyone can see. 
This is done by telling others you have a goal, and starting on day X you will begin doing it, let others know if they confront you and ask how the goal is turning out you'll consistently reply with steady progress; because you defined where you're going to end up right? I do this often with slight mental trickery on myself, that began actually working... A couple of years ago I decided, one morning, that the I'd wake up at 5am, and go for a run at 6am. I then decided that every day following I'd wake up at 5am, and consistently go for runs 2-3 times per week. Nearly 2 years later I am still doing this, and thus, a healthy habit has been established. 
Another more common example shared by many is one involving dieting. It can be extremely hard to refuse junk food when it's in your face, and even the strongest of minds can slip up if you're in the wrong place at the wrong time (this is your state). Design a routine for yourself such that you define when it is you are most vulnerable to over indulging (evenings for me...) and then ensure you are not surrounded by such temptations. It's not fair to yourself to keep junk food, or some other substance in close proximity, and promise yourself that you won't abuse it, then feel disappointed when you do; because you knew deep down that it would happen. Don't tell yourself you won't slip up; just make the act of slipping up impossible, until your brain stops considering it an option. 

I wouldn't suggest publishing these results in Nature because fortunately proof by anecdote isn't valued much in academia. Just consider it for yourself if you'd like, because whether or not you're aware, you have contracts you follow already. You have routines that make you "not a morning person", and "someone who can't focus for a long time" and so forth because you define them as such. Carefully define the state you need to be in, and what you wish to get out of life, and then take that action with utmost discipline. You've literally implemented a routine in your life, a repeatable segment of behavior that you can guarantee will yield a set outcome, given you enter the routine in the same state of mind.

#2 Unit Testing

When developing larger software it is common practice to design unit tests, which involves testing small modular (units) of a component based on it's code and behavior. By doing this we build up from simple pieces that fit together and have proven to be functional, and grow into more complex components that rely on those smaller ones. 

Big-bang testing is the sad alternative, which involves quickly putting together all the pieces and then testing all at once. 

Some would argue the Big Bang resulted in the complexity of life... In terms of software, it creates nothing but headaches. 

In relation to lifestyle, unit testing manifests itself when you wish to add something new to your routine (if you need help establishing routines then check part 1 above). It is always nice to be comfortable where you are in life, but realistically life is an ongoing struggle to keep up with rapid and sudden changes that may rock your foundation. Therefore it's important to test yourself, parts of what makes up your routines in life, and ensure you have those solidified before taking on something more complex.
 As an example, I personally found calisthenics interesting. If you aren't aware, calisthenics is like manly pole dancing, really, I swear! I'll call it gymnastics just to be safe. Stumbling across a few youtube videos late at night when you should be studying is often enough to get me planning for a new hobby. The issue is, I am already focusing on managing my diet, running daily, and waking up at 5am. If I were to keep adding more things, promising myself I'd work on this and that, in the end, chances are none of those promises would be kept, thus your contract has been broken because you didn't test yourself as you developed yourself. 
I spent a solid 90 days developing early wakeup and diet as a habit, and then I began calisthenics. A few months later, calisthenics has been going strong, and I've maintained the diet/sleeping routine as well! I've attached footage of my current progress if you're interested! 
The point is, to test yourself as you develop yourself. Multiple habits can't be easily established at once, regardless of your discipline, so build them up in smaller units. 

Each day is a new test: a test of your character.

#3 Coupling & Cohesion

In order to build strong habits and accomplish goals, it is often easier to build your life in such a way that you may alter little pieces of it without radically altering the others. Think to yourself and recall a goal you have in your mind, somewhere you want to be.
   How many other things in your life must you alter in order to accomplish this goal?
   Can you handle the sudden jolting change in lifestyle?
 With respect to state mentioned earlier, how will you feel about this goal in say 2 days, a week, a month? Although a perhaps rigid approach, aiming for high cohesion (to focus on one specific thing at a time) will put you further than if you alter countless interdependent (highly coupled) pieces of your life and then collapse under the stress. Thus, much like a computer program: aim for low coupling and high cohesion when introducing a new routine into your life.

#4 Abstraction vs Implementation 

The number of times I've been told to stop overthinking a task, or to just worry about details later is uncanny. I sympathize with those who struggle with me on this... 
Let's say I wanted to start going to the gym, my general thought process would look something like this:
   ...ENTERING KYLE'S BRAIN  ...
   I think I'll start going to the gym regularly... 
   It's always good to have a plan, so I need to know what days to go first...
   oh before that, what is it I'm wanting to train at the gym? Should I do cardio or weight lifting?
     I'm not really into the weight lifting community... so perhaps cardio; but is that good for me?
 

       Alright, well yahoo answers and Jason from the gym claim I'll bust my knees if I run... 
        I'm pretty young, though, I mean, exercising is probably better than nothing right? 

          
             Oh wow, how far do you have to run to have this happen... 
                Ah, these people run marathons
           I'll just perhaps stop before I hit marathon distance, as long as I'm doing < 26 miles every  few days I should be fine right?
            *falls down onto bed*
              this is too complicated
               Why can't I just get motivated to do something...
                 I think I am motivated... it's just, I overthink things...
                ... Wait I'm doing that right now, how ironic. How can I fix this...
          
I could keep going. Some will relate to this all too well; while others are fortunate to not experience this struggle. The most trivial of questions often lead the victim questioning century-old philosophical ideas and performing psychoanalysis on themselves. At this point it is important to take a step back and abstract, then once you have a realistic model just start implementing it.

A general approach is as follows:
    1) Look at the general problem/goal: what is it that you want to do?
    2) Ask yourself, how can I do it? 
    3) List the answers to that question: what steps you must take to reach your goal,
        For each of these general steps, AVOID elaborating on them yet. It gets too messy if you do.
    4) After designing your approach, begin the steps.
        Worry about the details for each step once you get there. It won't matter how difficult it may get since you've set your mind on doing it anyway, right?

Conclusion

I've gone over what I believe are the core life practices for establishing and retaining good habits. In summary aim for: 
  1. Abstraction: Look at your goals from a distance in the big picture, don't plan everything or you won't start anything. 
  2. Design by Contract: Outline where you started and where you plan to end up, and hold the contract with utmost discipline. To avoid breaking your contract, realize when you are most vulnerable to slipping up, and avoid putting yourself in such a state. 
  3. Cohesion: Set goals that focus on a limited number of particular things, don't aim to radically alter everything in your life at once.
  4. Coupling: Introduce changes into your life that are as independent as possible from other things. Don't force yourself to alter countless other aspects about yourself to fit in a new habit, or it won't stick.
  5. Unit Testing/Commenting: Track the progress by documenting it, serving as a motivator and reinforcement to keep going! Test yourself as you develop yourself, ensuring you don't try building further habits while others are crumbling. 





No comments:

Post a Comment

Please feel free to give feedback/criticism, or other suggestions! (be gentle)

Subscribe to Updates via Email