Blog: codeJourney

Immersed in JavaScript and More Projects

Posted on

In order to get deeper into the Rails ecosystem, I figured it is time to create a few Rails projects and contribute to others on Github. So far I have done the former and will embark on the later sometime this month.

Now that I have a few self-made projects under my belt, I feel it is time to include them in my online portfolio. Since I am revamping my portfolio page, it may be a good time to get my own domain name as well!

It is almost a given that you must know JavaScript and as the founder of WordPress said not only be familiar with JavaScript, but “Learn JavaScript, Deeply”. I’ve been immersed in everything JavaScript in the last few months. At my full-time job, I have had the opportunity to not only write plain JS, but utilize Backbone.js, Underscore.js, and of course jQuery. Additionally, for fun, I built a Rails project using Facebook’s React.js!

Some useful resources have been the following for JS learning in 2016:

Online Tutorials: freeCodeCamp, CodeSchool, CodeAcademy

Books: Profession Javascript for Developers by Nicholas Zakas, JavaScript: the Good Parts by Douglas Crockford, Eloquent JavaScript by Marijn Haverbeke

Blogs: JavaScript is Sexy, JavaScript Weekly, Paul Irish’s work

Podcast: JavaScript Jabber, 5 Minutes of JavaScript, Software Engineering Daily


Working on Projects

Posted on

I have taken a brief break from blogging to work on some projects. In this short break I have built an online bookstore and I’m currently working on creating a blogging app for a local neighborhood club, which can be seen at Github (dbess1). The blogging app is taking some time, especially since I am including a log-in system with encrypted security. In addition, I have picked up larger client that wants a revamping of their natural beauty supply e-commerce site. All in Rails.

What I have gained so far in my break is the ability to utilize SQLite and SQLiteStudio to visualize the data. Just coming off a week-long SQL training “bootcamp”, this is exciting to be able to apply it so quickly. I am also gaining a better understanding of the MVC process in all this. These past few weeks, I have picked up Sass, HAML, and worked with Backbone.js through all this. Going to the Docker and Kubernetes hands-on meetup at the Google Cambridge office was fun too!

Lastly, I have put a pause on Michael Hartl’s Tutorial (for the moment) and actually picked up Obie Fernandez’s The Rails 4 Way. This reference book is for the more advanced Rails developer, but has giving me some deeper insight on the Rails infrastructure. All this while continuing to listen to Giant Robots Smashing into other Giant Robots, Learning Rails, Ruby on Rails, RailsCasts, and Ruby Rogues podcasts.


Ruby’s World

Posted on

I attended my first Ruby Boston Meetup this past week and one of the guest speakers was Mark Bates. His presentation essentially reinforced my excitement in working with Rails and Ruby. In reflection, his main point was to demonstrate that as a small start-up business (or lone ranger) that intends on developing an app, Rails is the most efficient way to go. Trying to juggle all the different kinds of tools, frameworks, and libraries just to get a simple app up can cause headaches.

In some way, Rails has bolstered Ruby’s popularity. People will discuss the elegance and feel of the Ruby language, but it is hard to deny that its prominence is largely due to the Rails framework.

Hartl makes it clear in chapter 4 of his Tutorial that one will only need a basic rudimentary foundation of Ruby to work with Rails. In fact, there are a number of people who want to jump right in to Rails, building apps, with no programming knowledge whatsoever. Therefore, he presents Ruby from a Rails point of view, from what he calls a “Rails-flavored Ruby”.

I will delve more in to this later, but suffice to say there are tons of resources online and traditional classrooms and books to pick up Ruby. As I mention in my earlier post, Learn Ruby the Hard Way is an excellent starting point.


Test Driven Development

Posted on

Chapter 3 of Hartl’s Ruby on Rails Tutorial is nominally about setting up static pages, but the crux of this chapter was the introduction of Test Driven Development (TDD).

In the last few years there has been major discussion on the necessity of TDD, to the point that David Heinemeier Hansson, the creator of Ruby on Rails chimed in with his own thirty-seven cents! “TDD is Dead,” Hansson says.

