Why I am Trying to Give Up Drinking

Anyone who follows me on Twitter or knows me in real life knows that I am quite fond of my evening glass of wine. It’s at a point where it’s almost a personality trait, along with my pugs.

I am vaguely aware of the fact that it’s not really a good thing to be known as the person who drinks a lot. I had the problem of thinking that people like Dorothy Parker and Lucille Bluth are super cool and have lead me to attribute this as a positive personality trait.

I wasn’t always like this.

How I Started Drinking

The first time I ever got drunk was at my bachelorette party. It was a very interesting experience for me. It felt like having a migraine only it didn’t hurt. It put me into this weird, almost meditative state that I found very stimulating.

I never partied when I was in high school or college. I used to spend my Saturday nights watching public TV with my parents. When I was in college I would spend all night alone in my apartment doing cross stitching while watching Law & Order marathons.

I felt kind of like I missed out on my youth and I wanted to make up for lost time. I figured I would get tired of it and I didn’t worry about it too much.

I went back to school to learn programming. I had a lot of anxiety about how I was going to find a job because I knew that the tech industry was very youth-centric. I knew as a woman in my 30’s with no experience it would tricky to break into the industry. I knew my best chance was to work my ass off and try to increase my skills as fast as possible. I stopped cross stitching and doing all the things I used to do to relax. The easiest way to get myself to relax was to drink. I half heartedly tried quitting a few times, but I was so stressed out that I figured I would deal with it later.

Then my marriage started falling apart.

The last year I was married I gave myself alcohol poisoning five times. Two weeks into my first job I was out for New Year’s and I drank so much so quickly that I could not keep water down for a few days. I didn’t want to tell any of the young guys at my job that I got so drunk I couldn’t keep water down, so I just kind of got through it.

After I left that job I worked from home and worked on a book. I used to keep boxes of wine outside where they would freeze overnight. I would bring them in and by the time noon rolled around the wine was thawed enough for me to drink it.

After the divorce I went through a massive depression that I did not expect to go through. I had to commute sixty miles a day to and from my job. By the time I got home I was so spent that all I could do was open a bottle of wine and drink in the bath tub. I deluded myself into thinking I didn’t have a problem because I stopped giving myself alcohol poisoning.

I am painfully aware that these behaviors that I am describing are really unhealthy. But I was stressed out and depressed and this wasn’t at the top of my list of things to worry about.

Why I Am Going to Stop

I am honestly trying to remember what triggered this most recent decision.

The last few months I haven’t been able to go for walks because of the weather. I used to walk 45 minutes a day. It was therapeutic. I wasn’t doing it to lose weight, it was just to get away from the computer and try to clear my head.

I hit 34 and started noticing things like lines around my eyes. I feel like I have put on a bunch of weight over the last few months. I bought larger jeans that used to be loose that are now not anymore.

I recently was able to start doing my walks again recently. I realized that even though I was jogging two miles a day I probably wasn’t going to lose any weight because of my drinking habit.

For some reason, this really bothered me. I don’t want to be a person who is obsessed with losing that last ten pounds, but I am at the point where a bunch of this crap is really bothering me.

I have cleared out enough other emotional baggage from my queue that I now want to deal with this.

I don’t want to feel this way anymore. I have had enough periods of my life where I was out of shape and not feeling particularly well. I know that inevitably at some point I am going to be old. It will be harder to lose weight than it is now. My joints will bother me. I can’t keep this from happening, but I can push it off a while longer by making changes now. It’s better late than never.

What I am Trying To Do

My initial thought was that I would do things in moderation. I would limit myself to one glass of wine a night. I then realized that was not going to work. I always think I will have one, but then after the first one I feel really good and the evening is still early, so I have more.

I also decided not to try and replace alcohol with another sweet beverage like fruit juice. I want to be healthier and lose weight, so replacing alcoholic sugar with non-alcoholic sugar was not a great idea.

I am trying to go cold turkey on most sugar.

I did this a few years ago. I drank nothing but water for like two weeks to retrain my palette not to expect everything it encounters to be sweet.

I am restraining my beverage intake to just water, sparkling water, and tea. I am putting some honey in my tea in the mornings because I am also putting lemon in it and I need something to ameliorate it. I know honey is sugar and sugar is bad for you, but I am confining it to that one thing and I have no allusions that it’s healthy, so don’t lecture me.

