Quame's Rampant Rants (QRR)

Icon

QRR

ASP.NET MVC Reaction to Actions

 

If you are familiar with ASP.NET MVC, you are probably familiar with the State Validation mechanism that was shipped starting from v1. Its a great way to validate your model and funnel your validation result to the user if need be. What I find lucky or I should probably say what I thought was lucking was the fact that it only dealt with error. There is nothing wrong with there and it probably the sole intention but I wanted something general. For every event the user executes (action), they expect a reaction. The most common reaction is page reload with content in relation to the user action. With that in mind, I created an Html helper  provide a generic reaction to the user, based on their action. It could be errors, it could be a warning or a successful message. These are thing developers do very often. Below is the code for my Html helper. Please not this is was a quick hack to get it working. I will post my updated to the helper when I make the final changes.

So here is how it works. All my views are strongly typed and accepts a ViewModel type. My ViewModels inherits from a base ViewModel class which provide the implementation for adding ActionMessage’s to the view. As seen below, my ContactViewModel inherits from the ViewModel abstract base class.

 

public enum ActionMessaeType
{
    Success = 1,
    Failure = 2,
    Warning = 3,
    Alert = 4
}

public class ActionMessage
{

    public ActionMessaeType MessageType
    {
        get;
        set;
    }

    public string Message
    {
        get;
        set;
    }

    public string ForAction
    {
        get;
        set;
    }

    public ActionMessage(ActionMessaeType messagetype,
                   string message)
    {
        MessageType = messagetype;
        Message = message;
        ForAction = string.Empty;
    }

    public ActionMessage(ActionMessaeType messagetype, 
                string message, string foraction)
    {
        MessageType = messagetype;
        Message = message;
        ForAction = foraction;
    }
}

public abstract class ViewModel
{
    private List<ActionMessage> _internalactionmessages
                            = new List<ActionMessage>();
    public List<ActionMessage> ActionMessages
    {
        get { return _internalactionmessages; }
    }
    public ViewModel(){}
    public ViewModel Add(ActionMessage actionmessage)
    {
        _internalactionmessages.Add(actionmessage);
        return this;
    }
    public ViewModel Remove(ActionMessage actionmessage)
    {
        _internalactionmessages.Remove(actionmessage);
        return this;
    }
    public ViewModel Clear()
    {
        _internalactionmessages.Clear();
        return this;
    }
}

public class ContactViewModel : ViewModel
{
    public Contact Contact
    {
        get;
        set;
    }
}

 

 

My Contact View take accepts a ContactViewModel. Here is my page tag in my Contact.aspx

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.
Master" Inherits="System.Web.Mvc.ViewPage<YourNameSpace.
Models.ViewModel.ContactViewModel>" %>

Below is the post Contact Action method in my Controller

Code Snippet
  1. [HttpPost] //Post
  2.         public ActionResult Contact([Bind(Exclude = "Id")]Contact contact)
  3.         {
  4.             //if maodel is not valid, send validated contact
  5.             if (!ModelState.IsValid)
  6.             {
  7.                 return View(new ContactViewModel { Contact = new Contact() }
  8.                        .Add(new ActionMessage(ActionMessaeType.Failure, “Please correct the errors in the highlighted below and try again”, “create-contact-failure”)) as ContactViewModel);
  9.             }
  10.  
  11.             //save contact here……
  12.             
  13.             //Clear ModelState or redirect
  14.             ModelState.Clear();
  15.  
  16.             //display view with action message
  17.             return View(new ContactViewModel { Contact = new Contact() }
  18.                         .Add(new ActionMessage(ActionMessaeType.Success, “Thank you for your message. We will get back to you as soon as possible if a response is need.”, “create-contact-success”)) as ContactViewModel);
  19.         }

 

You will notice from the code above that based on the certain events during the action execution, I add an ActionMessage to the ViewModel before its passed on to the view. The ActionMessage take a messagetype (failure, success, alert,…), a message to be displayed and a “foraction” parameter which depicts where the message should show in the view. 

When the  view is rendering, the html helper is called to display the action messages. The helper can take a “foraction” parameter which is used to determine which ActionMessages to show. If no “foraction” is passed, all messages are displayed. Here is the code for the Helper method

