Day 57, last day of client project

Worked until 11:30pm. I am a freeman now.

Last couple of steps:

– Remove unnecessary comments

– Remove or disable all console.log()

– Remove unnecessary functions. Even in such a short project, there are major code refactors rendering some code irrelevant. It is sad to have to delete large chunk of working code. Well, someone said, if software engineers are paid to delete code, the world will be in a better place. Let’s hope that is true.

– There are still tons of bugs to fix, so I put all of them under a “known issues” page in the wiki.

We also demoed our personal projects in the evening. Some of them are really impressive, such as the dinosaur game, Felix’s RPG game, the recommendation engine Raccoon, Andrew’s 3d music visualizer, Chris’ Chrome plugin to control browser with a phone, Barry’s application to control multiple client screens with a phone. Very impressive indeed.


Day 54, Thorax 101

Only after using it for three weeks, I begun to understand the differences between Thorax and Backbone

– Thorax automatically fetch model/collection for a view when:

var view = new Thorax.View({
  model: myModel

var view = new Thorax.View({
  collection: myCollection

//Please don't try to fetch again

– “Note that while any view may bind a collection only a CollectionView will actually render a collection. A regular Thorax.View may declare a collection helper which in turn will generate and embed a CollectionView.” This means:

//in your admin.js file
var view = new Application.Views["web/admin"]({
  collection: admin
view.admin = admin; // this is absolutely necessary if view is a regular Thorax.View

//so that you can do this in your template, which is your admin.handlebars
{{#collection admin}}
  {{name}} //name is a property of the model inside the collection

Day 53, sequelize

Finishing up connecting Backbone to the API endpoints. Running into so many problems with Sequelize.

Here is one problem:
– Sequelize assumes that your table should have a column ‘id’ with primary key, auto increment, not null. If you create the database manually through MySQL Workbench, then your table might not have that column. The only way to solve the problem is to actually add that column in the table. I couldn’t find a way to disable this assumption.


Day 52, getting there

As expected, Larry spent only half a hour to fix the query. The biggest issue is, is, Sunday = 1 in SQL!!! We used JavaScript to convert dates to days and who thought Sunday = 1 in SQL. Lessons learned, certainly the hard way.

Additionally, I spent one hour trying to just submit that query through Sequelize and couldn’t get anything back. I hypothesized that I must have been missing some fields in the schema file, but can’t pin down the problem. In the end, I ended up using node-mysql to get my results back. Sign…

The good news is two of the most complicated queries are up and running, so we now have bandwidth to finish all the other stuff. At this point, it is likely that we will actually be able to finish the project on time.


Day 51, crazy SQL

At the beginning of the project, Larry wrote a 100+ line SQL query to deal with one of most complicated business logics. Now we can’t get it to work.

We first spent one hour debugging the SQL query.

Then we decided that the SQL query was too hard to maintain and we might as well take an alternative route. I spent my entire Sunday writing a similar query using smaller SQL queries and promises. Joe decided he was going to do something similar, so he spent an entire night writing the query using smaller queries and promises.

At 10pm, Joe’s program almost worked. However, we realized that the JS version of the code is not necessarily much cleaner than the SQL query…

Anyway, let’s wait for tomorrow.


Day 50, we lost one member

Many things happened today.

The new class started and we, became, the step children. One of the classmates said, it feels like that there is a new baby in the house. haha

Code review with Steven. Learned something very useful. Apparently, inside Express, I can use

//instead of
//not 100% sure...

Finally, our class lost one member, Sonomi, and I was shocked. I noticed that she wasn’t around but I thought she might be sick at home. Then 10 minutes before I called it a day, I was told that she was gone from the class. What I don’t like is that: there is no announcement nor no explanation on what happened. Sigh…

Also spent a couple of hours breaking down our 600 line API file into multiple files. Refactor code is always an interesting experience. I am glad that it turned out to be ok. After refactoring, I spent most of my time working on several API endpoints. It was fun.


Day 49, coffee surfing and the secret of happiness

The secret of happiness is imagining BART is going to strike every Monday and you are only told at 10PM Sunday night that, they are actually NOT going to strike. So, you will actually be able to go to work by train tomorrow. Seriously, this is the key to happiness. I think BART finally discovered the solution to Sunday blues and Monday blues.

The f**** BART was going to strike again tomorrow. The carpool was arranged and I even went out and bought a Fastrak. Until 10pm, good news, no strike for at least seven more days!!!! Yeah!!!! The entire house was celebrating and then we realized, this is the secret to a happy life 🙂 Your expectation is so low that you will celebrate for the opportunity to go to work on Mondays.

I did my fair share of working today. Spent an entire day at this place.
Peet’s Coffee & Tea @ Public Market
Address: 5959 Shellmound St #85, Emeryville, CA 94608
Phone:(510) 844-0850

Overall, positive. I paid my cheap coffee rent by buying breakfast with coffee in the morning and another coffee in the afternoon. I hope they don’t mind too much…

Wifi is fast. There are some power outlets. The Public Market has a big food court, and it is just at the back of Peet’s Coffee. Since Public Market has free Wifi too, you should always be able to find a place to sit. Most chairs inside Peet’s were uncomfortable and maybe they did that to keep people from occupying the desk for a long time.

Was fairly productive today. Spent most of my time working on the backend, writing functions to return JSONs for different routes.

I had so much trouble with Sequelize in the last couple days, now everything is just raw SQL queries inside Sequelize. It defeats the purpose of using an ORM, but hey, an ORM can run raw queries, but not the other way around.

With database queries come with callbacks and promises. The q library is neat and makes the code much easier to read.


Day 48, the power of dummy JSON

It is a simple but very powerful idea. Similar to the idea of ghost chart in management consulting, dummy JSON files allow you to set up your API server in hours instead of days.

Assuming you are writing /api/v1/tweets, instead of querying the database and return the correct result, you can just write the expected result in an object, and return the string version of it. For example, just do this in the node app:

var output = [{title:'tweet1'},{title:'tweet2'},{title:'tweet3'}];

The benefits are:
– many API endpoints can be set up in a short period of time
– reduce the uncertainty in the system. Basically, the backend shouldn’t cause any bug. All unexpected behaviors should come from the front end code
– allow parallel working streams. The front end developers can continue to work on the front end, without waiting for the backend.

I regretted that we haven’t thought about this early this week. It would save us so much time. With the help of dummy JSON, I was able to fix bugs in my front end code. When I am producing more backend code, I just remove the dummy JSON with the actual dynamically generated result. This is almost the idea working stream.