I am taking this one day at a time. I know from watching people fail at diets that I am going to have bad days. I will have days where I simply can’t deal with it and I will drink. I will not throw in the towel and give up on the experiment. I will just try to do better next time.

Things I have Notice So Far

I am only on my third day of this, so in a few weeks this might be a laughable blog post. But I have noticed a few things so far.

Nights are Boring

My routine used to be that I would finish work, take a bath with a glass of wine, get warm and comfortable, then go to bed.

I can’t do that anymore.

I used to think that after I got done with work, that I was spent for the day. I would basically drug my brain to get it to relax and calm down so I could sleep and work the next day.

The last few days I have realized I can take a bath and be refreshed enough to work on something else that I actually want to do.

It’s really disconcerting. I know I am tired and I need to sleep, but my brain gets a second wind.

This might be a temporary thing and I will probably crash in a few days. At that point I need to figure out a better way to relax. I never thought I would forget how to relax. It was so hard to do any work when I was younger that I never thought I would be stuck in the mind set that I had to work all the time.

Sugar Withdrawal Really Sucks

I think part of the reason I was drinking as much as I did was because I trained my brain to associate sugar with work being over.

I knew that alcohol had a lot of sugar in it, but I didn’t think about the fact that I was slowly increasing my intake over the last few years.

Yesterday I wanted to stab someone for a drink, not because I craved the alcohol, but because I craved the sugar. I ate a few pieces of dark chocolate and I felt better and the craving went away.

The long term goal isn’t to replace one source of sugar with another. I know that cutting back on all sugar is the goal, but it takes some time to get there. At least the chocolate provides some satiation. Alcohol is an appetite stimulant. I will not be hungry, but then I will have a glass of wine and suddenly be famished. Cutting back on the alcohol not only cuts those calories, but also all the ones I would eat after getting the munchies.

I am hoping the cravings get better the longer I stick with this.

Not Exercising Bothers Me

My Apple Watch got pretty passive aggressive with me over the winter because I wasn’t going on my walks. It was annoying, but I didn’t feel super compelled to do anything about it.

The last few days I have been crawling the walls if I can’t do some kind of exercise.

I wanted to go for a walk yesterday and I almost jumped out of my skin trying to find a time I could get out of here. It was too cold to walk, so I did a strength training exercise for half an hour and even that didn’t feel long enough.

Sitting at my computer today drove me crazy. I am going to try to find a way to do a standing desk of some kind. It’s harder to do with the retina iMac than it was with the laptop and the robotics boxes.

Moving Forward

For me, the biggest test of how this will go is when I got to my first conference this year in two weeks, RWDevCon. I need to decide if I am going to forgo drinking altogether at that event or try to limit myself to one drink. If it were right now I would forgo it completely, but I will see how I feel then.

I wish I could see this in an optimistic light. Yay, I can work on side projects after work. I can work out and lose weight and be healthier. This is going to be super awesome.

But I can’t think of it that way. This is going to be a huge and difficult adjustment. I know I used to live quite happily not doing this every night and I can probably do that again. But it’s going to take some time and effort to relearn how to relax so I don’t burn myself out. I feel like I have taken the fail safes off of myself that kept me from doing too much. I knew I could force myself to relax by basically drugging myself. Now that I am choosing not to do that anymore, I am not sure how I am going to function. I guess I will find out.

Exercises For Programmers: Exercise 3- Printing Quotes

The purpose of this exercise is to display a quote and prompt the user for the person who said the quote. If the quote is correct, you output the answer and the speaker.

I think the stated goals for this exercise assume that you are using a language like Haskell that does not have strong user interface component. I adapted the requirements somewhat for iOS.

The UI elements I need for this exercise are a label asking who said the quote, a text view to hold the quote, a text field to accept the answer, a button to submit the answer, and another text view to display the response.

What you start off seeing when you launch the app.

What you start off seeing when you launch the app.

I briefly thought about how to create a label that would allow for multiple lines of text, when I remembered the best object for that is a text field.

I tried to make the layout adapt to different lengths of quotes. I thought if I just pinned my elements under one another but did not specify the height of each element that it could expand and contract according to how long the quote was. This does not quite work. The text field is stuck at one size and height. If the text is longer than the text field, the element adopts a scroll view to expose the hidden text.