Code Snippet
  1. public static class ActionMessageExtension
  2.     {
  3.         public static readonly string ActionMessageCssClassName = “action-message”;
  4.  
  5.         public static string getActionMessageCssClassName(ActionMessaeType messagetype)
  6.         {
  7.             switch (messagetype)
  8.             {
  9.                 case ActionMessaeType.Success: return “action-message-success”;
  10.                 case ActionMessaeType.Alert: return “action-message-alert”;
  11.                 case ActionMessaeType.Failure: return “action-message-failure”;
  12.                 default: return “action-success-warning”;
  13.             }
  14.         }
  15.  
  16.         public static string ActionMessage(this HtmlHelper htmlHelper)
  17.         {
  18.             return ActionMessage(htmlHelper, string.Empty /* message */);
  19.         }
  20.  
  21.         public static string ActionMessage(this HtmlHelper htmlHelper, List<ActionMessage> messages)
  22.         {
  23.             return ActionMessage(htmlHelper, messages, string.Empty /* htmlAttributes */);
  24.         }
  25.  
  26.         public static string ActionMessage(this HtmlHelper htmlHelper, string foraction)
  27.         {
  28.             return ActionMessage(htmlHelper, null /*messages*/, foraction, (object)null /* htmlAttributes */);
  29.         }
  30.  
  31.         public static string ActionMessage(this HtmlHelper htmlHelper, List<ActionMessage> messages,string foraction)
  32.         {
  33.             return ActionMessage(htmlHelper, messages,foraction, (object)null /* htmlAttributes */);
  34.         }
  35.  
  36.         public static string ActionMessage(this HtmlHelper htmlHelper, List<ActionMessage> messages, string foraction, object htmlAttributes)
  37.         {
  38.             return ActionMessage(htmlHelper, messages, foraction, new RouteValueDictionary(htmlAttributes));
  39.         }
  40.         public static string ActionMessage(this HtmlHelper htmlHelper, List<ActionMessage> messages, string foraction, IDictionary<string, object> htmlAttributes)
  41.         {
  42.             //if no messages are passed in, the viewdata model is checked for messages to display
  43.             if (messages == null)
  44.                 messages = (htmlHelper.ViewData.Model as ViewModel).ActionMessages;
  45.             else //merge parameter with view actionmessages
  46.                 messages.AddRange((htmlHelper.ViewData.Model as ViewModel).ActionMessages);
  47.  
  48.             if (messages == null) return null;
  49.             if (!(messages.Count > 0)) return null;
  50.  
  51.             if (foraction != null)
  52.                messages = messages.FindAll(delegate(ActionMessage actmgs) {return actmgs.ForAction == foraction; });
  53.  
  54.             if (messages == null || !(messages.Count > 0)) return null;
  55.  
  56.             StringBuilder result = new StringBuilder();
  57.  
  58.             //Render Success Messages
  59.             RenderActionMessage(messages, ActionMessaeType.Success, foraction, htmlAttributes,ref result);
  60.             //Render Alert Messages
  61.             RenderActionMessage(messages, ActionMessaeType.Failure, foraction, htmlAttributes, ref result);
  62.             //Render Alert Messages
  63.             RenderActionMessage(messages, ActionMessaeType.Alert, foraction, htmlAttributes, ref result);
  64.             //Render Warning Messages
  65.             RenderActionMessage(messages, ActionMessaeType.Warning, foraction, htmlAttributes, ref result);
  66.  
  67.             //Render …..more types of messages
  68.  
  69.             return result.ToString();
  70.         }
  71.  
  72.         private static void RenderActionMessage(List<ActionMessage> messages, ActionMessaeType messagetype, string foraction, IDictionary<string, object> htmlAttributes,ref StringBuilder htmlresults)
  73.         {
  74.             StringBuilder htmlSummary = new StringBuilder();
  75.             
  76.             //Render  Messages
  77.             List<ActionMessage> typemessages = messages.FindAll(delegate(ActionMessage actmgs) { return (actmgs.MessageType == messagetype && actmgs.ForAction == foraction); });
  78.             if (typemessages.Count > 0)
  79.             {
  80.                  
  81.                 TagBuilder messageList = new TagBuilder(“ul”);
  82.                 messageList.MergeAttributes(htmlAttributes);
  83.                 messageList.MergeAttribute(“class”, getActionMessageCssClassName(messagetype));
  84.  
  85.                 foreach (ActionMessage message in typemessages)
  86.                 {
  87.                     if (!String.IsNullOrEmpty(message.Message))
  88.                     {
  89.                         TagBuilder listItem = new TagBuilder(“li”);
  90.                         listItem.SetInnerText(message.Message);
  91.                         listItem.MergeAttribute(“class”, ActionMessageExtension.ActionMessageCssClassName);
  92.                         htmlSummary.AppendLine(listItem.ToString(TagRenderMode.Normal));
  93.                     }
  94.  
  95.                 }
  96.                 messageList.InnerHtml = htmlSummary.ToString();
  97.                 htmlresults.Append(messageList.ToString(TagRenderMode.Normal));
  98.             }
  99.         }
  100.  
  101.  
  102.     }

 

