Tuesday, September 23, 2014

The Coding Process

A lot goes into the coding process, and it can be confusing.  That's why I wrote up this guide; to help newcomers navigate the sometimes-difficult process of bringing software live.  It's open-source, so if you have any changes or suggestions you're welcome to help out!  You should really follow the link, because the version here won't be updated.

The Coding Process

  1. Define your project
    • Clearly state what you wish to accomplish
    • Make sure this objective has measurable goals!
  2. Explain your MVP (Minimum Viable Product)
    • This entails the core functionality of your application
    • What does your app need to do work?
    • This is the 80 in the 80-20 rule
  3. Break code into small chunks
    • Make user stories - small detailed explanations of the user's point of view when interacting with your app
    • Example: The user clicks on the button in the center of the screen and an alert appears
    • User stories should be limited in scope
    • User stories are rated in difficulty to facilitate project management
    • User stories don't just have to be for the frontend! The API is a user interface too.
  4. Write a design doc
    • This resembles a program in structure
    • Higher level than actual code
    • Make a comment skeleton in program files explaining what the code should do
  5. Start coding!
    • This should be a minimal amount of work
    • You should have the code already spelled out in the design doc
  6. Know when to stop
    • Don't go for 100% perfection - you'll never finish!
    • Once the MVP is operational, stop coding and review
  7. Review
    • Make sure the app is operational
    • Check for errors, bugs, codesmells and crashes
    • If any fixes need to be made, spell them out clearly now so they don't cause problems later
  8. Code some more
    • Fix any problems revealed in the review process
    • Minor improvements, bug fixes, etc. - no major changes should happen at this point
    • Go back to review when this is done, unless nothing needed changing (highly unlikely)
  9. Review one more time!
    • Come on, I know you didn't look hard enough for that bug. Trust me, you'd rather find it sooner rather than later.
  10. Finalize and start production
    • Bring your app live!
    • No changes should occur at this time
  11. Start the maintenance process
    • You didn't review your app well enough before. I promise.
    • You'll need to make fixes and changes to your app during its lifetime.
    • Follow established criteria for the update cycle.

Contributions

I gladly welcome updates to this manual! Please, fork and submit your changes upstream.

Thursday, September 18, 2014

Tech Club Meeting September 17, 2014

Hey everybody, in case you missed the meeting on September 17th or just want to review the material we covered, here's the video.  We decided to build a breakout-style game in javascript and I covered some programming basics.  We used jsfiddle.net for our demos.  Please make accounts on github and trello if you haven't done so already!


Wednesday, September 10, 2014

Object Orientation


Here's the audio version of this blog post:



These are objects
What is an object?  In real life, a lot of things are objects.  Plants, bicycles, cars, pets, bananas, thoughts, really anything!  Even people could be considered objects (bear with me here).  The question "what is an object" raises some philosophical issues, but it is clear that objects play a large role in our daily lives.

Because objects are so pervasive in our perception of the world, we can say we experience life in an object-oriented way.  For example, take the sentence "I'm going to the store".  Here, "I" refers to the person object that is going to the store.  The store could be interpreted as a destination object, which implies that there is also an origin object.  The subject of our example may plan on driving his car object to the store, or riding a bike object.  At the store, a person can buy food objects.

This example again raises the question, What is an object?
Let's define some criteria for object-ness:

  • An object must have characteristics
    • Tangible characteristics:
      • Color, size, weight, location
    • Non-tangible characteristics:
      • Emotions, personality traits, powered on, powered off
  • An object must have actions
    • Things that it can do or things that can be done to it
      • Run, walk, eat, drive
      • Power on, power off
      • Paint (change color)
      • Grow
  • An object must be identifiable
    • It must be a distinct entity
      • I can have two pens of the same model, but I still have two different pens
Notice how we never specified that an object must physically exist.  Our criteria for an object could include thoughts, conversations or mathematical formulas.

Because objects are so omnipresent in life and the human experience, things we create will reflect this object-oriented way of thinking.  Humans can easily think of problems in terms of objects, so we created many software tools to describe and interact with objects.  Programs that simulate icebergs melting or control aircraft scheduling patterns can be developed in an object-oriented way.