It might be possible to use programmable constraints to get the effect I would like. I am interested in figuring this out in the future, but I will leave that challenge for another time.

There are a few challenges associated with this exercise:

  • Display a quote
  • Check the user input to see if there is an answer
  • If there is an answer, is the answer correct?
  • Customize the output depending on what the user submitted

Like the previous exercises, there are three different possible outputs. Unlike the previous examples, the three are not all connected. If there is no answer, then you have one output. If there is an answer, then you have to process it further to see if it is the correct answer.

I wanted to hard code as little in this application as possible. It was indicated that later in the book we will revisit this application and refactor it to pull multiple quotes and authors from a data structure. I could set the quote and the answer in the view controller, but then if the requirements change and it’s possible that there are more than one quote, I will have to change things. I want this to be set up for that possibility and I want the entire application to be testable, which means moving anything that is not view controller code into a helper functions class.

Since I believe I will later need to have access to multiple quotes, the first function I created was one to return the quote:

func quoteText() -> String {
    return "You can lead a horticulture, but you cannot make her think."
}

Right now we only have one quote, but in the future the requirements may change where we may possibly have more and this can be refactored to determine what that is without having to change any code in the view controller.

Next I want to determine if the response is correct or not. Since the answer is going to be used in multiple places and won’t be passed in from the UI, I made the answer a global variable.

Incorrect response.

Incorrect response.

I need to pass in the response from the user and check it against this answer. It is either correct or incorrect, which means we are returning a Bool:

let answer = "Dorothy Parker"

func isTheAnswerCorrect(response:String) -> Bool {
    if response == answer {
        return true
    } else {
        return false
    }
}

Depending upon whether the response is correct or not, the output string will change. If the answer is correct, we output a congratulatory message. If not, then we let the user know they were incorrect:

func responseOutput(isResponseCorrect:Bool, response:String) -> String {
    if isResponseCorrect == true {
        return "Correct! (response) said (quoteText())"
    } else {
        return "Sorry, (response) did not say that. Try again."
    }
}

Again, I want to future proof this function by not hard coding anything that might change. I am using the response as an interpolated String in both output messages because it will be the same either way. There’s no reason to hard code the correct response, thus making it more difficult to go back and change later.

Correct response

Correct response

So far we’re assuming that the user has entered a response. If they did not enter a response, I would like to handle that contingency as well.

I need to not only check to see if there are no characters in the string, but also to have an output message for the user if it is empty. I want this string to be optional because it is probable that there will be a response and I want this to be a fail-safe:

func isResponseEmpty(response:String) -> String? {
    if response.characters.count == 0 {
        return "Please enter a response!"
    } else {
        return nil
    }
}

Empty Response

Empty Response

My Helper Functions file is now complete. Each piece is small and testable. Now I need to put these pieces together to complete my functionality in the view controller:

@IBAction func answerQuestion(sender: AnyObject) {
    let response = answerTextField.text
        
    if let noResponse = isResponseEmpty(response!) {
        responseTextView.text = noResponse
    } else {
        let checkResponse = isTheAnswerCorrect(response!)
        responseTextView.text = responseOutput(checkResponse, response: response!)
    }
}

I need to pull in the response from the user and store it in a variable.

Since the failsafe for no response is an optional, I need to wrap it in an if-let statement. This puzzled me for a while because I kept getting a compiler error when I did this initially because I had an optional that was not unwrapped. I knew I didn’t want to force unwrap the return value from isResponseEmpty() because most of the time it would be nil. At that point I realized I was using response rather than response! The value from the text field is always presented as an optional. In the first exercise I realized that when you don’t enter anything in the text field, it doesn’t return nil, it just returns an empty string, so I knew it was safe to force unwrap the response.

After I check to verify that there is not an empty string, I need to check to see if the answer is correct. I run the isTheAnswerCorrect() function and pass that value into the responseOutput() function. That function returns a string and that string is set to the response text view.

I ran the code and it appears to work properly. Just to make sure, I went ahead and wrote a unit test for each function in the Helper Functions file. Since each function is small and does a very specific unit of work, it doesn’t take too long to verify each possible output.

Conclusion

I suppose it’s possible that I have overengineered this application. Some of the functions are probably overkill for the requirements as they are now, but I wanted to make this flexible for if those requirements change.

