Category: Life

Every other post.

  • Programming Philosophy

    Programming Philosophy

    I’ve been programming professionally for five years now. Since I’m likely to be in the field for many years to come, what I intend on writing here is a reference to see where I was at in terms of my approach.

    Reduce Opportunities For Errors

    Everything I do is focused around reducing the opportunity for error.

    The first step is I pick a programming language that will require the least amount of code to achieve the task while satisfying other requirements around performance, longevity, and deployment. Sometimes that’s Python. Sometimes that’s C. The less code there is, the less opportunity there is the opportunity to introduce error.

    I remove any repetition as to make the contents of my functions only be what makes them unique. Every repeating instance is an opportunity to forget applying a change I did to some other part. I also code in such a way to make some bugs appear at compile time rather than run-time. For instance, I’ll store strings as defines in C/C++ as to remove one type of repetition and make typos pop up as compile errors.

    Employing practices like unit testing is another big way to reduce errors. It’ll catch some bugs that might otherwise fail to show up until a specific set of conditions occur in a running program, which can make it a pain to locate.

    Write The Idealized Code

    I structure code from the most abstract down. I specify what would be the function/method calls to make with the perfect library, one after the other, to solve a given problem. I then populate those functions after the fact, applying the same approach. Each invoked function/method is just a single-line return statement until properly populated. I refactor continuously.

    I find that the top-down versus bottom-up approach leads to code that’s better structured and more legible.

    Keep Code Legible

    If there’s a Venn Diagram for ideas, this is one that is impacted by a slew of other practices.

    I follow the conventions of the language. For C++, my functions follow the lowerCamelCase pattern. In Python and C it’s the underscore_name_pattern. If common practice dictates to use four space indentation, then that’s what I do. That consistency improves legibility for developers which reduces opportunity for error.

    Likewise I always avoid those clever one liners. If it’s meaning is not immediately clear, I get rid of it. I want to remove as many barriers to understanding my code as possible. Leave cycle-level optimizations to the compiler. The losses that matter are usually several levels of abstraction up.

    My lines of code never exceeds 80-120 characters, my functions rarely are more than a handful of lines, my files rarely exceed 200 lines. The more you have the more someone reading the code will have to track in their head, which makes the code less approachable. You want approachable. It also forces some level of modularization. The easier it is for someone else to pick up the code, the less likely they are to miss out the ways their changes could have unintended consequences.

    I never comment out parts of code permanently as a way to disable it for potential future use. That’s what code revision is for. It just clutters up the code.

    Only Code What’s Unique

    It’s really fun and cool to solve problems on my own. Figuring out how to write an email client from the TCP level. Learning how encryption works. I’m all for that.

    However, I avoid the Not Invented Here syndrome for production code. If there’s a library to do a given task, it’s probably better than what I could have put together on my own. I focus instead on writing the glue to interface with that library. I focus on the parts that make my software unique.

    Sometimes it’s necessary to re-invent the wheel, but I only do so when there’s a demonstrable need.

    Document The Code

    I also document the code following whatever standard is set by the automatic document generator for that language. For Python that’s docstrings. For C/C++ I use JavaDoc for compatibility with Doxygen.

    Comments are invaluable for maintainability. I hold the view that leaving it to the code is insufficient. Comments bridge the gap between how a computer thinks and how people think. The code explains how, the comments explain what.

    I also automate as much of the documentation process as possible. I consider commit messages a type of documentation and use generators like Doxygen. For outward-facing code, if it’s not documented – it doesn’t exist.

    Learn To Get Uncomfortable

    Software development is unlike many fields in that there isn’t a relatively stable body of knowledge to work towards. Rather, that body of knowledge changes drastically every few years less you work as a programmer for NASA.

    General skills around the process of software development are more static, but only just. Core knowledge around data structures has looked the same over the last thirty or forty years, but processes such as Agile and test-driven development are quite new.

    So it becomes necessary to keep learning new things and to avoid staying comfortable with a body of knowledge.

    I do this for two reasons. The first is that it really improves my workflow. All of these are born out of the lessons learned by other developers. Integrating those lessons saves me much time and effort, whether it be debuggers, revision control, unit testing, agile, etc. They were always prefaced with a learning curve that made me question their worth but it always proved invaluable.

    The second reason has to do with my reality in which I’m seen as disposable. Every one of my friends in the private sector, with few exceptions, have recently been laid off. Some multiple times. My own company has reinforced the notion that I’ll be dropped the second it’s convenient to do so. In this environment then I have to be my own agent so that if I’m laid off tomorrow, I’ll be employable. I seek to hold myself up to the standards of the top developers I know.

    Take Care Of Yourself First

    The most important lesson of all though has less to do with code.

    There’s only one person out there that can put your well-being first: you.

    Don’t miss out on spending time with those that matter in your life (including yourself) because you were working nights and weekends. Take those impromptu days off for self-care. Spend time with your chosen family. Don’t look at your work emails after 5pm.

    There are many companies and people within them that would rather you didn’t do this. Those people have different priorities. That’s okay. This is why you’re there.

    There’ll always be people who make more than you. Maybe most people. But if you make a livable wage, have full-time work on regular hours, have your health, and a network of people that love you – then you’re pretty much golden. Those other people will have nicer things. Let it go.

    At the end of the day, it’s the people that matter most.

    And your time with them is the one thing you can’t get back from working evenings and weekends with a company.

  • New Home & Life Update

    New Home & Life Update

    The last few months have proved quite busy.

    I went back to school for evening classes in January and then dropped out. I’ve continued working on the book (pictured below), for which I plan on printing a single copy and leaving it at that. I’m doing it because it’s therapeutic and drives a personal sense of accomplishment.

    Cover for the single-issue book.
    Cover for the single-issue book.

    I also moved last week. This is months shy of my lease being up on my old place so I’m paying dual-rent at the moment.

    The move has been an incredible boon to my mental health. My old place did not feel like a home.

    I had a pretty severe leak which lasted twenty days because the property management company wanted to save money and did not want to get a plumber. It took another twenty days to fix the ceiling that had collapsed due to their inaction. It took a week to “fix” the broken lock on my door (the wonders of plywood.) The pipes atop my head vibrated extremely loudly at night preventing me from sleeping. I’d often wake up at all hours. Turns out there was something loose in the boiler room which took three months to fix. My bathroom always smelled like cigarette smoke, the halls often reeked of pot. The property management company would cut power to the building one day, water another, and have reason to go into my unit each month. The halls had ripped out flooring and walls, the product of construction that had been abandoned before my initial move. Tenants discarded their own garbage inside the building. Then there was an email from my property manager asking me to take down a review in which explained the terrible initial state of the apartment. There was no acknowledgement of their responsibility. That was atop of the regular patronizing reminder emails they’d send out.

    That last week in the old place I was counting down the days to the move and seeing that as a shrinking window in which I could kill myself. I knew the place I was at sucked but I didn’t see changing places as an opening for getting better. I just saw it as a chance to separate myself from negligent property managers. Getting to sleep was still a nightmare with negative memories replaying endlessly.

    It was only after I moved that I realized how significant the old place had been to the degradation of my mental health. It had been far more than the annoyance I had thought it to be.

    IMG_20140410_074431

    Even though we’re four in the house, I fall asleep to soft laughter or silence. I wake up to the sun, a luxury I didn’t have in my basement apartment. I sleep so well. It’s really strongly impacted my mood for the better. Those negative thoughts that occupied the hours before falling asleep are no longer as present. I don’t know how long that will last, but I’ll take it.

    The residents here also are super affirming for me. I can wear my new Lululemon skirt and they won’t comment on it. Because it’s normal. I have not heard the wrong pronouns or my birth name uttered here once. One day I came home and they had supper for me. It’s just been lovely. I now spend 2.5 – 3 hours travelling each day to get to/from work, but it’s well worth having this home to go to.

    I’ve also started to self-medicate for hormone replacement therapy.

    I started pursuing legitimate channels last May. It took about four months to have a social worker discuss my history and vouch for a referral. Since then it’s just been wait. My first appointment was scheduled in November. The appointment was set for the first week of February. The clinic then pushed it back to the first week of March. The second appointment was supposed to be in the last week of March, then it got pushed to Mid-April, then to mid-May. The doctor wants to also go over my history beforehand, so we’re now looking at well-over a year before I’ll get on officially.

    It’s frustrating because I know of people that went from bringing it up with their GP to getting a prescription in under a month. I just did not win this lottery. I’ve had this option to self-medicate from the get-go. I tried waiting. But over that year I saw further irreversible masculinization take place and the capacity to cope with it erode.

    The only thing I gained from waiting further was the approval of cisgender friends at the expense of my own mental health. They saw self-medicating as more risky than waiting. The trans people in my life know the reality can be the reverse. Outward physical health does little good if there’s no mental health to go with it.

    I’ve felt a sense of relief being on them. I don’t expect much in terms of outward changes as I’m on anti-androgens. I’ve used a guide made available by the Center for Mental Addiction and Health, the arbiters of surgical care under OHIP, for suggested start dosage and risks. I’ve also turned to the Standards of Care issued by the World Professional Association for Transgender Health for further information. It helps that many among my friends network are or have been trans service providers.

    Other than that, life is good.

    I took a month-long reprieve in March from social media and socializing in general. That followed a particularly bad night mental health wise, and that did me much good.

    I’m still baking for fun, and now that I have room mates it’s not just me eating everything. I have these plans for the summer too. If I’m still at my current employment, I’m going to take a month off in August. I haven’t had a month off since I started to work when I was 15. I’ll use that time to finish my book and work on an open-source project. It’s very difficult to find energy to program for fun when that already consumes 11-12 hours of each day (I count travel time.) A month would do me great.

    Friendships are doing well. Many of my friends have also seen the last few months as being a period of great change, for the better. I’ve been keeping busy and doing things like going to watch plays. I saw Seeds last week, which is a documentary-play about the patent infringement case brought against a farmer who was found to have grown Monsanto seeds without authorization.

    new-imagegrainslicorne

    I’m excited for the impending summer.

  • Vegan & Gluten-Free Quinoa Chocolate Cake

    Vegan & Gluten-Free Quinoa Chocolate Cake

    Again with Bridgehead. They had a quinoa chocolate cake and I wanted to try to make something like it.

    Chocolate Cake (Original)

    • ⅔ Cup Quinoa
    • 1⅓ Cup Water
    • ¼ Cup Flax Seeds
    • ½ Cup Water
    • ⅓ Cup Almond Milk
    • 1 Tsp Vanilla Extract
    • ¾ Cup Vegan Butter (eg. Earth Balance)
    • 1½ Cup Sugar
    • 1 Cup Unsweetened Cocoa Powder
    • 1½ Tsp Baking Powder
    • ½ Tsp Baking Soda
    • 1 Tsp Salt
    1. Bring quinoa and water to a boil in a sauce pan. Cover and reduce to a simmer for ten minutes. Turn the heat off, fluff with a fork and let cool for another ten minutes.
    2. Preheat the oven to 350 F.
    3. Grease a spring form pan for the cake. If you use a different pan, also cover the bottom with parchment paper.
    4. Grind the flax seeds and mix with the half cup hot water to a bowl. Let cool.
    5. Combine almond milk, flax mix, and vanilla in a large bowl using an immersion blender or food processor.
    6. Add the cooked quinoa and butter to the same bowl and blend.
    7. In another large bowl, mix the sugar, cocoa powder, baking powder, baking soda and salt. Add the blended quinoa mixture and mix well.
    8. Pour into the greased pan.
    9. Bake for 45 minutes or until a tooth pick comes out clean.
    10. Let cool.

    Chocolate Frosting (Original)

    • 2 Cups Icing Sugar
    • ¼ Cup Vegan Butter
    • ¼ Cup Almond Milk
    • ¾ Cup Unsweetened Cocoa Powder
    • ½ Tsp Vanilla
    1. Cream sugar and butter.
    2. Add remaining ingredients and mix until smooth. Add almond milk by the tea spoon if it’s too hard.
    3. Place frosting on top of cooled cake.

    IMG_20140302_210942b

    Thoughts

    The cake was moist. I was in a rush when I made it, so I didn’t give it adequate time to cool before I threw on the frosting. As a result it kind of sunk into the center displacing the batter. You could tell the quinoa and flax meal were there, but it impinge on the taste.

    This wasn’t as dense as the usual flourless chocolate cakes and safe dairy-wise. I was wondering how I could enhance the presentation. Maybe a draw pattern on top with white glaze and/or top it with cherry pie filling.

     

  • Vegan & Gluten-Free Butter Tarts

    Vegan & Gluten-Free Butter Tarts

    I experimented this weekend, preparing vegan & gluten-free butter tarts. I was looking online for recipes, and they all called for raisins – which I really don’t like. So I improvised.

    Vegan & Gluten-Free Butter Tarts (Original Recipe)

    Makes 12 tarts.

    Pastry

    • 3 Cups Gluten-Free All Purpose Flour
    • 1 Cup Sugar
    • 1 Tbsp Nutmeg
    • ½ Tsp Salt
    • 1 Cup Vegan Butter
    • ¼ Cup Ice Water
    1. Oil and flour the wells of a muffin tin.
    2. Mix the dry ingredients in a bowl. Add the butter and mix until crumbly.
    3. Add the water and form into a ball of dough. Add more water by the tablespoon if necessary.
    4. Place the dough in the fridge for 30 minutes to an hour.
    5. Roll out the dough so that it’s ¼ inch thick and cut out twelve circles. Place in the muffin tin.

    Filling

    • ½ Cup Brown Sugar
    • 2 Tbsp Agar Agar
    • ½ Cup Vegan Butter
    • ½ Cup Maple Syrup
    • 2 Tsp Vanilla
    • 2 Tbsp Corn Starch
    1. Preheat the oven to 450 F.
    2. Mix the sugar and agar powder in a bowl.
    3. Add the maple syrup to the bowl and mix.
    4. Melt the butter and add to the bowl. If you’re using a vegan spread like Earth Balance, you can brown it instead of just melting it.
    5. Add the corn starch and mix.
    6. Pour the filling in the prepared shells.
    7. Bake until puffed and browned, about 10-12 minutes.
    8. Let cool to allow the agar agar to set.

    IMG_20140301_085348b

    Thoughts

    This recipe diverges from the original a bit. A whole nutmeg became ground nutmeg, which is more readily available. The agar agar was added as the mechanism through which to gelatinize the filling. I’m not sure if two flax eggs would have also worked.

    Overall, these are okay. The shells are a bit thick. Perhaps cutting down the pastry ingredients by up to a third next time. The filling meanwhile is very average. Perhaps mixing in chopped pecans or walnuts could have given it that extra kick.

    This is a functional treat and I can see me making these again, though I do think there’s room for improvement.

  • White Chocolate Bread Pudding

    White Chocolate Bread Pudding

    I had made a sweet maple-infused bread that wasn’t all that spectacular so I decided to turn it into bread pudding! I stole the idea from a bakery up the road that has incredible white chocolate versions.

    White Chocolate Bread Pudding (Original Recipe)

    Makes four 4.5″ tarts. Approximately 500 calories per serving.

    • 4 Stale Slices of Sweet Bread
    • 2 Tbsp Butter
    • 112g White Chocolate Chips
    • 2 Eggs
    • ½ Cup Milk
    • ½ Cup Whipping Cream
    • 3 Tbsp Sugar
    • 3 Tsp Vanilla
    1. Cut the bread into half-inch cubes and place in four 4.5″ tart pans. Make sure the bread is more or less level with itself. Protruding pieces will toast when the tarts are baked later on.
    2. Drizzle melted butter on top of the bread.
    3. Spread the chocolate chips on top.
    4. Whisk the eggs in a bowl.
    5. Combine the milk, cream, vanilla, and sugar in a small sauce pan. Stir frequently as you bring to a boil.
    6. Pour the hot milk mixture into the bowl with the eggs, stirring constantly. Don’t whisk as the custard will foam.
    7. Strain the custard over the egg and chocolate. Let stand for 10 minutes.
    8. Preheat the oven to 325F.
    9. Bake the tarts for 20-25 minutes, or until brown on top.
    10. Serve warm.

    If served after the tarts have cooled, throw them in the microwave for 10-15 seconds.

    IMG_20140227_195021b

    IMG_20140227_204551b

    Thoughts

    Delicious. There was a bit of dry toasted bread from where it protruded. I think making sure that the bread was all level with itself would have solved this. I wasn’t sure whether to add more melted butter, but it seemed right by the end. Maybe concentrate more of the hot custard in the center.

    Make sure to microwave if these have sat in the fridge overnight; they don’t taste good cold nor dry.

    Second Attempt Notes

    For the second attempt, instead of cutting up the bread in cubes, I just punched out slices of bread using the tart pans. It made the end result more consistent and more like the products from the bakery up the road. I also cut down the white chocolate chips by half – I think next time I’d go back to the original amount. I used a loaf of my whole wheat bread – I think next time I’d use white bread or something softer.

    IMG_20140323_104523

    IMG_20140323_105634

    Still delicious. This recipe is now one of my favourites.