Skip to main content

Posts

Showing posts with the label Programming

CodeSchool vs Codecademy(or 'How socket inherits event listening methods and implements asynchronicity')

In this review I'm going to focus on the pedagogy that I see evident in some CodeSchool courses and compare them to  Codecademy. By pedagogy, I mean: 'How does CodeSchool teach?' and ' Does it do a good job of teaching?'. I'm going to argue that despite high quality videos, colourful web pages, and often ssspppeeeeeakkkiiiing...rrrreeally...slowly..., CodeSchool's pedagogy is inferior to that of Codecademy. There are many fantastic resources for learning to code on the web, and CodeSchool is one of them. So far I have completed courses in Ruby, Rails, Javascript, HTML/CSS, Jquery and Git on CodeSchool. The courses have all included high quality videos and colourful, interactive exercises- as well as  massive  pdf files of the slides ( the files take more than a minute to load on my machine .) The question is: does the higher production value mean better educational quality? The 'Try' courses on CodeSchool(such as Try Ruby and Try jQuery) are f...

Algorithm Analysis - 1

Currently, I'm learning to perform algorithm analysis using Big-O notation. In one resource I found the following problem: You just dropped a box of glass toys and  n  toys in the box broke in half. You'd like to match the halves of the toys so that you could glue them together, but the only way to tell whether two halves belonged to one toy is to physically pick up the two pieces and try to fit them together. Express how long this matching process will take in terms of  n . The answer given is n^2 (n squared) with the following explanation:  You have to compare every piece with every other piece. If you have 1 toy and it breaks in half, you have 1 comparison to make. If you have 2 toys and they both break in half there are 4 pieces and you have to do 6 comparisons. If you have 3 toys, there are 6 pieces and you have to do 15 comparisons. If you have  N/2  toys, you have  N  pieces and you have to do N-1 + N-2 + N-3 + ... + 1 =(N)(N-1)/2...

IF YOU'RE A CODER, EXERCISE IS PART OF YOUR JOB.

If you're an elite footballer, cyclist or Hollywood star, part of your weekly routine probably involves hitting the gym. You're not paid to go the gym- you're paid to play football or repeat lines for £10,000 a word. However, you can't be a great athlete or (these days) a Hollywood star if you don't maintain a high level of physical fitness. Though the link may not be as obvious, I am going to argue that: To be the best coder you can be (or any kind of knowledge worker) you need to exercise regularly. (Before I'm accused of insensitivity, I'm not arguing that those unable to exercise due to disabilities can't be great coders. To claim that, I would have to be ignorant of people like Stephen Hawking. I am only making a general claim (i.e. 'on average')) I'll assume you already know about the benefits of exercise for your health in general, so we won't talk about the benefits of exercise in reducing risk for conditions like heart dis...

10 week update

    With the exception of the week over Christmas, I have been studying coding for every week for 10 weeks now. I estimate that I have spent 300 hours on study so far. Realistically, not all of that time was spend coding, much of it was spent reading forums looking for help, watching lectures, reading books as well as brushing up on mathematics. So, perhaps half of the time (150 hours) could truly be called coding practice.    Without a mentor, it hasn't always been easy deciding on the path to take. I spent the first 2 weeks on Java, as that was the first course I found. Then I discovered The Odin Project and spent the last 7 weeks learning Ruby, Javascript and SQL. Over the last couple of weeks I started some Python study, including an online course.  Just before Christmas I also discovered FreeCodeCamp which focuses on Javascript.  I believe that I've finally discovered the best path. Last week I volunteered as a mentor at my first CoderDojo. Last n...

Venturing into Number Theory

In attempt to solve a maths problem with Ruby, I discovered the benefits of going beyond simple arithmetic. Perhaps surprisingly, many seemingly complex mathematical problems can be solved using basic arithmetic and raw computing power. Most of the time this doesn't pose a problem. However, as the values involved grow larger, the demands on the computer's memory reaches a critical point beyond which you risk crashing your computer.  The problem I was trying to solve was the following:    What is the smallest positive number that is evenly divisible  by all of the numbers from 1 to 20? After causing my computer to hang for several minutes, I realized I had to rewrite the program I was working on. The program had to take shortcuts, so that instead of testing every single value between 1 and 1 million, it only tested likely values. With the help of my lovely wife (a Maths teacher) I rewrote the program using prime numbers.   class SmallestProduct requ...

Object Oriented Design- Wading into Deeper Waters

Objects, classes, inheritance, polymorphism- it sounds a little like Biology, and in some ways, object oriented programming (OOP) mirrors the natural world.  I've finally reached the OOP section in the Odin Project's Ruby Programming course. Many of the concepts are straightforward-especially to anyone who has read a little philosophy or studied evolutionary biology. The difficult part is translating the concepts into actual functioning OOP applications.  I've started reading what looks to be a promising book on OOP design in Ruby. I've learned something already that may improve my code. Here's an example from chapter 2:  class Gear    attr_reader :chainring, :cog,     def initialize(chainring, cog)      @chainring = chainring      @cog = cog    end    def ratio      (chainring / cog.to_f).round(2)    end end This is the 'good' way to create a class....

Programming vs Learning to Program

This is a multi-faceted topic, I want to look at one aspect in this post: effort vs. efficiency. After creating a Caesar cipher in Ruby  a few days ago, I looked at some other student's solutions. Some students were clearly experienced programmers- their code was 5 lines of densely packed recursive algorithms.  At first I was discouraged and thought "What can't I do that ?", and "Why doesn't my code look that ?".  Then I reconsidered. My solution to the Caesar Cipher represents my  single handed efforts at solving a problem. The solution was based on the 4 weeks of experience I have with Ruby.  Sure, there are built in methods that would have accomplished the task more elegantly (like the .modulo method).  Sure, I could refactor my code making it shorter and making it run faster. But, until I learn those methods and refactoring techniques, using them because someone else told me to would short circuit my learning. When I do search on StackExcha...

