Wednesday, January 3, 2018

Learning to Play Guitar - Motivation

A little over a year ago, after taking a decade+ hiatus, I started playing guitar again.  During my initial stint, which started in college, I was diligent about taking lessons and played for about 4 years before relegating my guitar to storage.

I often heard or read that I needed to practice 1 hour a day in order to come close to being an expert within any relatively short timeframe.  As a result, I'd freak out that I either didn't have that kind of time or enough motivation to play that long and simply not practice.  I started dreading something that should have provided me joy, simply because I bought into the conventional wisdom over what I should be doing when learning an instrument.

Fast forward to 2016 when I picked up a guitar in earnest again.  This time, I told myself that I'd carve out 15 minutes a day to play.  If I wanted to play longer, then fine, I could play longer, but I should feel like I accomplished my goal for the day if I hit that 15 minute mark.  I should also state that I had no further expectations of becoming an expert guitarist or making my living in music.  I simply wanted to play songs, improvise a little, and, eventually, write a little music.

As expected, by keeping the goal attainable, I've actually put in more time and effort than I require of myself - not because I feel it's mandatory, but because I usually get caught up in the moment or enjoy playing enough now to go back and practice more than just once a day.

On the occasions when I don't feel like practicing, it's easy enough to psych myself up enough to say - just run scales for 15 minutes or play through a few simple chord changes to hit the daily goal.  I don't need to lie to myself and say, "tonight, I'm going to block off 60 minutes to put in good hard practice time."  I only need to keep myself occupied for 15 minutes.  Often, when I start with that attitude, I wind up playing longer than anticipated and finding some little musical puzzle to solve that will sustain me for a few days further.  And then, truthfully, some days I look at the clock constantly waiting for the 15 minutes to be over, so I can check off my practice time for the day.  But, even on those days, I still get my practice time in for the day and go just that much further in making myself a better guitarist.

Monday, January 1, 2018

Adding To My Repertoire

I suppose this is my New Year's Resolution - to start writing in some sort of long form again.  Why not?  I've been able to compile a pretty active schedule of hobbies, and this is just another logical extension, considering I already like to write.

So, where are we today?  Well, here's my typical schedule:

  • 15 minutes a day learning French, Spanish, and Chinese
  • 15 minutes a day reading
  • 15 minutes a day listening to an audio book
  • 15 minutes a day playing guitar
  • 5 minutes a day drawing
  • 15 minutes a day for exercise
  • 15 minutes to explore new software ideas or write new programs 3 times per week.
There are two questions that people are likely to ask - why not just concentrate on one or two things OR how do you ever expect to become an expert?  I'll answer those in reverse.  I don't intend to become an expert.  It's amazing how much enjoyment and knowledge you can pick up simply being an amateur. 

The reason I'm concentrating on all of these things is simply because these are all things that I've wanted to accomplish.  By freeing myself from the tyranny of needing to be an expert, I'm actually able to explore all of these hobbies without succumbing to the stress of needing to perfect any one of them.  Paradoxically, because I don't set stringent expectations for myself, I tend to spend more time on at least one of these hobbies per day and gain more expertise than I would if I focused on one and then told myself that I need to do 'X' an hour a day or 3 days a week or whatever.

The nice thing too is that the 1st 3 items can be incorporated in to my daily commute, so I really only need 1 hour of free time per day to get through the latter 4 activities. 

Given that I'm lucky that I have that kind of time, I can now add a new activity - blogging!  I'll have it follow the same rules as the coding activity: write 3 times per week for 15 minutes.  The additional stipulation is that I'm not going to require myself to edit my posts, so there may be typos, missed words, and stranded thoughts.  But, I'm hoping the vast majority of by posts will be coherent.

Sunday, January 29, 2017

The Nuages of Django

