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!

Wednesday, June 6, 2012

NDC 2012 Day 1

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 I arrived just in time for the 9am talk.  The trains were late this morning but thankfully not late enough for me to miss the start.  Today's talk started off with the keynote by Aral Balkan, entitled "A Happy Grain of Sand".  He is an experience designer.  He talked about how toilets were designed in various hotels.  And lifts.  Providing examples of how not to design them.  One of his toilet examples had a flush that was situated on the bench top on the wall.  Bad design.  Also talked about how washing machines were badly designed, all of them to be precise.  Why?  Because they have settings that we don't really use or care to know about.  Ideally, there should just be a hole in the ground, we throw our clothes in it and boom, they should just come out clean.  Another example that he gave was the Arlanda airport (in Stockholm, Sweden) requiring you to do all these crazy steps to buy a ticket, and they even built a phone into the ticketing machine as support (so you know it's pretty damn bad!), whereas in Oslo you just slide your credit card and you're off to the airport.  It's a Superman moment, or rather, it's supposed to make you feel like Superman.  Badly designed things make you feel angry and well, pretty dumb.  I also made contact with an ex colleague of mine, it was nice to see him.


Aral Balkan singing a song before starting his keynote.

10:20am The next session I attended was the "Cut the Rope" talk by Giorgio Sardo, and this was him describing the experience and lessons learnt from porting the game to Metro, which is the upcoming user interface in Windows 8.  The application was originally written in Objective C which is for iOS, and Microsoft's obejctive was to not lose fidelity, so the entire game was converted to javascript, and only to use HTML 5.  He talked about how the ropes in the game were 30K triangles, each rope was 30K triangles and how it was optimised by making the functions inline, initially it was quite slow, the code that is.  He also showed how to use Xperf to profile and visualise performance issues.  The animation in the game was also done using sprites, one large sprite containing all animation images, with the javascript just showing the same image but different parts of the sprite, if that makes sense.  Touch was also another thing he talked about, there's a new API called the Pointer API which has one event called Pointer that can trigger events which are both mouse and touch events.  Giorgio also said how by the end of 2012 all laptops will have touch screens, but we'll see if that's true for Apple laptops.  He also provided animation tips using requestAnimationFrame(), setImmediate() and performance.now().  If you don't understand it don't worry because I don't remember much either. :)  He also talked about the audio tag which is unfortunately not supported in all browsers at the moment.  And how you can use pageVisibility to suspend drawing/audio if the current page is not in focus.  After that he provided a Metro demo where he literally copied and pasted the HTML into a new Metro project and it worked, but that's a horrible solution.  You have to scale your assets depending on the resolution, so a full screen game is well, a better solution for Metro in this case.  Also provided a quick demo in Expression Blend showing javascript real time running of the application, now that's cool.  You can edit the application while it's running javascript real time!  He ended with showing the Windows 8 store.



Giorgio Sardo.

Short break after that, I had some bread with crackers with some Mozzarella cheese and cured ham.  Oh there was the Norwegian caramelised cheese that was given out in the morning too as breakfast, forgot to mention that.

11:40am  Giorgio Sardo presented "Windows 8 Apps with HTML5 and Javascript".  He talked about how there are 3 projections above the Windows Runtime (Win RT), which are C++, C#/XAML and HTML + CSS + Javascript (Chakra).  But basically these 3 projections use the same Win RT.  He provided some code examples, showing how Windows is the namespace of WinRT, e.g. Windows.Storage.Pickers.FileOpenPicker().  Also mentioned the promise pattern e.g. picker.pick.SingleFileAsync().then(...) which I found interesting.  In Visual Studio 2012 you can now debug on the local machine, remote machine and the simulator as well.  Also mentioned the Win JS library which is the Windows library for Javascript.  He also repeated the Blend demo in the earlier session.  There's another thing he mentioned, process isolation, where your application on your local machine is trusted but anything that your application download will be in a web context area, or something along those lines.  He also went further into the Windows 8 store, saying how you can sell your application in the store where Microsoft will take 30% of the cut, and after 25K in sales, this falls to 20%.  Better than the Apple store.  He also mentioned you can use your own commerce engine and keep 100% of sales, and technical certification will be run on your application before you're allowed to sell it in the store.

Lunch was at 12:40pm, I had chicken tikka masala.  The queue was pretty long!  The arena (Oslo Spektrum) is not very big, but there's plenty of food to go around.  Also walked around and took photos after lunch.  Managed to grab a pear too.



Right of the exhibition area, also serves as dining area.  The yellow dropdowns hanging off the ceiling serve as signs to the different conference rooms.


Middle.


Left.


1:40pm "Hacking .Net applications The Black Arts" was the next session, by Jon McCoy.  He didn't really say how to hack applications, rather he demonstrated hacking applications using tools that he has written.  Basically everything .Net can be reverse engineered.  Not even obfuscated programs stand a chance.  He mentioned how meta data is stored in a lot of obfuscated programs even, so even if you mess up the names they can still be retrieved!

3pm The next session was "Metro Design Principles", by Laurent Bugnion.  How the Metro Design Language as bauhaus inspired, it came from Germany in the 1920s and was applied to architecture.  No gradients, just typography, and pretty much striped to the minimum.  Also talked about the 1950s Swiss Typography movement, and how Helvetica was designed by the Swiss.  Metro was developed in Zune, and made popular in the Windows Phone.  Also mentioned that you have to consider different screens when designing for Metro, ie. full screen views, snapped views and field views.  There's also other things he talked about like the 5 design principles, which are, pride in craftsmanship, fast and fluid, authentically digital, do more with less, and win as one.

After the session was over , I had some salad and corn at a different stall yes I ate more food.  There's plenty of food and plenty of things to try!  Also grabbed an orange and apple.

4:20pm "How we do language design at Microsoft VB and C#" was the next session.  This was presented by  This session was interesting but there was a lot of information.  He was saying how Visual Studio was huge and takes all night to build, for VB there's 20,000 QA tests of which 1000 are run automatically upon check in.  And how if there are language bugs, and if you tell management then they'll be allowed to fix it.  He also mentioned how UserVoice was used to provide feedback to the team and how people were complaining about the greyness of Visual Studio 2012 so they added colour back into the application.  And never to use var when giving a talk haha.  But he also said var was introduced as a good thing.  The Roslyn project is also something that he talked about, which is basically rewriting C# in C# and VB in VB.  And how it's not good to freeze a language as people want advancement like LINQ which was a research project in Microsoft Cambridge.  The Task keyword also started out at Microsoft Research.  Also mentioned a new feature called Async.  And how C# still has bugs. :)  Oh and x+= 1 is slower than x = x + 1, but I have to prove that.  He said shorter syntax does not necessarily mean faster code.  One very interesting thing he mentioned, was how all the data structures in Roslyn are immutable which means less bugs.  Cool.  And one of the last things he talked about was the /warnaserror swich is a big problem as it now means every warning is a breaking change for developers who use it.  This is still unresolved.



Lucian Wischik.


User feedback obtained from Visual Studio 2012, I think. 


My last meal was some Asian noodles which were quite bland.  But I took an orange after that.  Also somehow manage to stab my finger with some splinters off the chopsticks.

5:40pm  Last presentation of the day was by Robert C Martin who talked about the "Single Responsibility Principle".  Responsibility should be a person, and any module should be responsible to any 1 person.  To be more specific any module should be responsible to any 1 role.  Keep things that should change together, together, and things that should not change together, together.  Software should be isolated so that if 1 person asks for a change, the change doesn't affect somewhere else.  He provided an example of how an Employee class with the methods CalculatePay, Save, DescribeEmployee and FindById violates this principle because 3 roles are in play here, an accountant or clerk, a Database Admin (Save, FindByID) and a third role, HR maybe?  Well designed objects can resist change, whereas a system that is rigid you'll have to change in many places.  Fragile software is when making a change in one place causes it to break in another place because of coupling.  Oh and duplicate code?  Not necessarily bad.  E.g. if a function X and Y which are the same implementation are called by managers and clerks, then they are doing something different, it's just coincidence that the code's the same.  So it's okay to leave it in.  Lastly, always refactor!


Robert C Martin.


One of his slides presented on TDD, Robert mentioned how TDD (test driven development) feels slower but this slide shows development is faster as a result of TDD.

The talk ended at 6:40pm.  Each talk is an hour.  Tomorrow is another talk filled day.  Plenty of learning.

Tuesday, June 5, 2012

Norway nationwide strike, NDC prelude

Norway's been on strike since May 24th, and still going on.  Personally I've not been affected, not yet anyway, but the reason is, not surprisingly, unions demanding a pay increase of 4 percent and in addition to 10 paid days of fully paid sick leave.  It's public sector workers of course, private sector ones have no time for such recreational activities.  Police, teachers, health care and customs workers are the ones comprising this group.  Currently affected areas include Asker, Askøy, Bergen, Bodø, Drammen, Kristiansand, Larvik, Lillehammer, Narvik, Oslo, Sandnes, Tromsø, Trondheim and Ålesund.  A whole bunch of areas pretty much.  And Gardemoen airport.  Anyway we'll see what eventually unfolds.  Apparently some bosses of big state companies have obtained 18 percent or higher pay raises, according to the Norwegian VG newspaper, adding more fuel to the fire.  And garbage is being piled up in some places around Oslo.  That's quite bad.

Norway is apparently the 2nd happiest country in the world according the Organisation for Economic Co-operation and Development’s (OECD) report.  Yet people are going on strike?  People here don't work much to begin with.  Personally I feel it would be extremely hard for a Norwegian accustomed to the way of life here living and working anywhere else in the world.  Especially if they are a cleaner, garbage man, or a manual labourer, or someone uneducated, it would be very, very tough for them to make it in the world.  In fact dare I say smart, enterprising people want to leave Norway?  After working with some of the people on my floor, it's hard for me to think they want to achieve anything substantial in their lives.  But maybe that's just how people here are.

Tomorrow I'm attending NDC 2012, in downtown Oslo.  It's a developers' conference, with some good speakers.  I'm hoping it'll be good.  So the next 3 days will be spent in the dangerous east side of Oslo.  If I see any garbage piles I'll take some photos and put them up. :D