And here is how its used in the Contact.aspx view.

<%=Html.ActionMessage("create-contact-failure") %>

 

I hope this help. I’m having a hard time finding a good code plug in for Live Writer as I am not so pleased with how the code is presented above. When I do find a good one, I will update the code section of the post.

Future

Like i said, this was just a hack. The best way will be to have the Message Collection as a property of the ViewData since it cannot be used in its current state without using a strongly typed view who’s Model inherits from the base ViewModel class. That’s using Injection of some sort to update the ViewData used in the Views. I also want to pipe all the validation errors for the ModelState through the ActionMessage helper so I can use that as an all purpose notification mechanism.

If you have any suggestions, please let me know.

Filed under: .NET

Timestamp issue with MySql connector 6.0 – 6.1 for Entity Framework

This is really a short post as to highlight an issue that I run into (and most will) when using MySql with Entity Framework employing the mysql connector net.

 

Scenario

I work mostly on my laptop which has mysql connector 6.0.4 installed. Using the connector in conjunction with EF v1 generated my domain object with timestamp fields mapping from a binary in my conceptual schema to timestamp in my physical schema.  Everything worked just fine till I deployed to my production machine and realized I didn’t have mysql connector installed on my production server. So…I did what most will do, download the connect but installed the latest version (v6.1). After deploying my app to the server, the unexpected happened. My app was broken. The error message indicated that Edm.binary was not compatible to mysql.timestamp. OK, I was stumped. The app works just fine my my laptop why not on my server.

 

Solution

After a couple of hours using process of elimination, I realized that using version 6.1 of the connector sets your mapping for timestamp from Edm.DateTimeOffset(conceptual schema) to timestamp (physical schema)which worked fine but version 6.0.4 of the connector sets your mapping for timestamp from Edm.binary(conceptual schema) to timestamp (physical schema) which also works as well. DateTimeOffset is a type specific to Sql server so the best option for me was to stay with 6.0.1  (using binary) which is generic and can be used with other db’s if ever need.

Filed under: ASP.NET MVC

Adventures to my dream part 1

I have been hosting most of my personal application from my home pc for a while until charter blocked port 80 and others. This prevented me from doing exactly that. Disappointed in Charter, I switched to  AT&T U-verse for a better service. That worked great for a couple of week and then …..boom, my ports got jammed again. I called U-verse support to help resolve this but they claim they aren’t blocking any ports. Between you and I, I think they are even though DynamicDNS says the ports are open. Long story short, I decided it was time to shell out some cash for a dedicated windows 2008 server, so I did. I’m actually very happy with my server. I configured every aspect of it to the last bit but this blog is not really about how happy i am about my dedicated server but about my experience setting up my applications in IIS 7.

IIS 7 by far is the best IIS release ever. Built ground up from scratch to support mainly the modular architecture requested by so many web administrators. I have been very impressed and at the same time, frustrated. Why frustrated? Well it has its learning curve and without the IIS 7 documentation, I wont be any closer to understanding how IIS 7 works. So I have decided to make a blog post of any knowledge I can pass on to others in relation to configuring IIS

Today’s “Did you know”:  IIS 7 allows you to run multiple sites on the same port each with a different host name. IIS using Host Names to differentiate between different sites and forwards the request to the site. Now, you can host all your sites on port 80 if you wont to so far as their host name are different. Example, say you have 2 sites. www.site1.com and www.site2.com. You can create two sites in IIS with host names “site1.com” and “site2.com” and both binding to port 80. A request to www.site1.com and www.site2.com respectively will be routed to site1.com and site2.com respectively. your request to be served by that sit

Today’s War wound: Setting up ftp in IIS 7 with the new ftp service is very easy and also support the same port binding mechanism explained above. Using the example above, say you extend both site with ftp publishing feature. You will think setting the host names for the ftp binds (same port 21)  should give you the same ability to ftp into www.site1.com and www.site2.com through ftp.site1.com and ftp.site2.com using the host name feature and the same port 21. Well, you can do that but you are in for a treat if you plan on connecting from any ftp client to those ftp site. It just fails. For some reason, the clients don’t quit know who to use host name in their request. The solution is not to use host names for ftp but rather different ports and leaving the host name to unassigned. Then connect to the different ftp sites using the servers ip and the different ports.

I hope this helps anyone in their quest to tame IIS 7.

Filed under: .NET

Spell checking your content

