“Mooc Progress” huhuh get it…

Summary

Since I last posted I’ve completed my college project EducationRec and completed part 8 & 9 of a MOOC Java Programming course. I’m planning on working on improving my site and completing another 2 parts of the MOOC course over the next week.

Projects & Study

RubyonRails - EducationRec

In my project I tried to implement a major change to my programming style to make my code “Clean” and apply “DRY” (Don’t Repeat Yourself) methodology. Which meant I removed a lot of code that did the exact same thing and instead reused the code in one place.

DRY code is easier to understand and to change as you end up only having to change the code in the one place in the future. I also renamed my methods and files so as they made more sense and formatted my code.

I feel it made my project a lot more presentable and professional and most importantly I don’t feel ashamed having it on my github!

Out of all my code I’m most happy with the error message code. I know it is very basic, but it shows good use the DRY and what I’m trying to work towards. The code works for any object that is passed into it. An object can be set as any valid object in my case User, Skill and Candidate. You tell it what object it is getting by passing your object like this object: @skill this sets the object to be equal to the local variable skill.

_error_message.html.erb

<% if object.errors.any? %>
  <div id="error_explanation">
    <h2><%= pluralize(object.errors.count, "error") %> prohibited this from being saved:</h2>

    <ul>
      <% object.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
    </ul>
  </div>
<% end %>

Code for injecting the error message render

    $("#candidateerrors").html("<%= escape_javascript(render "home/error_message", object: @candidate) %>");

Mooc.fi - Java Programming

I’m currently completing a free Java Programming course by the University of Helsinki.

It isn’t an abridged course and is the same as two courses taught at their college CS1 Introduction to Programming and Advanced Programming.

You can do this course as a beginner with no prior experience or if you have some experience you can search through their contents and decide which part to start at.

Before I started my course in college I completed part 1-8 of the old version of this course. I really felt if gave me a big head start over others in my class, so I would recommend it to anyone who is looking to start programming!

In the last week I have started back working on it from the mid way point of the course (part 8) as a way of filling gaps in my Java knowledge. A lot of the material is very similar to what I learned in college, but I have found plenty of areas where I found this course to go into more detail or just explain a concept better.

At the moment I have completed part 8 and 9 covering the following topics

Hash maps

Hash maps are a really efficient way of searching for specific data. A Hash Map consists of a Key and a Value the Key is the what you search for to retrieve the Value.

They both have to be objects as Hash Maps use HashCodes to decide where to store the objects.

Unlike with an Array list where you may have to search through the entire table index by index and check each Object to see if it matches; with hash maps you can search for the object as a Key and the hash map uses the hashcode like an array would use an index number passed to it to check the index and return the value.

Hash codes & Equals

In Java all objects have equals and hashcode this means you can configure your own equals and hash codes to allow for objects which are of the same type to be stored at the same hashcode or for checking if two objects of the same type with different references are the same as the default equals checks if they are of the same reference.

Class inheritance, Interfaces and object polymorphism

I learned -

  • Why every object has methods toString, equals, and hashCode (Every java class extends the class Object, so they have its methods).

  • How inheritance, superclass, and subclass work (Using parent classes constructors, overriding or using their methods).

  • That an object can be represented through all its actual types and how this can be useful (“Programming to Interfaces” ArrayList and LinkedList are both Lists so have overlapping methods).

Current Focus -

Blog Face Lift

I want to change up the layout of the blog and add some flair to it. I’m not sure exactly what that will entail yet but hopefully it’ll be complete by my next post.

The only slight improvements I’ve made to the layout since I put it up is a sticky header and adding a project tab which isn’t much!

Study

I’m going to continue on the MOOC course complete part 10 and 11 by the time I make my next blog post.

Thanks for reading and happy coding!