I appreciate Hartl’s non-dogmatic approached to this subject by using TDD in moderation. As they say, “everything in moderation is better for you.” Researching and discussing with other senior developers, TDD has the following rules:

  1. The most important is to write and run the test code before you run the actual application code. Hartl specifically suggest to write the controller and model tests first, and integration tests second. Integration tests are great because this is used to mimic a user dynamically interacting with your web app.
  2. The first test you run should fail. Then use the errors of that failing test sto help you write the application code.
  3. Once the code passes the tests, then it can be refactored.

TDD is not a new concept, but Rails attempts to make it little easier from the start. When you generate your new controller, i.e. rails generate controller, Rails automatically creates a test file! In the terminal type:

ls test/controllers

You should see the controller_test.rb file. Opening that file up in your text editor, you should see generated Ruby code that issues the HTTP operation GET and makes sure it receives a “success” status code.

To write a failing test, Hartl throws in another page inside the Ruby code. Since he built the Home and Help pages, now he wrote a few lines to request an ‘About’ page. After writing that, you run the test by typing in the terminal:

bundle exec rake test

This automatically indicates a fail. Why? Well, because there was no Route that was created to match the About controller. Input a GET request inside the config/routes file and run the test again:

bundle exec rake test

Another fail. Why? Because we didn’t define an ‘About’ action in the Static Pages Controller. Define the about page in the static_pages_controller.rb file. Now, test again– Darn, failed again! What’s the error? There is no View anywhere to be found, i.e. there is no HTML file that Rails can call on to give our users a visible page! Hartl creates an html.erb page by typing:

touch app/views/static_pages/about.html.erb

The other way of creating it is to simply right click on the directory folder and just create a new file with an appropriate name (making sure to have an html.erb extension). Now you can put in some HTML code for a quick presentation, run the test again, and voila, it passed! Which means you can see the ‘About’ page in the browser, along with the ‘Home’ and ‘Help’ pages.

Lastly, code can get a little ugly looking to the human eye, or smelly as it’s called in the tech world, we must refactor. One of the things to look for are repeated code blocks. Employing the DRY (Don’t Repeat Yourself) principle is vital in Rails community and one should be cautious of violating it!

What I took away from this is getting into the skin of Rails and witnessing how the organs operate by utilizing MVC.


SQL Server Bootcamp

Posted on

It has been a busy few weeks and I will have to skip a lengthy blog this week. I will be immersed into a SQL Server Bootcamp all week. Perhaps I can report on this soon.


.NET World

Posted on

Even with all the fun work I have been doing with open-source software and frameworks, I end up getting a job (fortunately or unfortunately, however you want to look at it) in an enterprise environment. I have been immersed in the .NET world and now find myself working on open source frameworks in the off hours and weekends.


Ruby on Rails Tutorial: Scaffolding

Posted on

As I mentioned in last week’s post, Michael Hartl’s entire tutorial not only gives you a taste of Rails, but teaches you the overall process of web development generally. That is precisely why the first Chapter gets you started from nothing to deploying a simple Hello World App (loosely speaking) to production!

Chapter 2: A toy_app

This gives a very good high-level overview of the power of Rails. Hartl reluctantly demonstrates the scaffold model by giving a disclaimer that he would not use this for any serious application, but for demonstration purposes, this gets a prototype app up and running fairly quick. It is quite amazing how you can have an app up in production via Heroku in a matter of an hour!

After bundling new gems, Hartl immediately puts this toy app under version control with Git, so you are exposed to Git from the very beginning. This is why it is truly important to get the fundamentals of Git early on. He pushes his app up to a Bitbucket repository (“repos”) and then pushes it up to production with Heroku. There is a short dialogue box in chapter 1 about his preference for Bitbucket over Github. In sum: it comes down to Bitbucket having unlimited private repos versus Github’s unlimited public repos.

Rails Scaffolding

Next, he describes a visual structure of the data model, since the app will have users and microposts (i.e. tweets).