I have been very busy with work since I came back from Ghana so I have had  limited time to blog. But then again, that’s no excuse since I could post a line or two here and there with a hint of wisdom but …. So here I am back at it again. This time, it’s about spelling.  Here is the interesting part, the web is all about content. Anytime you open a browser to a site, you are slapped with many types of contents in different sizes. These include videos, sounds, pictures and lastly and most prominent of them all, text. In our daily work, we are either typing or reading. Both of which deals with text but ask me how many standalone spell checker tools one can employ and you will be amazed at how many there are. Very few I must say. I am still struck by the fact that visual studio does not ship with a spell checker out-of-the-box after 6 versions. Every thing from Windows form design to Web development involves publishing text content of some sort and yet, there isn’t a solid spell checker that comes with it. Instead, we have to resort to MS word , some other text editing tool (Openoffice etc) or plug-in etc. Frankly, every time I run into an interface design software that doesn’t have a spellchecker, I get dumbfounded. Is spell checking really the least most important feature or what. Then again, someone would say, what’s the big deal. If it bothers you so much, why not learn how to spell. Very true; I wont dispute the fact that we do need to know how to spell. After all, its one of the basic medium of communication since the invention of papyrus. But with the volume of content this generation produces daily, most people are bound to make spelling mistakes so why not help avoid it.  Matt Cutts (Head of Google web spam team) points out here as to how important spelling is on the web and how they can turn customers away. People don’t trust website with spelling mistakes. To that end, I know my ranting is not going to change the feature set of content publishing software’s like visual studio etc, so here are a couple of things you can do to keep your customers coming back.

1. Spell check your content in any good text editing tool like MS Office Word

2. Let a colleague or friend prove read your content for you. You can easily miss your mistakes even if you ready it more than you think you should. It came from you and you are bound to miss one or two.

3. If you can find a spellchecker plug-in to your content authoring software, plug it in and use the heck out of it.

4. For web developers, you can find online services that can scrawl your site for spelling mistakes. Beware of the service you choose; as Matt Cutts post suggests that you probably don’t want to use a service who’s own site has spelling mistakes.

I’m actually checking this post for wrong spelling using Windows live writer. Kudos to the windows live team for including a spell checker. With that said,  let me know what you think if you disagree with anything I have said or want to add to it.

Filed under: .NET

The site doesn’t work, I have javaScript & cookies turned on in my browser.

Problem

it’s hard resolving issues at a customer’s end because you don’t know what the state of their machine is in. You can do your best by gathering information from the client as to the behavior of the problem and go hunting for the solution after politely saying, “I will look into it”.

After all, the customer is always right.  JavaScript and Cookies are used by  lots of web applications and yet, it amazing how many browser currently in existence don’t have those features turned on. I understand the security risk of JavaScript but … So in such a situation, what do you do. Customers will always tell you they did exactly what you told them to do but it’s hard to know if they “actually” followed your steps to rectify the problem.

 

Solution

Relying on the Customer is great but proof is even better. Showing user browser configuration settings in your web application can be very helpful in addressing some of these issues. See example of such a configuration display below.

image 

image

image

This is all great but unfortunately, extracting this information for the browser can be tedious since they are no consistent amongst all browsers. Below is a JavaScript snippet which provides you with the above browser settings for IE, Firefox, Opera and Safari.

 

<script type="text/javascript"> 

function showBrowserConfigurationResult() {

    $get("browser_type_check").innerHTML = getBrowserType();

    $get("browser_version_check").innerHTML = checkBrowserVersion();

    $get("js_check").innerHTML      = "Yes";

    $get("cookie_check").innerHTML  = getCookieStatus();

    $get("platform_check").innerHTML = getPlatformStatus();

     $get("screenresolution_check").innerHTML = getScreenResolutionStatus();

}

function getBrowserType() {

     if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
       return "Internet Explorer";
     }
     else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
        return "Firefox";
      }
      else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
        return "Opera";
      }
      else if(/Safari/.test(navigator.userAgent)){
      return "Safari";
      }
      else
      {
        return navigator.appCodeName;
      }

}

function checkBrowserVersion() {

    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
     var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number

         if (ieversion>=8)
          return "8.x";
         else if (ieversion>=7)
         return "7.x";
         else if (ieversion>=6)
         return "6.x";
         else if (ieversion>=5)
          return "5.x";
         else
            return "n/a";

      }
     else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
       var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number

     if (ffversion>=3)
      return "3.x or above";
     else if (ffversion>=2)
      return "2.x";
     else if (ffversion>=1)
      return "1.x"
     else
       return "n/a";

    }
    else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
     var oprversion=new Number(RegExp.$1) // capture x.x portion and store as a number
     if (oprversion>=10)
      return "10.x or above";
     else if (oprversion>=9)
     return  "9.x";
     else if (oprversion>=8)
      return "8.x";
     else if (oprversion>=7)
      return "7.x";
     else
      return "n/a";
    }
    else if(/Safari/.test(navigator.userAgent)){
      var safversion = /Version\/\d\.\d\.\d*/.exec(navigator.userAgent)
      safversion = /\d/.exec(safversion)
     if (safversion>=3)
      return "3.x or above";
     else if (safversion>=2)
     return  "2.x";
     else if (safversion>=1)
      return "1.x";
     else
      return "n/a";

    }
    else
    {
      return  navigator.appVersion;
    }
}