I've finally finished my upgrade to Django 1.10, and, even though I've ranted a bit about the choice between maintenance programming vs. greenfield programming, it's worth taking a final look at the effort it entailed.

  • Here's the issue I used to track the work.  It took me about a month total to perform the work, though the vast majority of that was in relatively wide blocks of weekend time.  I'd estimate that the total effort required about 20-40 hours.  I did this in about 70 commits.  They aren't all independent, but they're as close to being side effect free between each other as reasonably made sense.
  • Using the issue to track my progress gave me a lot of advantages: it made me define clear (though imperfect) criteria for finishing the issue; it kept me disciplined in my tracking through short, relevant comments (although across 107 of them at this juncture, I'm sure there's repetition); it gave me a place to track articles and musings without having to worry about whether or not they were too trivial to put into something more 'official' like the wiki or this blog; and the aforementioned discipline helped me decide when other ideas should require additional issues.
  • I didn't hit every topic here during the upgrade, but I hit a lot of them.  Because a lot of the code was already available in the OpenEats project, much of the documentation served to be more tangential than it would be had I needed to learn things from scratch.  I think of this style of learning akin to learning the patterns of a foreign language via common phrases first before learning the rules of the grammar.  Greenfield development, to me, draws a common thread with attempting to learn how to conjugate all of the verbs in a given language before attempting to speak it.  In the former example, the constructs of grammar are important, but the ability to communicate, however imperfectly, outweighs the benefits of knowing all of the tenses of a limited domain.
  • The existing code gave me a strong launching ground for writing my own views.  OpenEats, as it stands today, favors a model where recipes are public by default and expected to be shared.  Because I'm more interested in simply having a site that's ad free and that allows me to view collected recipes and don't want to step on anyone's intellectual property rights, it's important that I keep the recipes private.  I was able to take an existing view and generate one that fit my needs, even though they were vastly different from the site from which they were derived.  
  • The other thing that an existing site does (even still somewhat within the context of the Django upgrade I started talking about), is provide straw men to help me decide my site strategy.  There's a lot that's part of the site that I want to keep, but there are some things that aren't as useful, and some that I found when they weren't there, provided a strong signal for a future idea.
There's probably a number of other things that I found valuable during this Django journey, but I'm happy leaving those musings for another post.

Sunday, January 22, 2017

The Software Detective - Django Authentication

As I move through the Django upgrade of my OpenEats fork, I also continue to double down on my philosophy that it's better to build from a previous foundation than it is to just write new code.  In today's argument to that effect, I'll use the site's authentication system as an example.

The current OpenEats site uses a combination of django registration redux and the framework's authentication module.  It also places login and sign up logic on the same page as separate tabs and makes calls to those individual functions via ajax.  I don't find anything wrong with this approach, but it seems a bit complicated in its design, so I decided to separate the two functions out into separate pages without ajax calls.

Now, if I were to do this as a green field project, I likely would have looked up the framework's authentication module and got a lot of the login/logout/password reset goodness that comes with it, but I wouldn't have found the additional registration functionality that comes with the redux app.  I may have stumbled on to redux if I were researching alternative authentication modules, but it would have been one of many.  The fact that I may have chosen something else isn't bad, but I probably would have spent too much time looking at the pros and cons of each module than simply selecting something, testing it, and moving on.  Because redux was already there, it reduced the decision space I had to wander through.  Also, because the redux functionality is pretty comprehensive, but the documentation hasn't yet caught up, I needed to read through the redux source code (which is pretty easy to follow, btw).  The end of the README also led me to a possible replacement when I want to move over to OAuth2.

Finally, because the OpenEats code references a lot of different snippets of authentication, and these made no sense to me at the beginning of the project, I needed to delve into the Django documentation to learn more about its authentication mechanisms.  Even more to the point, I needed to learn how the code in front of me worked, so I had a clear stopping point when researching documentation.  Again, if this were green field, I either would have copied and pasted code I don't quite understand, or attempted to read as much documentation as possible in order to ensure that I wasn't missing out on some valuable detail.

So, to recap, here's what I got out of not simply writing an authentication app from scratch:

  • I was able to leverage someone else's code to skip writing functionality that's generally considered tedious.
  • I was able to delve into other code on github to better understand my own project (and, as we've been told time and time again, it's good to read others' code and get familiar with github projects).
  • I had a ready definition of requirements for this portion of my project.
  • I was able to delve somewhat deep into the authentication documentation while making sure I didn't go too deep that I couldn't come up for air.
  • I found a lead for a possible future feature on my site.
Not too shabby for something that's generally considered maintenance programming.

Sunday, January 8, 2017

Everything New is Broken Again

I'm tackling the biggest programming task I've faced in quite some time as part of my fork of Open Eats.  The code is in good working order, but it's a few years old and relies on a lot of outdated libraries, most notably, Django.

It's at this stage that I could take a few paths - I could ignore what's there and completely write my own site; I could take the requirements and just rewrite everything from scratch with those requirements; I could leave everything in place and build off of the older foundation; or I could undertake the maintenance effort to upgrade the system.  I chose the last option.  Though I do generally opt for fixing what's there, it's not always straightforward, and I think this article does a good job of outlining some of the reasons why.

In a professional atmosphere, one of the big questions companies need to ask themselves is - do we move forward to get the latest feature set out there and risk incurring technical debt, or do we work on technical debt and risk falling behind on the feature curve?  There's no definitive answer, as it requires a balancing act.  Start ups, because they only have a toe hold in an industry, usually opt for features.  More established companies have the luxury of working on infrastructure projects (in fact, anyone at a start up who's advocating the use of microservices is probably an overzealous advocate of software engineering trends).

