Programming Style–Kendo & jQuery

  • Which of the following do you prefer? shutterstock_76533307
  • Which is easier to read?
  • Which is easier to write?
  • Which is easier to maintain?


 var dataItem =".k-grid").data("kendoGrid").dataSource.getByUid("tr").data("uid"));


var dataItem =


 var grid =".k-grid").data("kendoGrid");
 var dataSrc = grid.dataSource;
 var dataItem = dataSrc.getByUid("tr").data("uid"));

I’m not convinced the answers are obvious.

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen Pluralsight & LinkedIn Learning courses. He was a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in JavaScript, Kendo, Languages, Opinion, Programming and tagged . Bookmark the permalink.

4 Responses to Programming Style–Kendo & jQuery

  1. Vinny Brown says:

    I’m not a Kendo user, but along the lines of what Mark Rendle suggested, It looks like we need to do something like:

    var target =;
    return $(target).getDataItem();
    }else{ return null; }

    where the specifics of how to do that would be encapsulated in getDataItem() and have a lot more null-reference checking than we have in the sample 🙂

  2. Mark Rendle says:

    They’re all pretty bad.

    I’d be looking to wrap it all in a jQuery extension/plug-in so I could just call:


  3. Leo says:

    To me, 2 is the easier to read. To read 3 you have to keep in memory the lines to fully understand what is happening.
    And since we are talking about javascript, the less code, the better (I know this would eventually be minified but we still save some bytes with 1 or 2).

Comments are closed.