CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jay Kimble -- The Dev Theologian

Philosophizing about the .Net religion

ASP.Net

  • Should We Be Abstracting SQL Connections into Objects???

    [I know I have your attention.  So before you start reading this thinking it's an anti-ORM post or something of that nature.  It's not.  It's about something entirely different (look at the tags).  I am actually attacking a fairly popular notion that I have run into a bit recently and while I may see the point I think the argument misses some critical things... that said... on with the post...]

    I have been in Java hell over the last several days.  To be specific I have been in Apache Cayenne ORM caching hell.  I have been dealing with an update issue with my Mac project.  Everything worked great on my windows machine (but not on the Mac). 

    This project is one that I removed some really bad data access code (my earliest code on this project didn's have Connection Pooling... Java doesn't have that by default), and replaced it with the Cayenne ORM.  I started by converting only portions of the code that needed a better model (don't fault me it's really OLD code... I didn't know any better at the time).  Anyway, as time went on I have moved more and more code to the Cayenne model because of model inconsistencies that have created bugs. The solution to my problem was to eject the Cayenne update and replace it with a stored proc call. 

    <analogy>
    As I was doing this I began to re-think my ORM choice. I thought about how maybe this was a bad idea.  In fact the whole idea of layering a relational database into a set of Objects seems like an abstraction... and as I have read, all abstractions are leaky to some extent, maybe we should be doing this.

    Maybe we should go back to raw data calls.  I mean if everything was in straight SQL calls without any object there would be less code to test and therefore easier to test as well as less buggy.  I mean we wouldn't be abstracting the database.  New programmers would not be uneducated in how the database works.  They would quickly become experienced with the actual protocols.

    In fact I think we should all open up TCP sockets to the DB.  It should be faster and that way we are not abstracting anything.
    </analogy>

    So what am I talking about?  Well, I read an article on our sister site (Devlicious) that was trying to explain Ayende's complaints about ASP.NET the leaky abstraction.  This post troubled me (BTW, Sorry to do to you, Jeff what always gets done to me... if we ever meet I'll buy you a drink?); BTW, Jeff is not the only place I've read an article like this.  I went back and searched Ayende's posts (I like this one), because Jeff's seems to imply that Ayende wasn't clear and that no one got it.

    After reading Ayende's post I totally understood (and while I am not at the place to reject ASP.NET... I totally agree with his complaints... I know that's a shocker.  To be honest I avoid any kind of dynamic form in my ASP.NET code for the reasons Ayende lists).

    What troubled me was that Jeff complains that ASP.NET was made to look like Desktop programming.  Someone in the comments says that it was meant to draw in the VB coder. 

    Back in the day when I was an ASP developer and I saw the ASP.NET beta, I quickly realized that it was going to make my life a little easier, but that it was totally different then anything I had ever done.  Why?  Because of the statelessness of the web, and how ASP.NET was an attempt to relieve us from these difficulties. 

    I think the reason that it seems like Desktop development is that MS was trying to create a model that looked similar between the 2 environments.  If we could ask ScottGu I'd bet we would find that they were trying mitigate the number of things the developer had to know (because they were unleashing this massive framework on us all).

    I could be wrong.  But the big deal with ASP.NET is that it hides the stateless nature of the web.

    This actually draws me onto a different thought.  Before I say it I need to lay out a few of my own credentials.

    --------------------

    I have been a professional developer for 14 years now (coming up on my 15th year early next year).  Of those 14 years all but 3 have been in a web arena, so I'm an 11 year web veteran.  I predominantly feed my family writing Intranet apps.  I generally don't write shopping carts.  I write reporting apps, I write data collection apps... I have written a number of very cool web apps (that in my opinion were not really worth the effort or money poured into them... I certain app I did back in 2001 that made live calls to TransUnion's credit services comes to mind; this same app also made calls to a phone company; the app never made it into production as far as I know -- thank God!)

    That said, I think that HTML over HTTP is a lousy platform.  Statelessness sucks!  It's the one thing I would change about the web environment.  If you don't know the history about HTML/HTTP you would do well to go back and read some on it.  You'll find that originally all this was a Document library (not a platform for programming).  The web server handed documents out (and at the heart of things, that's what it still is). [BTW, I finally get why so many want to use MVC or MVP... it definitely better mimics what is REALLY going on].

    This is what something like SilverLight (or any of the competitors : Flash, Adobe Air, Java FX, etc.). I now have a plugin that I can write Rich Internet Apps and avoid some of the stateless mess... Before someone points this out... yes, this isn't new either.  We have had this stuff for awhile, but these frameworks are starting to mature (Ok, you could also say that since MS created one we are all looking at them now).

  • A Night Of Ajax In Ohio (Akron-Cleveland Area) In October

    Dave Balzer (of DevAuthority fame) and I have been talking about my trips to Ohio once a month, and how I have been itching to speak (and would really love to speak in the State of my birth). 

    We need to plan far in advance so that Dave can get a place lined up.  He (not me) probably should put some kind of sign up form so we know how many to expect. 

    Do we have anything together?  Well, actually I do know what I'm going to do my talk on.  I'm going to do a somewhat informal talk which involve my into to MS Ajax, Best Practices with MS Ajax (will also apply to other Ajax libs, BTW), and my alternative to JavaScript (aka my Script#/SilverLight talk).  All in all I figure that I can talk for about 2 hours on the subjects (possibly longer with your questions).

    This will all happen mid-month in Ohio.  (to steal a variation on Jeremy's line about the ALT.NET conference). If you line in Ohio and think Ajax sux and especially MS Ajax... or if it's not TDD enough for you, come on in and give me crap.  I tick you off sometime in the past, come meet me, and find out what a jerk I REALLY am <grin />.

    Seriously, we'll be digging in to MS Ajax and you should come away with some good tools (knowledge) for assessing Ajax patterns in your development.

    BTW, stay tuned to my blog and Dave's...

  • Day of Ajax on June 20, 2007... Free MS Training in Tampa!

    As you may or may not be aware, I spoke at the Orlando CodeCamp a couple months ago.  After which I went to the "meet and greet" where Joe Healy and I talked about a bunch of stuff.  Most notably was this idea I had about doing an Ajax conference.  The end result was Day of Ajax on June 20th at the MS Offices in Tampa.

    Joe Healy, Jim Zimmerman, and I will all be presenting. 

    Joe will do an intro to MS Ajax and will follow up later with a talk on Orcas' JavaScript integration.

    Jim will do his talk on writing MS Ajax components (extenders, behaviors, controls, etc.)

    I'm down for "best practices" which is a title I hate, but there's not a better title (I think that Ajax desciplines in some respects are too new to have "best practices" attached to them).  As an I'm also going to slip in a couple mini demos/talks to show off some less demoed features in MS Ajax.

    You can sign up here.

  • I can't wait until Orcas' Javascript Intellisense "arrives"

    Ok, so I have been building some stuff with Orcas' JavaScript editor (in beta 1) and I'm sorry to say I'm going back to Aptana Javascript IDE for now.

    I have read much of the info on it and from working with it it is nearly there, but either the way I'm writing my code doesn't get translated proeprly (Aptana isn't perfect either, but it gets closer).

    I have intellisense in my JS files which is nice, but when I do something like this:

    myClass = function()
    {
       // Constructor code
    }

    myClass.prototype = {
      method1 : function() {
         // No intellisense here
      }
    }

    Maybe, I shouldn't constuct classes like this, but Aptana recognizes this syntax and has no problems with it... I haven't tried to write any code in my web pages yet after using this syntax (I believe it's fine)...

    BTW, before Scott Gu or anyone else jumps in to comment.  I know that Orcas' editor will get there.  It's just not there for me.

    Another issue I have with it is if I try to type this:

    x = 0;

    What shows up is:

    XMLDOM = 0;

    if I type:

    var x = 0;

    then it works... but I'm not 100% thrilled that I can't use "x" as a variable.  I know I should probably report this in a beta forum, but I hate newsgroups (I'm sorry). 

    Beyond all this I really like it, but the above is annoying enough that I gotta use something else.

  • CodeCamp Tampa 2007: Ajax Challenge help us create the challenge...

    So I've had this cool idea, and I wanted to use it for my upcoming Day of Ajax, but we decided that there was already a full schedule, so we are postponing it until CodeCamp Tampa 2007.  BTW, the we = "Jim Zimmerman and I" (but we would be happy to include others).

    Anyway, here's the basic concept : Jim and I will form a team of developers to try to accomplish some task with Ajax.  It may be 2 competing teams or it may be 1 team, but regardless the task has to be a challenge, but not so much of a challenge that it can't be done in a few hours.  My thought is that at the end of the day we will unveil our creation(s).

    If we form 2 teams then we need to somehow vary the rules for each team.  Here's an idea that Jim came up with: one team must use free tools and the other (only) uses commercial tools. 

    If we go with the competing team challenge, Jim and I will both want to use SubSonic for DAL (if there's a DB involved). BTW, V2 just shipped... 

    Maybe Jim and I can try to whip up some controls (and it could be a control challenge)...   Honestly, I just want something fun.  Jim and I are really good with this Ajax stuff (in fact his book just got published), and I want to be able to put together a practical how we did it, etc.

  • MSAjax ClientScript - unpublished validation function

    [I just did a quick search on the net to see if anyone has published anything on this (and no one has), so here we go.]

    One of the problems with Javascript that is commonly complained about is type safety; I know having dynamic types is also a feature, but what happens when you want to make sure that something is of a certain type. Well, you can always try to convert the types to the necessary type or at least check the value of the type... using the getType method (available on the every object using the MS Ajax Javascript) also can help.

    But wouldn't it be nice if there was simply a way to check the types in a very convenient way to validate the type (and throw an exception if something is off). Believe it or not (I'm sure you do) the MS Ajax Extensions have an unpublished method for doing this: Function._validateParams. if takes 2 arguments : arguments array, and an object describing the parameters you want to validate. Here's a simple example to get us started:

    function myFunction(aName, somethingElse) {
        var e = Function._validateParams(arguments, [
             {name: "aName", type: String}, 
             {name: "somethingElse", mayBeNull: true} ]); 
        if (e) throw e;
    }


    So let's dig into that second parameter... it's a JSON string. If you don't know what that looks like then now you know... I really don't want to get into a huge primer on JSON, but here's a couple siimple rules so you can read that... anything between "[" and "]" denotes an array; anything between "{" and "}" is an object with properties identified by "name:value" (there's more to it, but you can now read the JSON above...

    The second parameter is an array of objects.. one object for each parameter. So let's tear apart the individual expected parameter object within the array. All of the parameter objects have a name field (this is so the validation script can identify the element by name from the arguments array). In the example above we have an additional field. The "aName" param has a type of String (BTW, this can be any type such as Function, Number, Sys.Component, etc.), so this parameter's type will be checked by the validation routine to ensure that only strings are passed in. The "somethingElse" field has a mayBeNull field (boolean) which indicates that null values are allowed in this field.

    Here's the complete list of additional fields:

    type - (Type) indicates the allowed type for this parameter (Some examples are Array, Function, String, Sys.Component, etc.)
    mayBeNull -(boolean) indicates that a param may have null passed in

    integer - (boolean) indicates that a param whose accepted type is number is also specifically tested to make sure it is an integer
    domElement
    - (boolean) indicates that the object param is a domElement
    optional - (boolean) indicates that the parameter is optional
    elementType - (Type) - indicates the accepted type of all elements of an Array passed in (type must be Array in this case)
    elementInteger
    - (boolean) indicates that all array elements are also specifically tested to make sure it is an integer
    elementDomElement
    - (boolean) indicates that all array elements are a domElement
    elementMayBeNull -(boolean) indicates that an array element may have null passed in.

    Something that should be mentioned is that one of the things that happens is that the routine will make sure that the number of parameters passed to the function are within the correct range (parameters can be marked as being optional, so it checks to make sure that the number of parameters passed in is within the max and min number of parameters expected); beware if this fact; if you want to validate you need to validate all the parameters.

    BTW, the routine returns an exception object to you if there was a problem with the parameters passed in. If you want to handle the exception in your function you can or you can simply throw it back to the caller.

    Just so you can see how complex you can make things... let's look at one final more complicated example:

    function myFunction(aNumber, somethingElse) {
        var e = Function._validateParams(arguments, [
            {name: "aNumber", type: Array, elementType: Number, elementInteger: true, elementMayBeNull: false}, 
            {name: "somethingElse", type: Object, domElement:true, optional: true, mayBeNull: true} ]); 
        if (e) throw e; }

    This last example was to show you that you can throw all kinds of options into the JSON. We still have 2 parameters that will be passed in aNumber and somethingElse. aNumber is an array of integers (Numbers), and all elements must have a value (BTW, the elementMustBeNull is really not required in this case; generally you would only use it if you wanted to allow nulls). somethingElse is domElement, but it doesn't have to be passed in or it can be null.

    kick it on DotNetKicks.com

  • A Day of Ajax... coming soon to Tampa...

    [I'm starting the buzz as early as I can...]

    I am in the process of putting together a free fullday training in Tampa called "A Day of Ajax" with Joe Healy (my Blog Daddy), Jim Zimmerman, and Jon Goodyear (and ASPSOFT). The presenter list has not been finalized yet (please, Joe, please get that special guest...)

    I can tell you that I am planning a killer best practices session.

    Anyway, we are planning for mid-to-late June, so watch this blog for further info.

    Technorati Tags: ,

  • Orcas JS Dreams

    I don't know what the proper place is to put this, but after playing with Orcas' Javascript editor I would like to suggest a few things. BTW, I am finding myself regularly using Aptana for JavaScript editing and can't wait to get back to a single unified editor, so I really want Orcas to succeed; BTW, IMNHO Orcas still has to get around #1 on this list to match Aptana. Since I now know #1 is there I may be uninstalling Aptana soon! (thanks guys).

    1) I need Intellisense in SCRIPT files (read .JS files) to be able to somehow give me access to objects that are in other script files. Aptana gives me the concept of a profile where I drag various script files into the profile area which adds their contents to the Intellisense (for any file I'm editing JS in). I've actually thought that maybe the solution is to have some syntax that is a comment that notifies both Orcas and a programmer using this script to be aware of what files are necessary for this script to work... something like:
    // Using "../MSAjax.js"

    2) Refactoring! Yes, I'm serious! The main refactoring that I want is to be able to highlight code and to extract a method... rename and make property is just icing on the cake for me, but extract method would be awesome! (Aptana doesn't have this one)

    3) Built-in JS library testing. Ok, I know this is a stretch, but it's worth asking for.

    4) While I'm at it, get Nikhil K. to turn over Script# and add it to Orcas! It rocks and would really help adoption to MS Ajax (since oen only really needs to know C# to use Script# and therefore create JS code)

    Technorati Tags: ,

  • Announcing the DTAjax Extensions to the MS ASP.NET 2.0 Ajax Extensions v1.0

    [oops I forgot the link I think] 

    So I tried to submit some of my controls to the AjaxControlToolbox, but was turned down... Basically when I asked if they wanted my horizontal splitter, I was asked if it complied with some composite control someone had requested (since it didn't and I didn't feel like making it work that way, I said no which ended the conversation).

    Anyway, enough about the AjaxControlToolbox, this is an announcement for my little AJax Project... so without further adieu...

    Announcing the DTAjax Extensions to the MSA2AEv1 (that would be "MS ASP.NET 2.0 Ajax Extensions v1.0")
    First of all you can get it here.  Here's what I did. I have a couple script components, a couple extensions, and a control that I wanted to release to the world. I have been building this stuff as I have been preparing to do the various trainings/presentations that I do these days (yes, you heard that right... you, too, can hire me to come give an MS Ajax training at your company.

    Script Components

    • Sys.Attribute - provides .NET style attributes to Javascript
    • Sys.Hashtable - provides a HashTable-like structure to Javascript
    • Sys.TimerUtil - provides some utilities for manipulating Server Side timer controls from Script
    • Sys.UpdatePanelHelper - provides a mechanism to register to receive events in an UpdatePanel's lifecycle

    Server Components

    • InPlaceEditExtender - utilizes the InPlaceEditBehavior sample by Nikhil Kothari from last year (I re-wrote the extender and ported the behavior to the v1 MS Ajax)
    • HoverEffectsExtender - simple Extender/Behavior for applying simple CSS hovereffects (this is mainly a sample)
    • HSplitterPanel - My many times mentioned horizontal splitter control has now seen the light of day

    Stuff to do

    • Create docs (!!)
    • Create Samples
    • Create Tests (I want good quality from this thing and tests help to be able to make sure everything is running OK... I know I'm not TDD yet, but who knows...)

    Oh yeah, the Server Components currently reference the AjaxControlToolbox (I need to doublecheck to see if it's necessary).

    BTW, I plan on making my improved ScriptManager to appear in this project and I'm open to letting others join and add their own stuff too... The idea is that this is not the big AjaxControlToolbox, but I would like it to become second to it, and would like to at least supplement it.

    Technorati Tags: , ,

  • CodeCamp Orlando slides/VS Project

    I spoke at CodeCamp Orlando on Troubleshooting Client Script apps with MS Ajax.  I wanted to publish my slides and project, so attached to this post is a zip file containing both.  The project is mainly Javascript and the aspx file.  I have actually built my own source browser so if you hit the web site from the root, you'll be able to run the sample apps (that are in VS), browse the source code, and also get the pptx file.

    There's also an Aptana directory containing the files I used for Aptana (these are the same files used with Orcas).

    BTW, people have had problems downloading stuff from this blog if they were using IE7 (I'm not sure of the exact version of Community Server we run around here or if it was just a couple people, but if you are having problems... use something other than IE7)

    Technorati Tags: , ,  

  • Orcas and Javascript: I stand corrected...

    Ok, so I complained first and asked questions later... I'm eating crow right now. Why? Because Scott Guthrie is the Man! Scott basically predicted my problem (which is a known issue)... and now I have intellisense goodness. I didn't mean to seem to be a naysayer... I just know that these CTPs are not always bullet proof.

    BTW, if you are coming to the Orlando CodeCamp this Saturday, I will be showing Orcas' Script intellisense! I think that is big enough that I won't need to give something away. Also, don't miss Dave's sessions... well, you can miss the session that competes with mine <grin />.

    Technorati Tags: , ,

  • Orcas Disappointment

    [Minor update here... I was having an issue with the Javascript editor in the Orcas CTP (March 2007).  Scott Guthrie referred me to the solution in the comments... so I had to post a retraction here. This is a typical post of mine where I tried hard, then blogged, and then found that there is a solution (if I had only searched for it)] 

    I spent the last couple days (in my spare time) trying to build an Orcas image that would fit onto an external drive I have, so I could demonstrate the new JavaScript editing at CodeCamp this weekend in Orlando (to go along with my Aptana Demo).

    Man, am I disappointed.  I know it's a CTP, but the intellisense seems to be only basic JavaScript, so it's not parsing the script libraries I have included (although I am getting an error that implies that it was trying to  parse my files).

    I'm going to make a few more attempts before giving up (it is a CTP after all...)

    BTW, Remember CTP stands for Constantly Changing unTil Production, so if you're mad about LINQ to Entities... hang on things will change (and it might not make it into the beta)... BTW, whatever happened to ObjectSpaces?

    Technorati Tags:  

  • Setup Aptana for building Ajax components with MS Ajax Extensions

    First of all (in case you don't know about it), Aptana is a great Javascript IDE for building client script libraries. It comes stock with a number of popular Javascript libraries (like Dojo, Prototype, Scriptaculous, YUI, etc.), so you can easily create a start working with the library of your choice to build script applications/libraries with full intellisense(!!)

    One of the libraries that doesn't come out of the box is the MS Ajax Extensions (I know you are probably sick of me talking about them). Anyway, the docs are pretty good for telling you how to add your own libraries, but getting the "planets aligned" for intellisense is not always simple.

    Basically, you have to create a directory that contains a template site (complete with subdirectories, etc). You put these libraries in the "...\Aptana\plugins\com.aptana.ide.documentation_XXXXXXX\libraries" (where "...\Aptana" is the directory where your Apatana.EXE is and where XXXXXXX is a version number (I have two versions because I upgraded to the "next version"). So in this directory (mine is "C:\Program Files\Aptana\plugins\com.aptana.ide.documentation_0.2.8.13698\libraries) you need to create an "Ms Ajax Extensions v1.0" directory. In this directory, I created a "_script" subdirectory which contains all the MS Ajax Extensions JavaScript (debug) files.

    The final step is to put an HTML file in the "Ms Ajax Extensions v1.0." This file needs to reference the scripts. Here's what my file looks like.

    <html><head>
    <script type="text/javascript" src="_script/MicrosoftAjax.js"></script>
    <!--script type="text/javascript" src="_script/MicrosoftAjaxTimer.js"></script-->
    <!--script type="text/javascript" src="_script/MicrosoftAjaxWebForms.js"></script-->
    </head>
    <body>
    </body><script type="text/javascript">
    function pageLoad()
    {

    // wire up your behavior here
    }
    </script>
    <script type="text/javascript">

    // Create your behavior/control here (when you are done you'll want to
    // move this script's text to a separate file
    Type.registerNamespace(
    "My.Namespace")
    My.Namespace.MyBehavior = function(element)
    {
    My.Namespace.MyBehavior.initializeBase(this, [element]);

    // Static fields

    // var staticVar = 1;
    // Instanced fields

    // this.instancedVar = 1;
    // Event Handler objects

    // this._myEventHandler = null;
    }
    My.Namespace.MyBehavior.prototype = {
    // private functions

    // initializer (activator)
    initialize : function()
    {
    // this must be the first line
    My.Namespace.MyBehavior.callBaseMethod(this, "initialize");
    // initial component activation
    // - create "delegate" event handlers
    // ---- Example
    // this._myEventHandler = Function.createDelegate(this, this._someEventHandlerFunction);
    // ----
    // - create needed associated controls
    // - create needed components

    // - attach event handlers
    // ---- Example
    // this._someDomElement.attachEvent('onSomeEvent', this._myEventHandler);
    // ----
    },
    dispose : function()
    {
    // clean up the component as it is being destroyed
    // - remove event handlers that were added
    // ---- Example
    // if (this._myEventHandler) {

    // this._someDomElement.detachEvent('onSomeEvent', this._myEventHandler);
    // this._myEventHandler = null;
    // }
    // ----
    // - dispose associated components

    // this must be the final line
    My.Namespace.MyBehavior.callBaseMethod(this, "dispose");
    }
    //,

    // event handler functions
    // properties
    // get_MyProperty : function()
    // {
    // return this._someValue;
    // }
    // set_MyProperty : function(value)
    // {
    // this._someValue = value;
    // this.raisePropertyChanged("MyProperty");
    // }//,

    }

    // Optional descriptor for JSON serialization.
    /*
    My.Namespace.MyBehavior.descriptor = {
    properties: [
    {name: 'MyProperty', type: String},
    {name: 'MyProperty2', type: Number}
    ]
    }
    */

    My.Namespace.MyBehavior.registerClass(
    "My.Namespace.MyBehavior", Sys.UI.Behavior);
    // Control registration
    //My.Namespace.MyBehavior.registerClass("My.Namespace.MyBehavior", Sys.UI.Control);
    // // notify ScriptManager that we're done loading (if in file)
    //if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
    </script></html>

    That's it!

    Technorati Tags: , ,  

    kick it on DotNetKicks.com

  • MS Ajax - Server Timer's Script interface

    Lately, I've been hacking my way around the script enhancements in MS Ajax. I have a couple contracts that have had me doing this. I just had to make a call to dynamically raise a tick event from script for a MS Ajax Timer (server control). As a result I had to hack on the Timer control a little and thought I would pass on to the world (and for my reference) the interface. Most of the methods are marked don't use and all are pretty much private (but javascript has no concept for private, so you can actually call anything in the object's interface.

    Sys.UI._Timer
    properties
    - enabled - Boolean - controls the flag indicating whether the timer is enabled or not (you probably shouldn't be setting this; use the _update instead)
    - interval - Numeric - controls the amount of time in milliseconds between timer ticks - default is 60000 or 1 minute (you probably shouldn't be setting this; use the _update instead)
    - uniqueID - String - Timer Component's Unique ID (you shouldn't need to set this)

    methods

    - dispose() - disposes/destroys the component (you probably shouldn't be calling this)
    - _doPostback() - causes the postback (again, you probably shouldn't be calling this)
    - _handleEndRequest(sender, arg) - internal event (don't use)
    - initialize() - creates internal structures/activates the timer (you won't need to call this if you are using the server timer)
    - _raiseTick() - raises a server tick event (this is private -- because the name starts with an underscore-- but you can probably call this... I am)
    - _startTimer() - starts the timer (this is also private, but it appears to be safe to call)
    - _stopTimer() - stops the timer (private, but it appears to be safe to call)
    - _update(enabled,interval) - safely updates the enabled and interval properties; if you set properties then you will need to call _stopTimer and _startTimer (private, but it appears to be safe to call)

    kick it on DotNetKicks.com

    Technorati Tags: , , ,

  • JavaScript API's and Debugging

    As stated a few posts back, I spent some time looking at other Ajax frameworks. I really have become fascinated with the JavaScipt APIs. I know it's cool to not have to do JavaScript (JS, hereafter), but enabling a good JS API within a framework like ASP.NET or in Java's JSP/Servlet Architecture is really not that hard.

    As I said, I'm fascinated with the libraries (I'm not always thrilled with where things are going)... As I have repeatedly stated I'm not so sure what I think of the Ajax/Web 2.0's improved GUI features (I think it's asking for trouble).

    That said, one of the biggest pain points for me with JS is that traditionally you did 1 of 2 things while debugging.

    1) Put alert calls all through your code to notify you of the values of your clientscript values
    2) Create a Div and push data to the Div.

    The latter being a bit of a pain to set up because you can't just use it. The latter choice is actually the better choice when throwing an alert up screws up your code.

    With the emergence of tools like Mozilla's FireBug, this is getting easier, but it's still sometimes a pain.

    Anyway, as I was digging around in the MS Ajax ClientScript API, I discovered the very cool Sys.Debug class. This basically lets me write trace information as well as dump for objects to JSON-like strings (using Sys.Debug.traceDump)) so I can see the values. These messages will show up in Visual Studio if you are debugging with IE; In Mozilla and Safari, this information gets written directly to the Debug console. They also let you create a textarea named "TraceConsole" which will display on the screen these messages (so it's not limited to debugging in only Mozilla and Safari).

    Sys.Debug also has includes assertion statements which is nice.

    Anyway, since I was discovering this nice facility I started to wonder if other JS frameworks have anything like this (the trace functionality... not the assert functionality).

    I won't single out any particular framework (OK, I will single out 1), but will give you the list of JS Frameworks that I found that have some kind of debugging facilities.

    The good
    • Ms Ajax (but you knew that)
    • Yahoo's YUI library has a complete logging facility and while I didn't find an equivalent of traceDump (but I'm sure it has a function for convert object to JSON string), the logging facility is much more sophisticated then what is in MS Ajax.
    • dojo has functionality almost identical to that found in MS Ajax (I know people will accuse MS from stealing from the dojo guys now. dojo goes a little further then traceDump... dojo has 2 levels of object dumping: shallow and deep.
    • MochiKit has logging facility like YUI's.

    Honorable Mentions
    • Cross-Browser.com's X Library has some facilities that are more dynamic in nature in that they let you modify the running document as well as drop in debug console's within your code.
    • The Script.aculo.us addon to Prototype.js contains some unit testing classes.
    Final Thoughts

    The one most notably missing to me is Prototype.js. I feel that I have to point this out as it seems crazy to me that Prototype of all libraries should have some sort of support for this (at least for writing to the debug console). I'm in shock that it doesn't.

    As far as other frameworks, if I missed yours I'm sorry. If yours doesn't have any kind of debugging facility be happy I didn't point it out and add debugging support... I've come to the conclusion that I won't be using a JS library that doesn't have it (it makes life way to convenient when you are trying to debug something).

    [this post brought to you by the nice folks at www.blogdesk.org... I needed a new editor and this just might be in (well, if this posts ok)]

    Technorati Tags: , , , , , , , ,

More Posts Next page »

Our Sponsors

Free Tech Publications

This Blog

Syndication

News

CodeBetter.Com Home
Current Threat level
Terror Alert Level