Blog

  • 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 Sunflower Butter Mousse

    Vegan Sunflower Butter Mousse

    Makes four 4.5” tarts.

    Oreo Cookie Crust (Original)

    • 24 Oreos
    • 1/4 Cup Melted Vegan Butter (eg. Earth Balance)
    1. Place parchment paper in the bottom of the tart pans.
    2. In a large bowl, turn the cookies into fine crumbs.
    3. Add melted butter and mix well.
    4. Line the tarts with the Oreo mix to make a crust.
    5. Place the tarts in the freezer.

    Sunflower Butter Filling (Original)

    • 300g Silken Tofu
    • 1 Cup Peanut/Sunflower/Almond/etc. Butter
    • 1/8 Tsp Xantham Gum (Optional)
    1. Combine the ingredients using a blender/food processor/etc.
    2. Pour into the crust and freeze for an hour.

    Chocolate Ganache

    • 5 Tbsp Vegan Milk (eg. Unsweetened Almond Milk)
    • 1 Cup Dairy-Free Semi-Sweet Chocolate Chips
    • 3 Tbsp Maple Syrup
    1. In a small sauce pan, boil the milk.
    2. Remove from heat and add chocolate and maple syrup. Mix until fully melted.
    3. Pour the chocolate mixture on top of the tarts.
    4. Refrigerate the tarts until the chocolate ganache has set.

    IMG_20140413_134042

    IMG_20140413_160429

     

    Thoughts

    I improvised this recipe trying to replicate the peanut butter tarts they serve at Bridgehead. This did not at all turn out like those – everything was far softer to the point I called it a mousse instead of a tart. Still good, just different.

    The crust did not hold together. The cookie crumbs would need to be finer, or perhaps use a flour plus cocoa crust recipe.

  • Vegan Deconstructed Apple Pie

    Vegan Deconstructed Apple Pie

    I think it’s fun to come up with new desserts. This is one of those ideas that I put down on a post-it note while bored at work.

    The jist was that I really like apple pie but that delicious crust is loaded in calories. I figured I could get away with half the crust without caring too much. It’s really those first and last few bites that matter for me. Whether there’s ten or twenty bites in between doesn’t make much difference. So this was my idea of how to make a pie with half the crust look appetizing.

    Vegan Deconstructed Apple Pie

    Makes four servings.

    Apple Pie Topping (Original)

    • ½ Cup Sugar
    • 3 Tsp Cinnamon
    • 4 Apples
    • ¼ Cup Vegan Butter
    1.  In a large bowl, mix cinnamon and sugar.
    2. Peel and slice apples. Place slices in bowl.
    3. Mix the contents of the bowl. Pour in a frying pan over the stove and add the butter. Set to medium heat.
    4. Stir occasionally. When tender, turn heat off. Approximately 30 minutes.

    IMG_20140319_184534

    Shortbread Crust (Original)

    • ¼ Cup Sugar
    • ½ Cup Vegan Butter
    • 1 Cup All Purpose Flour
    1. While the apple pie topping is simmering, preheat the oven to 400 F.
    2. In a large bowl, beat sugar and butter until fluffly.
    3. Stir in the flour.
    4. Make a ball with the dough and cover in plastic wrap. Place in the freezer for 10 minutes.
    5. Roll out the dough in a rectangle shape. Then cut it up into 4 triangles. Poke the crust with a fork.
    6. Bake for 15 minutes or until golden brown.
    7. Let cool before serving. Serve by placing one of the triangle pieces on a plate, and putting on a dollop of apple pie topping.

    IMG_20140319_183814

    Thoughts

    It’s apple pie. I love apple pie. It’s delicious. End of story.

    I liked the shortbread crust, but I think experimenting with more elaborate versions might be worthwhile. Like this buttery shortbread crust, that calls for heavy cream, lemon juice, and eggs. Fancy.

    IMG_20140319_185609

  • 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.