However, I feel that in both cases, small and large companies tend to do maintenance programming wrong.  Even large companies attempt rewrites of portions of their code base and through their 'best' (usually read most prolific or most pedantic) programmers at the problem.  This seems to be based on the human perception that if something's broken, starting anew will not only fix it, but improve it.  Unfortunately, when rewriting something, people often ignore the lessons of Dr. Heidegger and continue making the same mistakes over again while contributing new bugs to the rewrite effort.

The only time I could ever advocate rewriting something from scratch is given the following conditions - (a) the requirements are well defined, meaning the problem set the software solves is relatively self-contained (b) no one at the organization either understands the project's code or has the ability to delve into it and (c) everyone realizes that the new code will miss existing features and surface new bugs.

If those conditions aren't met, it's better to maintain what's there than it is launch a new greenfield project.  If you're making arguments like (a) it'll take too much time to maintain the existing project, or (b) it's too hard to rewrite because there's no safe way to rewrite the code (i.e. there's insufficient testing around the project), you're probably making the wrong argument.  For (a) you're ignoring the time you'll need to learn a new technology or process, and you're certainly ignoring the time to fix the new bugs and update the features you forgot about during the initial rewrite.  For (b), if you can't safely figure out what existing code can do, why do you think you can figure out something that has yet to exist?

This isn't to say that, via maintenance channels, you can't completely rewrite your entire stack.  You just go about it from a renovation point of view.  Don't bulldoze the house and blow up the foundation just to re-pour it.  If the floors are worn (or you need an ORM to replace your aging JDBC code), sand the floors and refinish them.  If the kitchen is outdated (or you need some semblance of an MVC framework to replace your hand-crafted version from 2000), install new counters and appliances.  If you need a new addition to the house (or need to get off Java 1.4 and have the option to use something newer, like Go), draw up the plans and do the work to make sure it fits well with the existing frame.

Sure, maintenance programming doesn't have the starry-eyed narrative of perfectly formed code springing forth from the head of a genius architect, but the ultimate result takes no less intellectual effort and is no less rewarding in the long run.

Monday, December 26, 2016

On Documenting Software Engineering Projects

I started working through my own fork of the Open Eats recipe site software.  To date, I've only made a few minor changes, such as placing (almost) the entire repository in an openeats module, so that the manage.py file can run correctly without further user setup.  I've also started documenting a lot of what I'm finding here.