function getCookieStatus() {

   if(navigator.cookieEnabled)
      return "Yes";
   else
     return "No" ;

}

function getPlatformStatus()
{
   return navigator.platform;
}

function getScreenResolutionStatus()
{
  return screen.width+" x "+screen.height;
}

 </script>

 

$get(“ x”) is a jquery function that returns the element with id=”x”. If you are not using jquery, you can replace $get() with the JavaScript function  getElementbyId(“x”)  and that should rectify the problem. Enjoy.

Filed under: Javascript, Scripting

Windows 7 beta Review

I have been running win 7 build 7.0 beta for the past month and I think I’m ready to offer my opinion about this widely praised OS.

 

Pre Installing 

As at the time I was thinking of trying win 7, I was in need of a laptop because our old laptop was giving up on me. It was too slow and I couldn’t do pretty much anything with it. So I decide to retire our old laptop and migrate it into either the Fedora or Ubuntun world. Haven’t decided yet. With that decision made, I set out to buy a new laptop. I kept going between windows pc or Mac pc. Why? , well, I’m not an apple fun boy but I was interested in developing for the IPhone which meant having a Mac. But I could bring myself to justify the amount I would pay for a Mac in relation to how much time I will actually spend using it (which will only be during development for the Mac environment). Then there was the thought of running windows on the Mac using VMware fusion. I had heard some good stories about fusion.

After a couple of discussions with a few friends, I made the discussion to go for a 64bit windows laptop. I discarded the taught of buy a Mac and running windows virtually because, I mainly live in windows. Emulation seems to take away the optimum performance of any OS and I do push my laptops really hard. I could have gone for a dual booth on a Mac but by then, I had already fallen in love with Sony’s Vaio FW. It was perfect in every way. So in the end, I ended up with a 64bit Sony Vaio FW . See the specs below.

 

image

 

 

Installation Experience

Installation was smooth as a baby’s ass. Wow, that different from what I have experienced so far. In any case, I think MS did a good job with installation improvements. My installation path was an upgrade from vista home to win 7 ultimate so I hope others with different upgrade or new installation path will go as smooth as mine. I can only hope since this is a beta.

 

UAC configuration

This is a lot easier since you can now choose your own configuration and not be bothered by unnecessary pop up’s. One up for the MS guys.

Device Discovery

This is by far my favorite since it looks like a lot of work has been done here. I was able to discover my Xbox, router, cellphone (through Bluetooth), wireless printer and more in just a few seconds. Win 7 really made it easy for me and I hope the  final version will even be better.

image 

 image

Software Installation

I didn’t have any issues except for IE 7 and Microsoft Expression suite. IE 8 64bit works just fine and works really really fast. IE 7 will start but doesn’t allow any interaction with it. I don’t know if its because I did an upgrade from Vista home to window 7 Ultimate. The expression suite also installed with no issue but will error out when running blend or designer. Personally, I don’t care for designer since I do all my vector work in illustrator and export to xaml when I need to. I just needed Blend for the composition of my application. I will have to resort to my desktop for now till I have a solution around this.

 

UI Features

I was really hoping for some ground breaking but ….its better than it was before. The peek feature is my favorite were you can peek a window and go back to the one you were working on without switching between windows. The grouping of apps at the bottom also makes sense and works very well for me. A bit of style would make these features look great but style is what Microsoft lacks, not like Apple. With that said, the UI is functional and lets you do your work and that’s all one can really ask for.

 

Overall, I will switch to win 7 in a heart beat as its proven to be a lot better than my vista desktop. I think MS got it right this time and if they keep this up, they will have customers like me on their side. That doesn’t mean I giving up on Mac. I like the work of the Mac boys. The look to design first for inspiration. They look to groundbreaking but unfortunately, they are not business worthy at the moment. Not because you cannot run a business with a Mac, but finding all the different software you need to run a business can be more challenging in Mac world than in the windows world. Plus their pride in the “no-virus” selling point  scares the hell out of me because no OS is bullet proof and I have more confidence in the support and speed of the MS security team (since they have been dealing with this shit for a long time) than the 2-5 man security team at Apple.

Note: I really don’t the size of the security team hiding at the Cupertino-based company’s basement. I was mealy making a point.

 

