Thursday, June 7, 2012

NDC 2012 Day 2

This is a technical blog entry of what I've learnt during the day. So if you don't have a computing background you might not understand all of it. That or you might find it rather head spinning.

9am Another morning start and this time the trains ran on time.  I met a work colleague today, turns out he is attending days 2 and 3, but he showed up late for the morning conference.  So we talked for a bit after 1st session.  I chose the session called "Javascript All Over - Sticking your big toe in Node.js" by Sara Chipps.  Unfortunately the session did not meet my expectations, the description of the session said there was going to be a working Node.js program in 60 minutes.  Instead the talk was about failure in one of her hackathon sessions in New York, so it was completely different to what the talk was supposed to be about.  Here's the supposed description "In this talk we will build our first node appliation together.", "learn how to send serverside JS clientside, how to write our own modules and where to look for simple hosting".  Needless to say, I was disappointed.  That's the problem with these talks, you don't really know what you're getting, and in this case it was completely different.  I don't think many people were happy.  Anyway, she suggested a book called Peopleware and mentioned that software failure is often people, not technology.  She mentioned hackathon sessions in new york like Photohack day where if you win the hackathon you get to be on the NASDAQ screen and $10,0000 (Not relevant, but she also made a joke on how $10,000 is like 5 NOK.).  Also talked about the face.com API which is apparently quite interesting, it can recognise your face and tell if you're a girl or a boy in percentage terms and things like that.  Also talked about Node.js hosting.  Which is apparently a javascript framework of sorts, that's as much as I know.  She said she spent too much time on authentication frameworks in her application which was basically allowing anyone to upload a picture and getting an octocat (search for it on google, it's the mascot of the Github website).  And that was the downfall of the team, apparently everyone else in her team of 4 (including her) worked their asses off but she failed them.  So the supposed would be very  cool application, wasn't completed in time during the allocated 24 hours.  Her lesson learnt was to only learn 1 thing new at any one time.  And that's it pretty much.  I didn't learn anything of Node.js which is well, very disappointing.  Not sexist or anything, but I don't usually see female presenters present much, so it was a real letdown!  Also her code presentation broke down several times, bummer.


Sara asking "Who has done client side Javascript?"


Her background.

Had a banana smoothie before the next session.  (Note: The food that I had for the entire day is the same as the previous day.)

10:20am  This session was freaking great.  Venkat Subramaniam presented "Design Patterns for .Net Programmers".  He began with "I hate design patterns" because they are not a good way to innovate design.  He gave an example of how your grandma makes great cakes, and you asking her for instructions to bake one doesn't necessarily mean that you'll make a great cake.  He is referring to the GoF (Gang of Four) design patterns book which are written by "grandmothers" of the industry.  He did say that they are a good tool for communication.  He typed code on the fly and showed how to make them better to read and understand.   The first example he gave was the Cascade pattern.  Basically it allows you to daisy chain functions by returning the object itself.  e.g.

class Mailer { // all void methods
  to(string);
  from(string);
  subject(string);
  body(string);
  send();
}


class Sample {
  mailer = new Mailer();
  mailer.to(...);
  mailer.from(...);
  ...
  mailer.send();
}

Not very nice to read or follow.  Instead change it to the following.

class Mailer {
  Mailer to(string);
  Mailer from(string);
  Mailer subject(string);
  ...
}


class Sample {
  mailer = new Mailer();
  mailer.to(...);
        .from(...)
        ....
        .send();
}

That's now a lot easier to read and use.  But how do you know when to stop, as in knowing that send is the last method to use?  Well you could wrap up the send method up in a static class like this.

class Mailer {
  static send(Action<Mailer> action)  {
    Mailer mailer = new Mailer(); // private c'tor for Mailer
    action(mailer);
  }
}

then to use it, do the following

class Sample {
  Mailer.send((mailer) =>
    mailer.to(...)
              .from(...)
              .subject(...)
              .body(...));
 }

Nice!  He also gave a pluggable behaviour example.  I won't provide the code sample here but it involves using Funcs, which is basically the strategy design pattern.  Also mentioned how idioms are useful, learning idioms from another language can allow you to apply them to a different language.  He also talked about the ExecuteAround pattern which basically means there is only 1 way to use the class.  e.g. try ... finally.. idiom, you can wrap that up in a Resource class and perform the clean up there instead of doing it outside the class.  Then you pass in the Resource class the Action you want to perform on the Resource, and the cleanup will be done by the Resource class.

After the talk ended I had some noodles, the same ones as yesterday, except with chicken.  It was still pretty bad but I just wanted to eat something.  Also had a pear.

