simonemiller-blog
simonemiller-blog
Web Dev Bootcamp
4 posts
Intensive 12 week web app development course with WeGotCoders
Don't wanna be here? Send us removal request.
simonemiller-blog · 8 years ago
Text
Web Dev Training with #WeGotCoders: Week 4
We continued our thread of persisting data by looking at databases and SQL.  Starting off with SQlite3, the SQL Docs and this SQLite Tutorial was really helpful, especially for going through CRUD actions and joins.  
We later looked at models, migrations and associations in Active Records…and how Active Records generates SQL queries for us – Active Records Magic
Next stop Postgres…
1 note · View note
simonemiller-blog · 8 years ago
Text
Web Dev Training with #WeGotCoders: Week 3
This past week we’ve been looking at TDD with Minitest & Rspec.  
We were working on a flight calculator, that takes coordinates and flight details and works out the distance between two airports and the estimated time of arrival.  We used Minitest to drive the development and were looking to refactor the calculator with SRP, extensibility and re-usability of code in mind.  
A separation of concerns lead us to create two classes – flight, that contained knowledge of its own airline, flight number, destination etc, and Coordinates –  which was responsible for calculating the distance between two point using longitudes, latitudes and radians.
We’re now working on persisting the data, and producing reports of incoming flight information in html, csv and text formats.  We’ve created extra Reports classes and sub classes to handle the report generation.
Here’s some of our tests for the Coordinate class:
describe "Coordinates" do  before do    @lhr = Coordinates.new(lat: 51.4700223, lng: -0.4542955)    @jfk = Coordinates.new(lat: 40.6413111, lng: -73.77813909999999)  end
 it "has objects which know their own latitude and longitude" do    @lhr.lat.must_equal 51.4700223    @lhr.lng.must_equal -0.4542955    @jfk.lat.must_equal 40.6413111    @jfk.lng.must_equal -73.77813909999999  end
 it "converts lat and lng into radians" do    @lhr.to_radians(51.4700223).must_equal 0.8983213552099045    @lhr.to_radians(-0.4542955).must_equal -0.0079289522519939    @jfk.to_radians(40.6413111).must_equal 0.7093246910223184    @jfk.to_radians(-73.77813909999999).must_equal -1.287671443289366  end
 it "calculates the distance to another coordinate object" do    @lhr.distance_to(@jfk).must_equal 5540.01265634309  end end
1 note · View note
simonemiller-blog · 8 years ago
Text
Web Dev Training with #WeGotCoders: Week 2
This week we’ve been focussing on object-oriented programming, and refactoring previous assignments with multiple classes to model real-world scenarios more closely, and encapsulate our code in methods.
We’ve also been working on modules, and implementing our own each and spaceship operator methods, giving us access to the Enumerable and Comparable modules within our own classes.
Here’s an update on the Transport for London assignment, where info about the Tube Line and Underground network have been separated out from the Journey class.  A class method, user_journey, now instantiates a journey object with a start and finish station, and the Underground class is responsible for working out what line a station is on.  TFL Project
1 note · View note
simonemiller-blog · 8 years ago
Text
Web Dev Training with #WeGotCoders: Week 1
Intro to Ruby
This week’s been an introduction to Ruby.  Strings, Control Structures, Data Structures, Methods, Classes & Objects and Code Blocks.
Transport for London Project
As part of the Data Structures track, we’ve been working on a command line app that plans a user's journey on the London Underground - Transport For London.  This involves modelling a subsection of the tube network, prompting a user for their start and end stations, and printing out their route.
We chose to model the tube sub-network using a hash of arrays, and began the process with a procedural approach, prompting the user for input along the way.
I’ve been working on refactoring the code with an object-oriented approach, using a Journey class and initializing each journey object with a start and finish station.  
Here’s the code so far: TFL Project
I’ve encapsulated each procedure within a method, so that the code prints out the stations between the user’s start and finish stations.  If they need to change lines to complete their journey, Oxford Circus is the intersection point.
There’s 6 general journey outcomes:
Travelling eastbound on one line
Travelling westbound on one line
Travelling eastbound on more that one line
Travelling westbound on more that one line
Travelling eastbound, changing at oxford circus, and continuing westbound on another line
Travelling westbound, changing at oxford circus, and continuing eastbound on another line
Next Steps
Adding control flow so that the relevant method is called when a journey is entered.
Refactoring!  There’s still lots of repetition and I’m using the return value of methods to access out of scope variables.  This is making the code quite unwieldy and needs work....once I get my head around scope! 
1 note · View note