Wednesday, February 27, 2008

No More Advices

I thought having an open mind is the most important thing a professional needs in this business. But the essence is avoiding questions and answers and caring about nothing at all. Even when you are asked for an opinion, you just avoid it. Don't hurt anyone with what your conversation, even if you have a point. You don't have to prove yourself to anyone other that you. And thats the secret behind every major developer's career. Why impose when you could suggest and then let the other person decide ?

Friday, February 22, 2008

MVC for HTML ?

Today I Stumbled Upon a great piece of lecture given by Jason Seifer from the Rails Envy group about Unobtrusive Javascript. The piece of video was a great insight on how to write apps which are purely MVC. Now the question is how does this have MVC ?

The terminologies according to Wikipedia
  • Modal - The domain-specific representation of the information on which the application operates
  • View - Renders the model into a form suitable for interaction, typically a user interface element.
  • Controller - Processes and responds to events, typically user actions, and may invoke changes on the model.
Writing HTML is a piece of cake. Its not a problem for most of the developers ( they even refrain from it accusing it to be trivial). But writing HTML which is flexible is the tough part. There are 3 parts to a web page as Jason points out.
  • Content
  • Presentation
  • Behavior
The Content is the HTML stuff (stuff you write ) which is orderly (may be a tree fashion ie parent/child). The Presentation is the styling stuff acting on those HTML stuff. The Behavior where HTML tags (parts) are assigned stuff to do on certain actions. For a page to be consistent, these components must be as separable as possible (as it is with MVC).

The comparison with Model/View/Controller is kind of wayward here. I would have it called Media/View/Controller for the better. The Media being the Cascading Style Sheets which hold the Presentation, the View being the HTML which acts as the Content and the Controller being the Javascripts which acts as the Behavior.

People have widely adopted the CSS style of coding ie. having the presentation separated and put into files that could be included in the HTML file. This accounts for better structure and traceability. If I were to change the font, I know the centralized and only place to change it. I won't want to change all the 'style' attributes of the tags in my HTML files. Of course the developer would have to understand how bad IE sucks when he tries to implement all those CSS hacks (necessary hacks) to make the page look the same in IE. But after the ACID test results (which Firefox WILL pass !!), I suppose developers will have a better time in the future.

Now I have not seen the same effort go into creating the Javascript files. Developers still write native Javascript using the attributes (events) and they end up in replicating code and making the HTML page obtrusive and ugly. Having all the code base in simple 'js' files allows the programmer re usability of code which results in what Jason states as 'Unobtrusive Javascript'. I personally have been using the excellent Prototype Javascript library for all my projects (including Workstreamr) and the results have been great.

A typical situation when the Javascript becomes obtrusive is when you add javascripts to events like click. Say we are content with the code being 'obtrusive'. With Firefox (the best browser in the world) it works fine. No memory leaks, nothing. But with IE this has the famous memory leak problem. If we were to have a site which has say one page and all the content being loaded in an Ajaxy way, then we will have problems with this. This code wont Garbage Collect unless you navigate away from the page (or refresh). Why use this primitive technique when prototype provides elegant event handling functionalities ?

What I would rather do is attach an id with the element ( say a span/div) and then use the event attaching functionality provided by Prototype. This may be implemented in a main js file accordingly (as per your requirements) and the call may happen from inside the page called (say an AJAX call ?). Using the OOP structure of Javascript is also a great add on. As a developer I felt so happy when I tried to use those concepts in my Javacript files. So the main Javascript file may have a Class which defines your application and routines inside the Object created will have the methods used in the application ( like a status update on the side of the app ?).

References :
Rails Envy
MVC
Ruby On Rails

This is the movie. I hope Jason won't mind this knowledge sharing !!








Monday, February 18, 2008

Birthday Bumps

This birthday, which is today, to me is kind of depressing and enjoyable at the same time.

Enjoyable for obvious reasons. I learned today that I know a lot of people who actually know me. The flat mates had a nice time smacking my bottom yesterday night at 12. I even got a call from my great friend Sajith from Chennai. Mom and Dad called early in the morning followed by Sis. Shilpi sent me an greeting in SMS. When I reached the office I got the same 'Happy Birthday' from all my colleagues. The bouquet came shortly after. Its Chetan's birthday today as well and we exchanged wishes. My Orkut was filled with wishes and I personally felt obliged to reply to each one of them personally. I always thought I was kind of a loner but hey even I am being watched or observed rather !

Its depressing when I think about my age. 25. Now thats not old my any means. But its one of those ages when we brood over those sweet twenties ( 20 -24). Feeling young is not right any more. More weight/mass. Grumpier feeling. Stressed out after 5 minutes of play. Thats what happens. And I tend to give in to the fact that I am losing it ..

I am still in my twenties though. Not for long as time flies by.

Thursday, February 14, 2008

A Busy Week

The past week (or rather 2 weeks ) was tedious. Work was at its best not letting any time for the poor worker. Stowe Boyd was here in Delhi, were he talked about his visions and ideas for his new baby 'Workstreamr'. To say the least I was taken aback by his eloquence. He was stern with what he wanted but was open to new ideas as well. His short (or rather long) speeches he gave were absolutely great. Of all the people I have heard speaking, he attracts and keeps his listeners interested.