11:40am  I attended "Interactive user experience: natural user interfaces" by Alisa Smerdova and Felipe Longe.  They talked about how UI involved over the years, and predicted human to human communication may one day become extinct.  Now that's a scary though.  It will be like Surrogates the movie.  Maybe worse!  Anyway, Felipe gave a demo using Kinect, how he controlled an avatar using his movement on stage, and Alisa talked about Surface and Felipe demo'd that.  Side note, Felipe was reading notes on stage while presenting, not a good idea, does not convey confidence! :)  What else?  WPF 4 provides touch events, and the ScatterView class provides that for free, all you need is to wrap your objects with that class.  After the talk you could walk down and play around with the surface table that was manufactured by Samsung.  Cost?  68,000 NOK or 11,0000 USD.  Surface can detect your entire palm movement as well as the orientation of your finger, so it's a bit more advanced that the iPad.  I played around with a jigsaw game with others around the table for fun, that was interesting.  We were finishing one puzzle when someone else hit another button for a different puzzle so we had to start over, but it shows collaboration isn't that easy and still needs to be though out.


Felipe demonstrating Kinect.


Demonstrating MS Surface.


Demonstrating MS Surface.

Lunch was Chicken tiki masala again.  Had a pear as well.

1:40pm Attended "What is OO?" by Robert C Martin.  Robert started off by talking about epilepsy and how they used to cure epilepsy by separating the left and right hemispheres of the brain.  And that worked, but then people who had that done to them couldn't draw the same triangle/rectangle/bird when presented a triangle/rectangle/bird to them.  Instead they had to vocalise.  So the other half of the brain heard the other half who saw the triangle, and then attempted to draw.  A connection obviously had been broken, and the subjects didn't know they had been rewired.  But that's a side story. :)  Robert said OO is 46 years old, as of this year, and there are 3 paradigms, Structured, OO, and Functional.  He defined paradigm as a restriction that takes things away.  For the structured paradigm, Dijkstra in 1968 published a paper "Goto considered harmful", and that you cannot prove that an algorithm is correct using goto.  This was resolved by using other languages.  So structured programming takes the goto concept.  In 1957, LISP stated that assignment statements are evil, so functional programming takes away assignment.  He suggested reading the SICP book which can be obtained from mitpress.mit.edu/sicp.  The authors in the book mentioned that assignments and threads interfere with time.  In 1967 OO took away function pointers, according to Robert. :)  He also mentioned that the keyword class came from the theory of types from the mathematician Bertrand Russell.  And how Algol led to the Simula language.  Robert also provided examples where C has better encapuslation (since keywords like public, private, etc were not needed in C and in C variables were invisible), has inheritance and can do polymorphism.  So what is OO?  It would be interesting if Robert was interviewing someone for a developer position I think, very interesting.

I had some salad after that.

3pm Attended "Introduction to Rx" by Paul Betts.  He mentioned Core of LINQ is sequence and Monads are what you want to do with data before you actually getting it.  And events aren't composable.  He suggested to watch a video by Eric Meyer proving that IObservable is a list.  And IObservable represents a steam of objects, a future result.  Apparent Rx (Reactive Extensions) solves the problem of race conditions too.  Prior till today I've only watched a video on Rx, and that was more useful than this session.  I feel the talk wasn't much of an introduction.  Was more of a quick dive and a splash.  I didn't really get the talk.  Perhaps I just need to study this on my own. amzn.to/programming-rx provides some videos.

I took a kinder surprise from one of the exhibitors after that.  And some oranges. :D

4:20pm "A better way to learn Refactoring" by Philip Laureano.  I'm indifferent about this session.  It was about refactoring the "FizzBuzz" program.  Look it up on google if you want to know what it's about, it's a simple program.  Basically it involved using Resharper to flatten out every if statement and moving methods into classes, i.e. method extraction.  And anything you don't understand?  You wrap it in a region and then refactor what's outside of the region first.  He did add you shouldn't do this without providing tests first.  Which we know isn't happening in the real world.  I probably should've spent the hour in a different session.  It ended early and I went to another session "Dealing with Dynamically Typed Legacy Code" which by Michael Feathers but that kinda ended early too so I didn't learn anything.

Had some dinner after that, noodles with prawns.  Bland but space filling. :D  And another kinder surprise.  And some oranges too.

5:40pm Last session of the day was "Deep Design Lessons" by Michael Feathers.  He talked about the "tell don't ask" pattern.  Never pass control flags to methods.  Rampant problems in error handling using Exceptions.  And Postel's law, the robustness principle which states "be conservative in what you send and liberal in what you accept".  He related that to a pipe, where the ends are fatter than the parts joining the ends.  Profound!  Also talked about the law of demeter where exposing internals is bad. e.g. account.calculator.table.cell(12,12).adjust(4) is bad because you're going deeper into the object whereas array.sort.unique.map is okay as each method call represents aspects of the same object.  Again the session ended early so I attended 15 minutes of "Debugging the Web with Fiddler" by Ido Flatow and that was quite useful.


Michael Feathers.

There was a party at 7pm (?) but I didn't stay for that.  Another long day tomorrow!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.