I probably could have shoved all my programming logic into one function, but I really like having everything spelled out and having each function do one small thing. When I was taking classes with Eric Knapp, he said that if you are talking about a function’s job and your description includes “It does this AND…” then you need another function. Each function should do one thing. I like this philosophy and I have been trying to implement it in my own code.

A link to this project can be found here.

Weight is a Number

I am entering my second year of living alone as an independent adult human. I am trying to sort out taxes and get my house cleaned to the point where I can have a party.

One thing I have been passively struggling with is my weight.

The last few years have been very difficult. I have commented on this blog before about the unstable food situation I have had. I have also dealt with a lot of stress and not knowing how to cook my own food. I thought that when all of those issues went away the situation would take care of itself. I didn’t want to try doing a diet and exercise plan because, honestly, I was having trouble just keeping my head above water so it wasn’t a priority.

I don’t think I have lost any weight since I started living alone. I think I had an unhealthy bloated look that has gone away and I feel like I look healthier, but I recently started buying all of my clothes a size larger to be comfortable while I am working.

I was very skinny as a child. The other kids would not go on the seesaw with me because I was so light that I would just hang up in the air. I was consistently ten pounds lighter than everyone else in my class up until puberty hit. Then I developed an eating disorder and I was mad that I didn’t lose any weight. I was freezing all the time and used to pass out, but I didn’t lose weight, so I was demoralized.

I feel a little like a failure because I feel like I had a natural body type that was not very heavy and I am now technically overweight. I don’t feel like doing all the stuff I would need to do to lose the 20 pounds I feel like I should lose to go back to being normal.

I remember being skinny.

You know what? Being skinny really sucked.

I do not remember a time in my childhood where I could tolerate any amount of physical activity.

The worst day of the school year for me was when we would have to run the mile. I would start out thinking I would try to run just this one time. Within a hundred feet I would be gasping for air clutching my side because I felt like I was being stabbed. I got used to my time just being over fifteen minutes because trying to do any better than that was just too hard. I had one year where I didn’t feel well and it was over twenty minutes and they had me do it again.

I hated athletics and sports because I totally sucked at anything physical.

I have noticed since moving out of my parent’s house that my eating habits have changed. My dad makes inedible food. The food he makes is somewhat nutritionally vacuous. He does a lot of bread and rice. One reason he and my ex would get into fights was because my dad wanted his meals to be mainly bread and cereals and my ex wanted his meals to be mainly of meat. Supposedly there should have been common ground between them to eat a lot of vegetables, but shockingly for some reason neither of them actually did that.

He has struggled with his weight most of his adult life. He likes to gorge himself and feel full, which means he tries to make a lot of watery soups that take up a lot of volume, but don’t provide calories or nutrients.

I think back to being a kid and eating turkey sandwiches on whole wheat bread with nothing else on them, not because I was picky, but because we didn’t have anything else to put on them. We had a lot of rice and steamed brussels sprouts and skim milk and iceberg lettuce salads with non-fat dressing washed down with cold glasses of Crystal Light Strawberry Kiwi Lemonade.

My dad had an aversion to fat and he replaced it with carbohydrates. We didn’t do a lot of vegetables and we didn’t have a lot of protein. Most of our food was nutritionally vacant. I am pretty sure my brother, who still lives with my parents, is suffering from scurvy.

I will cop to the fact that when I was starving myself I was making my body weak. I was working against myself by not taking care of myself properly. But as I have been angry with myself for abusing myself, I keep thinking back to the times when I wasn’t abusing myself. I think about how when I was seven I had to ask my friend’s mom for a ride less than a block because I would be winded trying to walk that far.

I might have been skinny, but I sure as hell wasn’t healthy.

I know I should do more than I am doing now. When it’s warmer outside I go for hour long walks and I find them enjoyable. I started running on and off the last few years and I find more joy in it that I ever thought I would because I associated it with feeling like I was going to die and being made fun of for being weak.

Recently I helped my 64-year-old mother move a mattress to the basement. She has arthritis and couldn’t grip the mattress, so I helped my dad do it. She didn’t want me to because she thought if she couldn’t handle the mattress there was no way that I could. Do you know how pathetic it feels to have your retired mother be shocked that you can do normal tasks because it’s something she doesn’t think she can do??