Wish List

  1. Spellchecker feature built into the OS or as an add-on so all content applications can make use of it instead of rolling out their own
  2. Map feature should be build into or be an add-on to the OS for allow mapping needs to be met by any application that needs it
  3. Location based feature build into the OS
  4. An OS that knows its environment, that can adjust the light, sound(noise cancellation etc) properties depending on the surrounding.

These are the things I consider moving forward. Up until now, I still cannot believe that laptops and pc don’t come with prebuilt radio receives in them but they are present in the tiny mp3 players we buy.

What do you say dear reader. What are your thoughts.

Filed under: Personal, Platforms

Browser Spring is full of great browsers, only one will be kingpin!

It’s amazing how the web has been ignited again in the name of the best JavaScript engine and browser layout engine. Everywhere I turn, there is talk of Ajax, JavaScript frameworks etc. The web has entered another phase; were application are heavily rendered on the client-side instead of the server-side; hence; the need for better JavaScript and rendering engines. The cloud is everywhere and people want to access it from many different devices. The browser war has even made its way to the mobile platform with contenders like Mobile IE, Safari, Opera etc. All these exciting work comes with the duty to support if not all, the major browsers in our applications.  There are lots of browsers but I will concentrate on the major ones in this post. With that said, Let introduce our contenting fellows.

Meet Mater (alias Internet Explore)

popc3

Take your time to absorb his looks. Not handsome but has been around the block for a long time. Internet Explore 1.0 debuted in 1995 to facilitate the growing hunger of the mass to access the world wide web. The use-to-be-great Netscape battled it out with IE till around 1999. IE won hands down not because of Microsoft strategy to include IE in its OS, but because IE stayed on the edge and was the only browser at that time to support a large part of of W3C Dom and CSS standards. After its success over Netscape, Internet Explorer basically stood still from 1999 to 2003 with not much activities except for the usual patches and updates here and there. It was the kingpin of Browser Spring till 2003 when Apple rebelled with Safari. By then most users were sick and tired of the old IE, for nothing had happened to it in a period of 3 years.

Meet   Lightning McQueen ( Firefox )

popc1

Catchewwww, yep, that’s the sound of spend and beauty. It’s lightning mcqueen zipping through browser spring. First released on November 9th 2004, Firefox was the resurrection/rebirth of Netscape but engineered without all the mistakes made by its predecessor. It packed the goody’s on W3C Dom and CSS  standards. Better yet, it was free; not like its father, Netscape. The Netscape/Mozilla team had learnt their lesson and had created a monster, formidable to stand toe to toe with IE. Firefox 2.0 push the game much further, introducing great features such as tab browsing which has now become the standard to most browsers and the extension manager, which by far; has become the most used feature set of Firefox. Firefox boost of both rendering speed (using Gecko) as well as JavaScript execution speed. It made it’s mark, and is hear to stay.

Meet Sally (Google Chrome)

popc2

Fed up with the timeline it takes to release new standards by W3C to support the modern use of browsers, Google decide to spit out Sally with her V8 cafe. V8(Chromes JavaScript engine) and Chrome have been touted as the fastest browser and JavaScript engine as of early 2008 (inception of chrome). Chrome took a different route with JavaScript by building its engine to compile JavaScript to native machine code making it fast. My first impression with Chrome was that of –“here goes another browser for developers to worry about”. Well, I will have to say, I have been very impressed with chrome and look forward to more in the future. After all, Google’s cash making machine primarily comes from search and it’s web apps. Thus, the better the browser,the better their applications’ performance.

Meet  iHudson (Safari)

popc4

Safari was developed by Apple in 2003, to ship with their flagship OS X 10. Apple boasted that Safari was the fasters browser there was but there had actually been no proof. In 2007, a windows version was released, becoming the second Apple product to trend on Microsoft territory after iTunes. Team Safari just announced a couple of months ago, their new JavaScript engine named SquirrelFish; to be the fastest JavaScript engine at present beating Google chrome’s V8. Sally must not be pleased.

Javascript Benchmarks

On same computer, an average of 10 test run on each browser


Browsers

V8 Benchmark Suite-v1 Sunspider  Javascript Benchmark
Internet Explorer 8 beta 70 7890.8ms +/- 1.3%
Safari (Windows) 3.0 71 browse froze everytime
Firefox 3.0 231
3361.6ms +/- 1.5%
Google Chrome 1.0 3200
1250.4ms +/- 8.8%

War in Browser Spring