One of the first things I questioned was where my documentation should live.  I've essentially got access to this here blog, the above wiki, the issue tracker attached to Bitbucket, and the code itself.  I'm sure my preferences will change over time, but here are the current rules for documentation usage:

  • Code - Documentation - much to the surprise of a younger version of myself - should be minimal here.  If the 'how' of the code is unclear, the code should be refactored.  If there's a specific 'why' behind an algorithmic design, that's fair game, though I could argue that documentation belongs in the wiki.  Architectural/project design should be left to the wiki.  So, the code should really only behave as an actor, not as an explainer.
  • Issue Tracker - Document immediate issues that are either enhancements (which I'm also treating as stories) or bugs.  I'm not using any other types.  If they existed in this simple bug tracker, I'd potentially use epics to group bugs and enhancements, but they don't, so I won't.  Things here should be immediate calls to action with very specific exit criteria for fixing.  There may be some overlap with the wiki on information, but that's OK.  We don't refactor issues or wikis, so duplicate information is OK.  Although, we should be very diligent in editing the wiki to ensure that information is correct.  Issue tracking requires less diligent editing, as issues are expected to be ephemeral and out of date at some not too far distant point.  Of course, anyone who's ever managed a backlog knows this isn't always true, but the principle still holds.
  • Wiki - This is the canonical documentation and requires the most care.  Wait, what!? Don't you mean the code requires the most care, since it runs the site?  Well, maybe.  In most cases, you'll be reading a lot more code than you'll be writing.  If you're not, even as part of greenfield development, you're doing it wrong, because you're copying and pasting from stackoverflow without understanding what's going on.  Second, the code is to some extent, self-correcting.  If you add a feature and it doesn't work correctly, you'll eventually find out.  If your documentation is wrong, you'll only wind up frustrating people in the long run who expect it to impart correct information.  The wiki can be used for just about anything, and I'd say that shading toward over-information is preferable to less information, as long as you're following along with a decent narrative (so, don't just barf up some documentation from somewhere else and expect that it will be sufficient for your wiki).  People are going to come to your wiki to understand just about everything, so you should give it the appropriate care.  What's more likely than not to show up in a wiki:
    • Architectural overviews and decisions.
    • Notes that are expected to last a long time and show why the decisions that are in place are in place.  
    • Notes describing particularly inscrutable or idiomatic code choices.  This reduces the text volume overhead in the code itself.
    • Discussions for future enhancements or extensive bug work.
  • Blog - I've debated a bit about whether or not both a blog and a wiki are necessary for documentation in this case.  If I had to jettison one, I'd lose the blog, but I think that a blog does a good job of complementing the wiki.  A blog generally shades toward thought process, while the wiki shows the output of that thought (though a wiki can also show thought process).  A blog is good for discussing meta topics (like this one about choosing documentation standards).  A blog is time based, where a wiki is more generally a static snapshot.  So, I can write a lengthy post about documentation standards and then completely contradict myself next week without making edits to the wiki documentation.  If I were promoting the recipe website, a blog serves as another separate medium for marketing, which serves a useful purpose.  Finally, a blog allows me to go off-script with various posts (say, if I want to review Rogue One tomorrow) without seeming too out of place.
A few final notes on documentation - 

Given the comprehensive abilities of markdown files, I'm fine with the argument that a good README.md with children could supplant a traditional wiki.  In fact, now, as I write this, that may be a better option, as then the repository and documentation is entirely self contained.  For the moment, Bitbucket makes it easy enough to integrate issue tracking, code, and a wiki that the argument for markdown is a little academic.

The most important part of this post (talk about burying the lede), is that documentation is difficult.  It requires a lot of writing and editing.  It's extremely time intensive, and can be frustrating when you put in a lot of effort, but people either don't get your point or don't read it.  However, those aren't excuses not to document.  Code without documentation is essentially dead code.  Code is part of a living ecosystem and needs support - it never lives in isolation.

This holds more true in the commercial space than in the hobbyist space, but, even though you may know the code like the back of your hand, eventually you'll quit or move on to something else and someone will need to support what you've built.

Saturday, December 17, 2016

A New Hope

Yes, of course that's a crappy Rogue One joke, because a new Star Wars movie came out.  More to the point, though, it's sorta true.  I've been working in earnest on my own recipe website for the last few months.  Originally, it was Python on Google App Engine (no wait, it was Angular!), then Python, then Python on a VPS solution.  I've learned a lot - especially around standing up infrastructure and basic security principles.  Enough so, that I've spent more time on the operations and infrastructure than I have on the actual feature code itself.  However, to move forward a little faster, I decided to see if there was another open source solution available.  Lo and behold, there was.  Before I get into that, though, let's go through my overall motivations for this project:

Motivations

  • I'm a software engineering manager now, not a software engineer.  In order to keep current on some skills, and learn some new ones, I wanted to get involved in a project.
  • I wanted to work on a project that has some nominal value for me.  Because I cook a lot, and because recipe sites are rife with ads that make browsing unbearably slow, I decided to write a recipe site.
  • Yes, I know I could do a ton of other things like install ad blocking software, utilize Google Drive, or probably just buy software, but I'm cheap and, also, see bullet point one.
  • I also want to learn as much as possible to run a small website.  This isn't start up territory where I lose money when I don't ship features.  This is a labor of love and software engineering.  Here's a list of things I want to explore and improve: back end feature development, front end feature development and UX design, mobile development, DB administration, scalability, reliability, monitoring, infrastructure as code, data science and documentation.  So, basically everything I can get my hands on (I'm sure there will be more).  However, I realize I may never get to all of those things, but it should be fun to try.
  • I do actually want to use the site though, and, if I concentrate on all of those things, I'll learn a lot (which is ok in the case), but won't actually have a product.
I realized after doing this, though, that one thing I liked about being a software engineer was being a code detective.  It annoys me to no end when people throw out old, working code to start over in search of a 'better' system rather than spend a little effort to improve what's there already.  In order to meet my goals above and adhere to my software engineering principles, I decided to find an open source recipe system I could work from.  In five minutes I found Open Eats by Googling for 'open source recipe software'.  Here's my copy of the repository.  Wish me luck!