Generating a scaffold with attributes is quite simple, from the command line you type:

$ rails generate scaffold User name:string email:string

The name of scaffolds must be singular (i.e. User, not Users). This is the same convention for naming Models; however, this is the opposite for naming Controllers (always plural).

Now, because we are dealing with databases we will have to migrate the data model (i.e. the users and emails in this case) to the server. You do this by typing in the command line:

$ bundle exec rake db:migrate

In just those few commands you have a small app that you can play with which implements a typical CRUD standard for users!

I do appreciate Hartl going through this process although there are a ton of weaknesses that follow along with the scaffold method. The main downfalls I see are the lack of security and real testing. Nonetheless, it is a good way to demonstrate a prototype to a client.

Lastly, since this is my second work-through of the book, I was happy to find a free sample of his screencast of this particular chapter! Screencast.


Ruby on Rails is Right on

Posted on

Prior to the Fall 2015 semester, I figured I would get a jump start on Ruby on Rails, so I Googled around asking what was the best free tutorial or book on the framework. The number one search result then (and still today) was railstutorial.org, which happens to be a tutorial book. Perfect! With overwhelming reviews that this was a valuable resource for beginners and intermediate Developers, I plunged forward!

The Fall semester finally began, and my choice of reading Michael Hartl’s tutorial before my free Ruby on Rails course at CCSF was right on the money, because lo and behold, this professor used the very same text for the course!

As many people have stated, this is an amazing tutorial, because Hartl gives you the steps to build an entire app. The prototype app that you create functions like a Twitter-like clone. Here is my first ever application I built from end to end: CatNipz

Lastly, for anyone who is jumping right into this tutorial for the first time with little to no programming experience, a lot will fly right over-the-head; but, my suggestion is to plow through it somewhat blindly and go back through it again to catch all the little details.

I am now on my second go-round and although I felt I missed a lot of little details, what I did gain from the initial reading was an understanding of the general process of web development (particularly web app development) from end-to-end. Everything from refactoring, MVC, version control with Git, integrated testing, deploying, etc. will be communicated clearly for the reader.

Note: With all this said, what I will do from here on out in my blog, is continue to hike through my coding path, but interweave reviews and thoughts of Hartl’s work (perhaps by chapters). I am doing this because, as I am going through the Rails tutorial for the second time, I have found myself taking notes and highlighting, so I figured I will document this publicly. Additionally, I have started Hartl’s other tutorial called Learn Enough Git to be Dangerous, which potentially could be read in parallel to the Rails tutorial.


Taking on Ruby

Posted on

My end goal was to work with the popular framework Ruby on Rails, so I figured I would learn Ruby first. This was a linear approach to developing a full understanding of RoR, but in the end this has been beneficial.

Being a San Francisco resident, I have the wonderful opportunity of taking free courses at the City College of San Francisco. The Ruby programming course used the Learning Ruby book by O’Reilly, but I additionally used the online tutorial book called Learn Ruby the Hard Way.

After that semester, I reworked through Learn Ruby the Hard Way and also had fun with Why’s Poignant Guide to Ruby all throughout the summer. As with any new programming language, it is a work in progress, but I certainly felt confident to approach Rails with some fundamentals.


C, C++, and Ruby

Posted on

In college I developed my first program in C and stuck to that for some time. Although it was beneficial in getting a basic understanding of a compiled language, I never really got the feeling that this was a beautiful language at all. Thus, I did not stick with this.

My partner was a Linguistics and Cognitive Science major and it was required for her to take a programming language. She chose C++, and I would have to say that it was fun working with her on the assignments, but I still didn’t think I would be committed to this language as well; however, I will probably go back to it if I get into game development.

After several years of being away from all programming, I wanted to learn one of the hotter interpreted languages. My choses were Python or Ruby. After researching and talking to many people offline and online, I eventually settled upon Ruby.

The deal breaker was Ruby on Rails, which I will get more into on this blog. Needless to say, the community around Rails is electric and the creators of both Ruby and Rails, respectively, are phenomenal.