Its amazing how all these enhancement to the web has suddenly sprung up. Every browser has to stay on the edge just to be competitive. I, for one, I’m no one to complain. Competition breads the best in everything. In the end, the end user benefits. As a developer for the web (sometimes), I’m pleased to see such excitement. IE has itself to blame; for it stayed in dormant state for way to long. Microsoft has the tendency to do that. They lack innovation in some area and I fear the browser is one of them. I could be wrong with IE 8.  MS is slated to release IE 8 sometime next year which is suppose to be more standard compliant  and supports CSS 2.1.

Who do you think will be kingpin? Let me know your thoughts.

Filed under: Ajax, Javascript, Platforms, RIA, Scripting

Reducing Online Ad Noise

 

THE ROUTING

I have my ritual every morning from the minute I get to work. I get my coffee; next; ask my colleague (he’s an early to rise kind of guy) if there are any issues that needs my attention ASAP. If none; I put my desk in order; spend the next 15 minutes checking emails and catching up with my favorite blogs etc; then to work.  I’m content with all this except for the last 15 min within which I have to check my emails.

 

THE DISLIKE

Because I have come to dislike internet Ad’s with a passion; both at yahoo and hotmail. They just take up space which otherwise can be used by the application. I have read a lot of complain in relation to yahoo and hotmail to get ride of the Ad’s and more but I know this won’t happen. Below is an image from hotmail but mind you, this applies to yahoo and other email client providers as well. Google does a better job at this by making the ad’s section very small and very smart by relating the ad’s to the content of your inbox. 
adbefore

 

THE BECAUSE

Ad’s are not going to go away any time soon.It wont because the advertising business is a cash making machine. USATODAY reported online ad revenue over $21Billion in 2007 and the interesting part is that internet ad’s account for less than 10% of all Ad’s. Meaning there are lots of room for improvement and money to be made by online solutions like yahoo (with yahoo mail, search , …) , Google (mail, search, apps etc), Facebook and more. I can understand why Ad’s are important to these companies because, after all, we don’t pay for the service they provide. We search and check our emails for free for the most part. Unless you have a premium account or something of that sort.  That’s how they make their profit.

 

THE SOLUTION

Gladly, I stumbled on a great Firefox extension called stylish and have to admit, its one of the best extensions around. It allows you to customize the look and feel for any site by saving your modifying style in stylish and it does the rest. The best part of stylish is that it has a huge support and contributing community which makes it easier to find styles for many sites. I wasn’t able to find a one for the new hotmail and live sites so I created one and contributed it to the stylish online community repository. Below is a screen shot after applying stylish. You can apply stylish to any site, any web email client. Now, I can enjoy my routing freely. Take stylish for a spine and you wont regret it.

adafter

Filed under: .NET, CSS, Design, Personal, UX

Get it Done, NOW !! {DIFN}

It’s been hard trying to find time to blog. I have so much respect for people like Jeff Atwood, Matt Berseth, Scott Guthrie and Scott Hanselman. These guys have lots of responsibilities at work and at home and they some how manage to find time to blog. So I began to wonder what it takes to blog and blog "successfully.  From what I have come to learn, they are two types of developers. There are those who create “noise” by chatting , blogging, writing articles  etc and then, there are the “quiet” ones, those who are knowledgeable but either has no motivation to blog about it or just to see the need to. Belonging to any of these categories doesn’t make you better than the other. The only difference I have come to realized is  motivation.

Motivation is  what makes people like those I mentioned above, make time to blog amongst the million others things they do in their day to day activity. They feel some sense of responsibility to tell the world about their findings, their thoughts and their lives experiences. Jeff Atwood and his team at stackoverflow have even take the extra step to tap the hidden knowledge inside the “quiet” ones amongst us. I have tried to encourage my team at work to blog (including myself as you can tell I’m not too happy with my blogging habits) but most of them don’t think blogging makes any difference in anyone’s life.

So you must be wondering why I’m so unhappy with my blogging habits or why I’m not a successful blogger like the mentioned above if I have all this motivation. Well, because I’m lacking the DIFN. The “DO IT F**KING NOW” plan. Yes, that’s what I’m missing and that’s what most early bloggers lack. We procrastinate. We are not committed to “doing”. We don’t have a blogging plan for success.

I recently read a post by Joel Spolsky talking about DIFN in the form of  Fire and Motion

Once you get into flow it’s not too hard to keep going. Many of my days go like this: (1) get into work (2) check email, read the web, etc. (3) decide that I might as well have lunch before getting to work (4) get back from lunch (5) check email, read the web, etc. (6) finally decide that I’ve got to get started (7) check email, read the web, etc. (8) decide again that I really have to get started (9) launch the damn editor and (10) write code nonstop until I don’t realize that it’s already 7:30 pm.