My dad keeps making passive aggressive comments about my “unhealthy” food that has “flesh” in it. He keeps trying to pawn watery lentil and squash soup on me. When I turn him down he keeps telling me that I picked up some bad habits from my ex and comments how skinny I was when I ate his food.

Yeah, starving people tend to be skinny. But being skinny isn’t the best tool that we have to gauge health. If I have to be overweight to be able to actually go hiking and running and not constantly feeling like I am going to die, then cool. I would rather deal with the ten or twenty vanity pounds I would like to lose than go back to how I felt when I was skinny but thought I was fat.

Exercises For Programmers: Exercise Two – Counting Characters

This is the second exercise in Brian Hogan’s book Exercises for Programmers. My solution for this exercise is on GitHub.

Since this is still relatively early in the book, we are still dealing with some simple concepts. This exercise is about asking for a string, repeating it back to the user, and telling the user how many characters are in the string.

countCharactersSuccess

This was supposed to be the first exercise where you set up a user interface, but I jumped the gun on that by setting one up with the first exercise.

The only changes between the first exercise and the second were that there was going to be another label to output the number of characters and that I needed to count the characters in the string.

I was able to complete this far more quickly than the first exercise because most of the road blocks I encountered with the first exercise were solved for the second. I already knew how to set up my auto layout. I remembered how to get the text from the UITextField. I already had most of my set up for the processing I needed to do for the labels.

Failure condition. Need to set both labels, including making sure the second label is an empty string.

Failure condition. Need to set both labels, including making sure the second label is an empty string.

I started out thinking that because I had two labels I needed to create two separate functions. I initially made a variable out of the text field input and passed that into my two functions. Then I thought more critically about it.

I was passing the same information into both functions and doing the same “if-else if-else” statement:

func yourInputString(input:String) -> String {
    
    if input.characters.count == 0 {
        return "You need to enter a string!"
    } else if Int(input) != nil {
        return "Please enter letters and not numbers!"
    } else {
        return "Your input string: (input)"
    }
    
}

func numberOfCharactersInString(input:String) -> String {
    
    if input.characters.count == 0 {
        return ""
    } else if Int(input) != nil {
        return ""
    } else {
        return "(input.uppercaseString) has (input.characters.count) characters."
    }
    
}

That is a lot of repeated code. There is probably a better way to consolidate this.

One of the things Brad and I talked about with Swift having an advantage over Objective-C is that it can return more than one thing. One reason that the NSError stuff is so screwy is because you can’t return more than one thing. You have to pass a pointer to the location in memory for the error because you can’t simply return the error.

I realized that I could cut down on a lot of code by simply returning a tuple that contained both label strings. This cut down on code in both my helper functions and in my main View Controller because I only had to call one function and then assign the result from that function to the labels in the UI.

func inputStringAndCharacterCount(input:String) -> (String, String) {
    
    let yourInputString:String
    let numberOfCharactersString:String
    
    if input.characters.count == 0 {
        yourInputString = "You need to enter a string!"
        numberOfCharactersString = ""
    } else if Int(input) != nil {
        yourInputString = "Please enter letters and not numbers!"
        numberOfCharactersString = ""
    } else {
        yourInputString = "Your input string: (input)"
        numberOfCharactersString = "(input.uppercaseString) has (input.characters.count) characters."
    }
    
    return (yourInputString, numberOfCharactersString)
}

I am finding this iterative approach of starting with something simple then adding complexity is a really good way to approach programming. You take lessons you learned doing something simple and you apply them as you do more and more complicated things.

Writing unit tests also forces you to think in ways to make it as easy as possible for yourself to be able to separate out as much functionality as possible in a way for it to be testable.

When Brad was telling me initially about using tuples I didn’t get how he came up with the solution. It was obvious once I saw it, but I didn’t get how he came up with it. I get it now. When I was writing my code and saw that I was repeating myself a lot, it forced me to think more critically about how I could make my code better.

I am happy I am doing these exercises because I don’t feel I get to code as much as I should. I am now seeing that coding things for myself helps me to learn things better than just being told what to do by someone who learned the way I am learning now.

We can read all the books we want to on clean code and so forth, but you really learn by doing and making mistakes and going back to refactor. I think a lot of people never go back and refactor and that is unfortunate for them. They are missing out on a great learning opportunity.