Not how it is
So, this means when we write most programs, it is easiest to write them in an object-oriented way.  This results in minimal effort on the programmer's part.  Well designed object-oriented programs read more like a description of the real world than arcane source code.









Alright, let's see some code.

class Pig:
    #definition for Pig object
    def __init__(self, weight, age, name):
        #a pig has weight (lbs), age (years) and a name
        
        #assigning parameters to pig object
        self.weight = weight
        self.age = age
        self.name = name
    
    def oink(self):
        print "Oink!"
        
    def sayHello(self):
        print "Hello, my name is " + self.name + "."

#make a new pig named Spider pig that weighs 40 lbs.
#and is 3 years old
SpiderPig = Pig(40, 3, "Spider Pig")

#make spider pig introduce himself
SpiderPig.sayHello()

#make spider pig oink
SpiderPig.oink()

Here's a link to an editable and runnable version of that example.

The programming language I used to write that example is called Python (named after Monty Python's Flying Circus).  If you want a more in-depth introduction, check out my blog posts Python Intro and Python Intro Part Deux.  I also wrote an introduction to Java, another object oriented programming language.

Monday, September 8, 2014

Argument Unpacking in Python (holy balls!)

Hey y'all, I'm here to teach you about Argument Unpacking.  Please, try to remain in your seats.
Woah that guy just got Argument Unpacking













So I had to do some screen scraping (follow that link).  Yuck, right?  Except no, I get some weird sick pleasure out of screen scraping (I volunteer to do it).

(Skip this if you know what screen scraping is)
So in short screen scraping is when you translate a hard-to-traverse website into a nice data structure like json.

Anyways, I was writing a screen scraper for the paint mixer.  I made classes for my data templates (yay go me).  At first, I thought it would be easy to just iterate through the table cells using BeautifulSoup (a very cool and excellent Python html parser).  That was not good.


for cell in cells:
   if cellNumber == 0:
    try:
     cardNumber = cell.contents[0]
    except IndexError:
     cardNumber = None
   elif cellNumber == 1:
    try:
     firstName = cell.contents[0]
    except IndexError:
     firstName = None
   elif cellNumber == 2:
    try:
     lastName = cell.contents[0]
    except IndexError:
     lastName = None
   elif cellNumber == 3:
    try:
     email = cell.contents[0]
    except IndexError:
     email = None
   elif cellNumber == 4:
    try:
     balance = cell.contents[0]
    except IndexError:
     balance = None

^^^ Holy Mother that is bad

I knew Python just had to have a better alternative to this (the word pythonic is a thing, talk about a language dating itself), so I did me some googling and came upon a glorious find: argument unpacking.
This is going to be you in a few sentences











The Astute Reader (tm):  Wow, that traversal Max was talking about seemed really array-like!  I bet there's an easier way to do that!
Me:  Gee thanks captain obvious!  You don't think I was lamenting that with every line I wrote?  I knew I was so close!
The Astute Reader (tm):  Ok, that was an obvious lead-in to Argument Unpacking.  Let's have it, then.

Ok, here it is...drumroll please.

I have a method that takes 6 parameters:

def method_with_lots_of_freaking_parameters(x1, y1, x2, y2, x3, y3):
 print "Haha I'm not even going to use those arguments!"

And I have a list with those parameters stored just itching to be passed to that method
superswaglist = [5, 1, 3, 6, 6, 6]  #wow this is super contrived huh?

Without Argument Unpacking, this is how you'd have to call that method
method_with_lots_of_freaking_parameters(superswaglist[0], superswaglist[1], superswaglist[2], superswaglist[3], superswaglist[4], superswaglist[5])  #puke

But with this blessed tool (In the Name of Python We Pray), we simply call

method_with_lots_of_freaking_parameters(*superswaglist)  #wow such ease
I couldn't agree more
This tool condensed 56 lines of code into one for my screen scraper tool.  Be excited.

PS If you want a tutorial on screen scraping let me know in the comments!

Thursday, September 4, 2014

Tech Club primer

The Beautiful
I recently started a Tech Club at my school.  It's super awesome, and you should go.  If you're interested in science, the future, academia or art, you'll have a place here!  Tech Club is a group of like-minded individuals that love to discuss the future and the possibilities modern technology provides.


You do not need to be a 'computer person' to enjoy Tech Club.  If you're interested in discussing the future and imagining things to come, you'll fit in just fine!







To get an idea of what Tech Club is all about, watch this video:



And this one:



Here are just a few projects we might work on:

  • A game
    • a board game (chess, monopoly, not already an app)
    • Chess engine (AI)
    • one ai learns lots of games
  • Public forum (on canvas)
    • a qa system
  • Moodle...
    • old version of canvas
    • mobile end of lms
  • Online dance ticketing system
  • Better version of canvas
  • Math stuff
    • visualization
    • numerical analysis
  • Fractals
  • Recreate twitter or facebook for fun
  • bio printer
  • quad copter stuff
  • bluetooth control app
  • music listening stuff
  • new iteration of social media
    • gps on gopro
    • online db of experiences
  • PowerSchool screen scraper
    • stay signed in
  • zupas...
    • app to simulate sandwich assembly
    • sell to zupas
    • (quizlet)
  • Booster juice ordering app
  • online bus tracking system
    • schedule online

If you're interested in attending, fill out the Tech Club Application.  There's zero commitment involved in signing up, in fact, we encourage drop ins!

Wednesday, September 3, 2014

The Catcher in the Rye (6)

The Catcher in the Rye is an exemplary book about the difficulties of growing up.  Moving on in life is never easy, and the turmoils of adolescence do nothing to ease this burden.  Everyone is glad to move on from that awkward, hormone-controlled phase of their lives.  This is what makes The Catcher in the Rye so relatable: everyone has a hard time during that part of their lives.  Though the novel refers to some specific historical constructs, this book is timeless and has a universal appeal to kids and adults alike.

Why is growing up so hard?  I think it's because of all the rapid changes everyone experiences.  Life seems to accelerate tenfold when stepping up from middle school to high school.  Everyone's growing at a rapid pace, mentally and physically.  This is emotionally taxing, to say the least.  Lots of people are pushed to the breaking point, while others rise to the challenge.  Eventually, though, most people make it through relatively unscathed.

The Catcher in the Rye offers an interesting perspective into adolescence.  Holden obviously acutely feels the drive to grow up and be an adult, much as every other person begins to crave freedom and privilege during adolescence.  Though there exist much worse teenage experiences, many people don't have nearly as hard of a time as Holden.  In either camp, people can relate to Holden.  He's so sensitive and likable, the reader can't help but root for him.  To truly understand this book, the reader must empathize with Holden.

Every teenager should read The Catcher in the Rye.  It can be used as a field guide explaining what not to do, but many positive messages can be obtained from it as well.  I can't imagine that adults can fully appreciate this book to the degree that someone going through the process of growing up can.

The Catcher in the Rye (5)

After sprinting away from Mr. Antolini's house, Holden starts to crack up a bit here.  He fears that he is about to disappear when crossing the street, so he pretends to talk to his deceased younger brother in order to...not disappear?  Anyways, after muttering to himself for a while, Holden proceeds with his emotional breakdown.  Walking through the world as if numb, Holden finds his way to his little sister Phoebe's school and decides to try to visit her.  While waiting to make contact with her, Holden feels physically ill, as if he is about to vomit.  When he finally finds his sister, he is about to collapse.  He tells Phoebe he is leaving for a long time, and shows her a suitcase he was toting around.  She begs him to let her go with him, and he refuses.  She becomes very upset and refuses to talk to her brother, again.  He pretends to give up, and walks towards the zoo, in full knowledge that his sister will follow him.
Sure enough, they arrive as a pair at the zoo, and Phoebe finally begins to warm up to Holden again.  She and Holden bond for a while, until it begins to rain.   Holden remains outside without any protection and gets soaked, but feels a sense of euphoria at seeing his little sister so happy.

After the rainstorm, the chapter ends.  A very short chapter, the last one, follows, serving as an epilogue of sorts.  Holden explains that after the zoo and the rainstorm, he got very sick and had to go to a different school.  However, he makes it abundantly clear that the reader is not to focus on these details, rather, the reader must finish the story themselves.  I like to think Holden went on to live a happy life and everything worked out for him.  What about you?

I think much of this book is about moving on from the death of a loved one.  Upon finishing the book, I was struck by the bittersweet feeling of moving on.  I think, in the end, Holden figured out how to deal with the loss of his younger brother and learned to move on.  The same numbness and bittersweet feelings are abundantly present in the novel The Perks of Being a Wallflower.  The protagonist of The Perks of Being a Wallflower, Charlie, also lives life at a rapid pace and to the extreme, and also has a very difficult time with the death of a loved one.  Charlie and Holden are both quite young at the time of the novel, and are both very sensitive.  Both Charlie and Holden eventually learn to move on and grow in the process.

The Catcher in the Rye really resounded with me.  I've never experienced the traumatic death of a loved one, but I feel better prepared for that inevitability having read this book.  I made a deep and personal connection to Holden.

The Catcher in the Rye (4)

After Holden's messy date, he calls up an intellectual friend and arranges for drinks later that night.  Then, another insight into Holden's psyche that helps us to empathize with him.
Anyway, I'm sort of glad they've got the atomic bomb invented.   If there's ever another war, I'm going to sit right the hell on top of it.  I'll volunteer for it, I swear to God I will.
(Salinger 141)
This internal dialogue comes right after Holden reveals that his older brother was in the army "for four goddam years."  Poor kid.
Holden and his friend meet up for drinks.  They talk.  Holden gets mad.  They part ways.  Spotting a pattern, anyone?
Holden gets extremely drunk and reminisces about his dead younger brother.  Holden suddenly decides to go visit home and see his little sister, Phoebe.  He wakes her up, and they have a conversation, which turns to why Holden is home so early.  His sister finds out he was kicked out and refuses to talk to Holden.  He coaxes her back into the conversation, and they discuss various heavy issues.  They bond for a while, when their parents show up and Holden bolts out of the house.  Without a place to stay, Holden turns to old friends, Mr. and Mrs. Antolini.  Holden falls asleep, and wakes up a few hours later with Mr. Antolini patting his head.  This is deemed "perverty", and Holden freaks out and bolts again.

I have to agree with Holden, something about this event feels a little rapey.  This reminds me of a similar scene, albeit from a totally different angle and perspective, in the book The Art of Racing in the Rain.  The scene where the younger niece comes on to the older male protagonist leaves just as bad a taste in this reader's mouth.

I tend to take life at a high speed, and often fail to appreciate the present.  Holden has a similar problem.  His wild and crazy antics are a reflection of his need to appear adult-like, just like myself.  I, like Holden, need to slow down and appreciate the small things.  Adulthood ain't easy.

The Catcher in the Rye (3)

Guess who's back (back back) back again!  Will the real Holden Caulfield please stand up?

Where last we left our intrepid hero, he had two older women hanging on to his every word (or so he wished).  This was in a dive bar.  Flip forward to Holden inside a cab.  He has an utterly ridiculous discussion with the cabbie regarding the survival of fish in the nearby often-frozen duck ponds.
Holden: "All right.  What do they do, the fish and all, when the whole little lake's a solid block of ice, people skating on it and all?"
Cabbie: "What the hellaya mean what do they do?  They stay right where they are, for Chrissake."
(Salinger 82)
...and so on
After a decidedly unpleasant cab ride, Holden arrives at Ernie's (another lame bar), where he proceeds to lamely pick up on chicks.  It doesn't go well.  After a protracted, even herculean effort, Holden concedes defeat and heads to a hotel.  While Holden rides up the elevator to his room, the bellman Maurice starkly asks him
"Innarested in a little tail t'night?"
Shocked, the surprised Holden eventually says he is indeed innarested.  In about 45 minutes, in bursts a hooker into Holden's hotel room.  She attempts to initiate "relations", but Holden just wants to have an innocent chat (this kid is actually pretty sensitive).  Upon discovering this, the girl leaves.  Holden believes all is well, until some time later the girl and Maurice return to his hotel room, demanding an exorbitant price for the encounter.  Some arguing occurs, and Holden is roughed up a bit.  He goes to bed with injured face and pride.

After this episode, Holden schedules himself a date with an old friend, Sally.  They go to see a "show" (movie?) and confess their love for one another.  After that, they go skating and have a fight about their future together.  Holden says something mean and Sally starts crying.  Poor Holden.

Holden is a terrible ladies' man, but he doesn't seem to understand this.  Holden also doesn't understand that he's too young to be acting like this, drinking and flirting and smoking and whatnot.  Holden definitely ought to be a little more wary of people like Maurice.  He, like Willy in Death of a Salesman, is unable to confront the truth about himself.  Holden is clearly a sensitive guy, so if he just reflected on his process and really thought about it, he would get the girls.  Holden needs to take a step back and get a reality check on himself, just like Willy.

I think we all delude ourselves into thinking we are more mature than we really are.  I know I'm guilty of this.  I always feel so grown up at my current age, but I know I will feel even more adult-like a few years into the future.  At fifth grade, I thought I was on top of the world.  I'm sure you know what I mean.  To truly understand myself, I need to take a step back and view my maturity and development objectively, just like Holden.

The Catcher in the Rye (2)

Hear ye, hear ye!  I have yet another riveting update to share with you regarding my obligatory summer reading book, The Catcher in the Rye.  Last we left off, we discovered that the brooding teenage Holden has a good reason to be sad: his younger brother died of leukemia.  Flip forward a few more pages, and we are planted into a flashback involving Holden and one of his classmates.  Holden and Stradlater (the alpha-male classmate dude) get in a rather nasty fight about a girl, and Stradlater drew blood.  Holden and Stradlater obviously feel bad about the whole thing, and seem to just want to move on rather than hold any grudge.  It's hard to say what Holden really wants out of this relationship with Stradlater, because they were previously something that could have been interpreted as friends.  I guess Holden's just having a hard time.

Enter Ackley, the questionably hygienic "older" kid that no one seems to like.  Holden, ever the gentleman, is at least moderately polite to Ackley, most of the time.  After some antagonistic dialogue with Ackley, Holden heads off campus to the train station.  On the train, he meets the mother of one of his classmates and acts all adult-like with her.  Holden eventually arrives in New York, where he goes cruising for chicks at some random bars.  Surprisingly enough, he does meet some (significantly older) women, but they don't hit it off.

Holden awkwardly hitting the town reminds me of the Hogwarts students romping around Hogsmeade, except the Harry Potter kids seem to know their place a little better than Holden does.  Both Holden and Harry Potter and co. seem like they don't really know what they're doing outside of school, but Holden seems a little more streetsmart.

I'm not really a rebellious kid, but I can understand what Holden is trying to do.  His taking off and hitting the town is an attempt to seem grown-up, wild and interesting.  We can all relate.

The Catcher in the Rye (1)

This summer, I'm reading The Catcher in the Rye. So far (as of page 40), the main character, Holden, seems to be yet another angsty and apathetic teenager that doesn't really like anyone or anything. His parents seem to have shipped him off to some sort of boarding/reform school because of some trouble he's gotten into in the past or something. Apparently this didn't really help things, because the first few pages reveal that Holden got kicked out of school (again?). After supplying some (intentionally vague) background information, Holden visits one of his sort-of favorite teachers. The visit is super awkward. After that unfortunate encounter, Holden sort of gets into a fight with one of his semi-friends from school (this is a flashback).

He seems like an overly mopey and judgmental kid until he reveals that his younger brother died of leukemia, at which point you feel like a complete douche for judging him. This mopey I-hate-school-and-don't-understand-changes-happening-in-my-body-and-around-me phase is a pretty common occurrence in teen/YA books. I suppose it's mildly evocative of Ender's Game. Ender, like Holden, has a tough time making friends. I bet those two could have a great mope sesh together.

I can completely empathize with Holden, except for the dead younger brother thing. I feel pretty bad for him as far as that goes. But the whole teenager thing? Ya, I'm living it right now. I hate school too, man. *hugs