He talked about the concepts that he wanted, his visions on how the product would look like and the concerns he had. He was one of those people who would sell a dime for a dollar. Persuasive is the word if the above analogy was crap. We had a great time with Ben and Sam when we zig zag -ed through those Noida Highways, without even caring the signal lights. Ben and Sam better get used to those as they are going to be here for some time now!

My role has slightly shifted from a ROR programmer to an HTML programmer (if that could be categorized as programming). Standardizing the actual interface. I have always liked JavaScript but I feel I would have more time off that those other guys now. The problem that I faced, and all those HTML guys would agree to this, is not to make HTML with great style sheets but to make them work with the ever crappy Internet Explorer. I can't figure out why IE has become the most used browser. Its as Dracula says 'You suck more than I do !!'.

Thursday, February 7, 2008

Java to Ruby transition

I was one of those who made a transition from small time Java programming to small time Ruby programming. I have tried to understand the differences between them, in convention, usage and concepts. It was when I 'Stumbled Upon' a mind blowing piece of code that I understood that I don't even know 1% of Ruby. This was the Arc Challenge. It also dealt with a concept called Continuations.

The problem statement was simple. Implement 3 pages - the first one would get an argument from the user, the second one would show a link which says 'Click Me' without the argument passed and the final page would display 'You entered #{argument}". And what I saw was pretty confusing code which made me go and browse the basics of the language.

I managed to get hold of some content which I thought was pretty useful. It dealt with what to expect from Ruby if you are coming from a Java background. Some questions were also raised like Dynamic Languages v/s Static Languages. Some of these are pretty old content but its worth the read.

The links are as follows.

Google Apps team Edition is out ..

Google has come out with another of its 'bundled' suites. This time they have bound Google Docs, Google Calendar, Google talk and a Start Search page for the members of teams - and they have called it Google Apps Team Edition. All the users have to do is to sign up with a domain (like abcd.gef@creekwood.com where creekwood.com becomes your domain) and you will get a mail sent to this address. After clicking the confirmation link you are all set and ready to access these apps. You could invite other members of the same domain and then the collaborative effort kicks off with messaging, document sharing and Calendar scheduling. We even saw the collaborative effort in the case of Google Docs when they introduced the Forms in Spreadsheets. The Google Docs have been revamped and the UI looks great !

Anyway this seems to be a great way of collaboration but still it is under Google. Major organizations may consider this as threat full ( I feel so). Small companies with a distributed workforce may consider this as a blessing in disguise. Anyway Google Rocks yet again. Heres the Video.

Wednesday, February 6, 2008

Micro yahoo ?

The largest offer after the PayPal deal is on paper now. Has 'Bill's Hard Drive' (courtesy NY Post) done the trick here ? Steven Ballmer's letter offers $44.6 billion to Yahoo! for its acquisition. And its widely said that Yahoo! will give in to the deal. Google's Eric Schimdt has openly protested against this deal. He has even called up good friend Jerry Yang to offer help to retaliate the progress from Microsoft. Yahoo! has even said it needed time to think about this deal. The Yahoo! shares have leaped after this announcement.

Now the war between Google and Microsoft is evident. But the point that I look upon is after the merger, if it happens, how will Yahoo! be treated my Microsoft. Will MS actually make the web a better place by encouraging Open Source initiative or will it shadow the web in the same way that it has with the PC ? With the vast array of products that Yahoo! has, it may be well possible that MS will dominate these areas with a dominating notion. Instant messaging, Mail and want not (For all I know Hotmail and Yahoo Mail may become Hot Yahoo! Mail ).

I sent a mail regarding this to a community of mine and the reactions were quite astounding. Some of them reacted to the offer as a good thing. That MS would try to make Yahoo! a better firm and promote Open Source Software and try not to ruin the Internet. They will take the 'consumers' as entities and not dumb terminals. I was skeptical about that comment anyway. One of my friends in Yahoo! said that he was praying for the merger to dissolve.

Here are some related material :-
Yahoo, Google, Microsft Acquisitions Timeline
Yahoo Acquisitions
Microsoft Acquisitions
Yahoo Finance
BBC News on the subject
BBC News ShotGun Marriage

Tuesday, February 5, 2008

Social Graph API

This is a new one from Google. This Open Api tries to gather information from a website and tries to link to other sites. This is a great idea as such because then even if you have your content distributed, a person could actually search and connect those contents. It gives the person more visibility and opens up more details about his personality, likes and dislikes, his friends and other social details. Though there are speculations about the negative effect that this will have on the community, crackers may use this information for malicious activities, I feel that the idea is great. The lesson that the content that must be protected should be protected and must be maitained by the needed takes charge here.

The Api requires that the data be formatted in a way so that the crawler (which only takes data which is visible in the Google search) may understand this and interpret. Say the 'rel' attribute is searched for terms like 'me' and 'friends' to actually connect to those other sites. The point here is that a single site which has all those links nicely tagged will serve as a starting point for all your distributed content and any person could correlate to your activities using that single site.

I tried this with blogger and it seems that the taggings are not done as yet for blogger. I hope this will soon come into picture. TechCrunch has an article about this. References are given below.

Social Graph Api From Google
Social Graph Api Docs From Google