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.