Somewhere between step 8 and step 9 there seems to be a bug, because I can’t always make it across that chasm. For me, just getting started is the only hard thing. An object at rest tends to remain at rest.

I remembered this for a long time. I noticed how almost every kind of military strategy, from air force dogfights to large scale naval maneuvers, is based on the idea of Fire and Motion. It took me another fifteen years to realize that the principle of Fire and Motion is how you get things done in life. You have to move forward a little bit, every day. It doesn’t matter if your code is lame and buggy and nobody wants it. If you are moving forward, writing code and fixing bugs constantly, time is on your side. Watch out when your competition fires at you. Do they just want to force you to keep busy reacting to their volleys, so you can’t move forward?

 

Jeff Atwood also has a similar post from a different angle, titled  “How To Achieve Ultimate Blog Success In One Easy Step”. In his post, Jeff asserts that continues jabbing and regularly throwing haymakers is what makes it happen.

 

But success takes time– a lot of time. I’d say a year at minimum. That’s the element that weeds out so many impatient people. I wrote this blog for a year in utter obscurity, but I kept at it because I enjoyed it. I made a commitment to myself, under the banner of personal development, and I planned to meet that goal. My schedule was six posts per week, and I kept jabbing, kept shipping, kept firing. Not every post was that great, but I invested a reasonable effort in each one. Every time I wrote, I got a little better at writing. Every time I wrote, I learned a little more about the topic, how to research topics effectively, where the best sources of information were. Every time I wrote, I was slightly more plugged in to the rich software development community all around me. Every time I wrote, I’d get a morsel of feedback or comments that I kept rolling up into future posts. Every time I wrote, I tried to write something just the tiniest bit better than I did last time.

 

In all these different perspective lies DIFN as their foundation. The power to get your ass off the couch after work and spend an hour to blog about a great piece of code you wrote at work, or about some efficiency process you implemented and so on. Anything worth the world will add to the knowledge we all feed on. If you are one to think blogging is a hustle and worthless, I only have this to say to you. Try ignoring all blogs and articles in your result set for your web searches and let me know how you do. That’s when you will come to understand the importance of blogs (with useful content).

From this moment, I intend to keep jabbing everyday with good content and most of all, uphold DIFN.

I will be glad to hear what you think of DIFN.

Filed under: Personal

Part 1: Reporting for duty after 2 months of AWOL

 

I will like to start by thanking Jeff Ottum and Alan Kneel for their emails in relation to my wedding. Thanks guys. I appreciate it. Its been 2 months since I made my last post and 4 months since I made a post on this blog  so I will try to elaborate on what I have been up to so far. I might have to split this post into two as I might not be able to finish due to time constraint.

Table of Content

  • -What I have been up to
  •   – Go-live at work
  •   – Family Time
  •   – House maintenance
  •   – Programming
  •       - Google Android
  •       – ASP.NET MVC
  •       – F#
  •       – Silverlight

 

What I have been up to

I lot has happen the past few months after my wedding. It’s been crazy here and I haven’t had time to catch my breath. I will not be able to elaborate on every aspect of it so not to bore you out of your mind. After all, you are not here to read my memoir.

Go-live

We just went live with our 2nd major version of our management software at work, streamlining processes from customer enrollment to management to renewal or termination. Since go-live, my team has been very busy supporting issues in relation to management. Our end-to-end management software includes our client and customer portals in which I own. That’s to say I have the largest surface area exposure in relation to issues, hence, very busy. I have learnt a lot through out this project and we already have plans for our next release with some exciting new features. 

Family Time

Jennifer and I have been spending a lot of time together as we didn’t have vacation days to go on a honeymoon. Some of my co-workers are not happy with that and insist I take off from work for my honeymoon. Well, we do have it planned, it’s just not time to execute it. We just had our wedding (took days off for that) and we also took a couple of days off during the years to take care of some other family business. Go-live at work needs support and a lot more. Due to all these reasons, we decided to push it off to next year but make it a point to spend time together after work. That has translated into less time on my computer and …you know the rest.   My mom was also here visiting this past few weeks and that was great. I got to have some good home made meals …mmmmm…. I’m missing it already. We also finally got our wedding pictures. I must say, I’m not big on pictures but I really like these. I will put up a couple later.

House Maintenance

Whoever said owning a house doesn’t come with responsibilities. Huh. I have had to set time aside to get the house ready for the coming winter. We had a leakage in the guest bedroom and that had to be taken care of. We also had other problems that need to be resolved but all in all, I’m feeling more like an owner now and I can’t complain. At least I don’t have to do the lawn and snow blowing.

 

I will like to end this post here as I will need more time for the programming section than I have now. I will have some code samples and others in my next post. 

Filed under: Personal

Del.icio.us