Qt's Home

The Story of a french guy discovering the world

Week 6 - Day 1 - More OOJS, APIs, and Changes

| Comments

More OOJS

Yesterday, I paires with Harry. We have a great dynamic going on and we ended up building a good MVC system on Javascript for one of the challenges we had.

People don’t necessary get it so by the end of the week I’ll try to send some code that I came up with for private projects, as an example.

As for the rest, we had a lot of fun and played with that a bit, to the point that we ended up falling short on a problem that apparently many people have. It feels good to not feel like you’re outside of that whole development world ;)

The problem we had was : We made a Controller class, and just to Namespace and separate concerns, all the AJAX calls were used from the Ajax Controller, a class of its own.

Now the problem we hit is :

  • Who calls the Ajax controller? –> The controller
  • What does the Ajax controller in case of a successful request? –> The controller

That is a problem, how do you link two objects when you can not create both at the exact same time?
And so our solution was to pass one as the argument to the other (The Ajax Controller knows about the controller), and then add the Ajax Controller to the controller

In demonstration :


var AjaxController = function(controller){
    this.controller = controller;
}
// Do stuff with the ajax Controller

var Controller = function(){}
// Do stuff with the Controller

$(document).ready(function(){
    var controller = new Controller();
    var ajaxController = new AjaxController({ 
        controller: controller // First link
    })
    controller.ajaxController = ajaxController; // Link back
})

In the end, that looks very hack-ish. But then it is actually a question that people have nowadays : How do you do that? And like every good programming problem : There is no right or wrong answer ;)

I’ll stick with that for now.

APIs

APIs are interfaces for your program to be able to play with some web apps around. The idea is that instead of posting status via Facebook, you build an app that can do that for you somewhere else. The link between that App and Facebook is that API.

Your app will send a message to Facebook saying (write_status) and that will write the status.

Yesterday we started playing with Twitter and that was fun, and today we play on more… So expect some nice links in the near future ;)

Changes

I feel like DBC changes people. Not necessarily in the best way, but that does change people anyway.

I feel changed, I AM changed. But then, you will be able to see that the next time you meet me ;)

I am more confident, deal with my problems a more logical way, I empathize more with my peers… All in all, I like to think I took the good in that program. I may also have taken the bad, but then I don’t know about that yet… Only time will tell!

Comments