7th Week-Progress

I have entered the 7th week since my fatal decision to become a master coder. What progress can I report?    I finished The Odin Project's Web Development 101 course on Monday and began the third course in curriculum : "Ruby Programming". Although I completed the Codecademy Ruby course and did some other Ruby work a few weeks ago, I felt I needed a review.  To this end I am redoing the Codecademy course, I completed Chris Pine's book  Learn to Program,  and I reread Chs.2 + 3 of Peter Cooper's Beginning Ruby .  Needless to say, the revision was worth it- I have a much clearer understanding of blocks and procs, as well as hashes and arrays. Concurrent with the Odin Project I am working through the  Epicodus curriculum . It is always helpful to have multiple perspectives on a subject. I have also discovered an intriguing course called FreeCodeCamp . It isn't complete yet, but the aim is to train students to write code for non-profits. Much of t...

Rails Project-Blogger Problem

Ran into my first challenge with the blogger today. I was creating a new model for a Comment feature and I typed: $ bin/rails generate model Comment author_name:string body:text article s :references That single red letter cost me an hour of struggle (I mean 'learning'). The extra s created a database schema containing something called 'articles_id'.  Since id  is a property of a single article, the comment controller  couldn't find an id  for articles,  as it didn't exist.  I looked at the Comment model file and saw the extra s  almost immediately after trying to enter a comment. But then I couldn't reverse the error. Rolling back the migration ( rake db:rollback), had no effect on the schema.  Destroying the model ( rails destroy model Comment)  had no effect on the schema. In the end I replaced the my local files with the Github repo contents (luckily I had just done a push). git fetch --all git reset --hard or...

Week 5-Progress

Going into week 5 I feel I am making great progress.  Yesterday I completed and submitted my Javascript Etch-a-Sketch project for Web Development 101. It's not perfect, but I added a couple of extra features (such as colour choice)-one improvement I could make is to change the colour choice to a radio button format and allow colour change without erasing the image. In the end, the project only took a few hours, but that was after going through HeadFirst books on HTML/CSS, JavaScript and jQuery. For some reason, my brain was stuck in HTML mode and I couldn't see how to create the webpage using only Javascript. Once I remembered the jQuery method of creating HTML elements, it was easy.  I spent some time trying to figure out how to increase colour intensity with each mouseover event. The pseudocode is easy, but I can't get the Javascript syntax right-I will go back to it  when my Javascript has improved. I spent the last day completing the Codecademy Ruby course-mo...

Final-Reference Variables-Constants in Java. What does it all mean?

So far, my programming journey has been easy riding. Everything in computer science I've come across so far seems so logical and (really) obvious after a moment's thought. (n.b. The following will contain mistakes, don't copy and paste this for your Comp.Sci.101 Assignment. If any readers can help clarify my thinking, it would be much appreciated.) Well, except for constants in Java. In Java, you can define a variable and give it a value:   ( e.g. Year current =1932;  creates an variable of type Year and initializes it with the value 1932). Speaking correctly, the variable   current  is NOT equal to 1932. Rather, current is a reference to a location in the computer's memory where the data 1932  is stored. A variable name like current  can be thought of as a listing in a telephone directory: "To find the current year, go to this address in the memory." Variable are so called because their values can change during the running of a program. For ...

Elegance

Here's an example what 'elegance' means in programming. These are three solutions to a Project Euler problem .  All three programs do the same thing-find prime factors of a given number. (I've removed comments). The relative sizes of the scripts are 1.285kb, 0.694kb and 0.139kb respectively. 1) var biggestPrimeFactor = 1; var numberToFactor = 600851475143; var factorArray = [] for (i = 2; i <= Math.sqrt(numberToFactor); i++) {     if(numberToFactor % i === 0) {         factorArray.push(i);         var isPrime = true;         for(j = 2; j <= Math.sqrt(i); j++) {             if(i % j === 0) {                 var isPrime = false;             }         }         if(isPrime === true) {             biggestPrimeFacto...

Current Courses

          In an attempt to enlarge my skill-set and keep my brain gears well oiled, I am studying computer science, programming and data analysis. Fascinating courses on every subject are easy to find these days and data science seems to be extremely popular. Programming/Computer Science    1.  At the moment, I am working through the free Saylor Academy Computer Science Pathway. Unlike MOOCs offered by universities, Saylor Academy comprises courses cobbled together from already existing online resources (though there are some original resources).            So far, I am very impressed with the Computer Science course ( CS101 ): it is  logically structured (each new unit builds clearly on the last) it provides multiple resources on each concept (videos, readings, interactive pages)  it includes regular assessments (including self assessed programming assignments)         ...

My First Control Structure in Java

Here is my first original program, written after 5 days of learning java. The goal was to include a looping control structure with decision making paths (if/else). ____________________________________________________________________ import java.util.Scanner; public class AverageTemp  { //Calculates the average temperature of weekdays in centigrade  public static void main(String[] args)  { Scanner keyboard = new Scanner (System.in); double monday, tuesday, wednesday,thursday,friday; char option; //User input for five weekdays do { System.out.println ("What was the average temperature on Monday?:"); monday = keyboard.nextDouble(); System.out.println ("What was the average temperature on Tuesday?:"); tuesday = keyboard.nextDouble();  System.out.println ("What was the average temperature on Wednesday?:"); wednesday = keyboard.nextDouble(); System.out.println ("What was the average temperature on Thursd...