Daily links

I’ve been really busy lately. My mail keeps accumulating and I want to write more about Monorail and ASP.NET. Soon.

General

Tools

  • Saltstorm – Cool JavaScript compression utility. I’m sure there are many similar tools, but this is professionally done and well documented.
  • Ultimate Developer and Power User Tool List – A great list of tools that every developer and most of power users should be at least aware of.

Web development

  • Efficient JavaScript code - Writing efficient JavaScript code can be a complex task. This article will help you to know the cost (in terms of memory, execution time, etc.) of various things in JavaScript. My only concern is that it’s written from Opera's perspective, which is not as widely used as IE or Mozilla and so the applicability of the article diminishes.
  • Data persistence in IE – Overview of how to use IE DHTML Behaviors (proprietary Microsoft extension for IE to ease control creation) to persist user data (such as view or control state).
  • Understanding and Solving Internet Explorer Leak Patterns – A great article from Microsoft on what can cause memory leaks in IE. An interesting read providing good insight into the problems I’m trying to solve with my UI project.
  • Six JavaScript features we do not need any longer – Discussion on six JavaScript features that author think should be avoided in JavaScript development (as well as thrown out in the future versions of JS). Mostly I agree, but I don’t think "href="javascript: …", onclick="javascript:" can be thrown out yet. Not until Microsoft fixes the problem with IE only supporting “:hover” CSS pseudo-class for the anchors (<a></a>). Using JavaScript here can prevent anchors from navigating away from the page ("href=”javascript:void(0)"). Using anchors is inappropriate in many cases (which doesn't stop most developers, including me, from doing it), but it can really simplify life sometimes.
  • W3C DOM vs. innerHTML – Another article on JavaScript performance. In this case, two ways to manipulate the page are compared and apparently, “innerHTML” wins in most of the cases. Still DOM is often more convenient. In most cases, the difference should not be noticeable, but it’s nice to know what to look at if JavaScript seems to take too long to execute. Don’t forget that it’s also possible to use various JavaScript profilers, such as Mozilla Venkman.
  • Object Hierarchy and Inheritance in JavaScript – In-depth JavaScript OO capabilities overview. Most certainly, you will learn something knew or recall something you’ve forgotten about what JavaScript is capable of.
  • Design for future: workarounds vs. hacks – All web developers who has to work with CSS sooner or later discover inconsistencies in how browsers handle CSS as well as run into CSS limitations. This article is a good starting point to understanding hacks and workarounds possible in CSS, how they can help and when they’re appropriate to use.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/30/2005 at 7:20 PM
Categories: Links
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

.NET website frameworks

I’ve finished documentation for my UI project and there are only two or three small tasks remaining before it can be released. They are related to the publishing process. The most important one is a website for the project. I could use sourceforge.net or something similar, but I'm planning to work on commercial projects as well and I would like to have a single place to manage and publish all projects.

Several technologies can be used today to create a website , from simple HTML to PHP, ASP, ASP.Net, JSP, etc. I decided to use .NET, which narrows it down to ASP.Net 1.1, ASP.Net 2.0 (still in beta) and Monorail.

I’ve had some experience working with ASP.Net 1.1 in the past. It is a relatively new generation web development technology and it still has some problems. For example creating master pages (a common template for all pages) is not trivial. Another problem is communication between pages, but I recently found out about Page Methods that make it simple. ASP.Net 2.0 solves some of those problems (master pages mentioned above is one), but several fundamental flaws in the design of the framework that I wasn’t able to work around remain. ASP.Net makes it a complicated task to create simple, cohesive and loosely coupled classes in the web application because it’s so easy to put parts of the business logic into the presentation layer. There’s also a problem due to the fact HTML is a state-less environment. From what I’ve read online, I’m not the only one who is struggling.

Not long ago, I found out about Monorail via this Code Project article. It’s based on Ruby on Rails and it attempts to solve often-encountered problems in web programming. Everything I’ve read about Ruby on Rails had only good things to say about it, but it doesn’t mean that Rails is the silver bullet of web development.

So far Monorail looks interesting, but it’s still in beta (although looks stable). The main advantage of the framework is that it enforces programmer to separate code into Models, Views and Controllers (MVC pattern). It’s still possible to screw up and have bad design, but it’s not going to be as easy as in ASP.NET.

Monorail can use either nVelocity (simple HTML templates engine) or ASP.Net for the views. So in theory it should be possible to reuse ASP.NET controls, but I haven’t tested it yet. Monorail developers recommend using nVelocity to keep the views simple, but I’m not sure it is always suitable. I also have concerns about necessaty to go through all the trouble of using a beta framework (ASP.Net 2.0 is in beta too, so I’m just as reluctant). Maybe the same concepts could be implemented in ASP.Net. I doubt it will be easy though. Also ASP.Net is a more widely supported framework. There are more developers writing it in Microsoft than Monorail, more tools and extensions come out for it, etc. Chances are if I need to do something in ASP.Net there’s a control for it somewhere in existence. In Monorail I might have to reinvent the wheel and write my own extensions.

I’m leaning towards Monorail at this moment. I like that it promotes good design, but there are still some more experiments to do before I can completely justify using it over ASP.Net. Expect more posts on the subject.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/24/2005 at 8:47 AM
Categories: .NET
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

.NET developers association meeting

Yesterday I went to a local .NET developers association meeting. It was on the upcoming VS 2005, .NET 2.0, SQL Server 2005 and Team Server. An interesting event, although too short to cover such wide topics in detail. Most of the time presenter just scratched the surface. Often he just told the viewers that a new feature exists but he doesn’t have enough time to go into it and moved on.

There was a short demo of ASP.NET 2.0. New features are cool, but I still don’t think it’s simple enough. It’s just too easy to screw up and make the project too complex and hard to maintain.

Another demo was on new VS 2005 development tools (I really liked automatic diagrams to see class relationships). New debugger is much better and makes code analyzes much easier. There's also a new edit and continue feature for C# developers. New Visual Studio looks like a much better platform for code writing and provides a lot of functionality that was either absent or offered by third parties as plug-ins for VS 2003.

In the end, though, I haven’t learned a lot. It was fun to see it in action, but I’ve been following where .NET is going to and there were no real surprises. The most informative part of the presentation was at the very end when people started to discuss problems they have encountered when they tried to install and work with the new tools. Basically VS 2005 Beta 2 and .NET 2.0 can be installed side-by-side with the old versions, but SQL 2005 doesn’t like to sit on the same machine as SQL 2000. I’d recommend not installing new and old SQL servers as apparently Enterprise Manager gets really %#@) up. If you still decide to do it, I would strongly encourage you to look up more information online.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/22/2005 at 10:08 AM
Categories: .NET
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Child element reference in IE CSS

I recently found out about this hack to enable ".parent > .child { /* CSS code */ }" (select only direct child, not descendants) support in IE, but unfortunately I’ve lost the link to the original article. Anyway IE doesn’t support ".parent > .child" at all. It simply ignores it. Workaround is simple, but it still involves more work than you would have to do in a more CSS compliant browser (like Mozilla):

.parent .child { /* direct child data */ }
.parent .child .child { /* original CSS modified in .parent .child above */ }

Class references can be replaced with the tag:

UL LI { /* CSS for direct LI children */ }
UL LI LI {/* general CSS for LI elements */ }

This solution is somewhat limited, as you have to know how to restore CSS properties modified for the child nodes, but it’s better than nothing.

On the side note, I updated CS to 1.1 release. Everything appears to be running smoothly, but if you encounter any problem don’t hesitate to contact me. Update went OK (more or less) and the only complaint I have is that it cannot be automated. SQL scripts had to be run manually, even though the portal does support web installation.

Also I'm almost finished with the first version of JSOLait UI library. I'm finalizing documentation and planning to release it shortly.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/20/2005 at 10:56 AM
Categories: Web development
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Formula 1 in U.S.

Apologies for not posting anything on the blog for a couple of days. I went to watch Formula 1 practice and qualification runs on Saturday (06/18/2005). After I got back, I had too many things that required my attention and I couldn’t find time to blog.

The whole thing was a lot of fun. I got to see some of the best racing cars on the planet. It was very exciting to witness professionalism of the drivers when they took the same turns with equal precision from one lap to the next. The only downside was that the cars were too loud. Louder than I was expecting.

Watching practice and qualification runs is fun of course, but not as fun as watching the real race. The drivers didn’t really try to fight with each other and concentrated on getting their cars tuned in for the track and getting the best time during qualifications run.

Unfortunately, this year US Grand Prix race was practically a disaster. Seven out of ten teams refused to race due to the defective tires and only six cars raced. Apparently, Michelin tires that came with the latest shipment can deflate at a certain turn. It’s the fastest turn and I understand that with all the forces acting on the car taking it at the high speed the tires become unsafe. Michelin engineers offered a solution of modifying the track slightly so that the cars would have to slow down more on the turn, but FIA officials refused. As the result, Ferrari owned the track with their cars being the fastest in the race. This was the record lowest number of the cars in the race in the history of Formula 1. I hope that this event will not push away Formula 1 fans in the US and around the world, but I doubt there will be as many people following the race next year as there were this year.

If anybody's interested let me know and I will publish pictures from the event. I might actually publish some later when I find enough time to sort through all of them and pick good ones.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/20/2005 at 10:54 AM
Categories: General
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Daily links

Tools

  • PowerBand - A powerful IE add-in to explore and partially modify current webpage. Very cool and powerful tool. The only complaint I have is that working with CSS is somewhat limited. Computed (a.k.a runtime) CSS for an element can be copied into clipboard, but that’s it. I can’t even view it on the fly.

Design

  • UI Hall of Shame - Love it or hate it but most developers eventually have to get into UI design. I for one have to do it quite often and I realize there’s a lot of space for improvement for me. One of the ways to learn something is by looking at what not to do and this website is all about bad examples of UI design.

Web development

  • Pure CSS buttons and XML button via CSS - Often blogs feature button-like elements to allow readers to subscribe to the blog feed. Most of the time images are used, but there are a few techniques I found that can unleash the power of CSS to replace image with HTML tag. If you own a blog and are not afraid of modifying it’s look you might find the links interesting.
  • Whitespace in the DOM - White spaces are always a tricky subject when it comes to HTML (or XML) programming and understanding how they are processed is important for any serious developer. This article covers how Mozilla treats them and how to overcome some of the limitations imposed as the result. I’ve actually done something similar in my UI project to make code compatible with both IE and Mozilla.
  • W3C CSS2 Specifications - I wish I’ve known of this place earlier. It’s one of the best resources on CSS programming. It’s well written and easy to understand (unlike most of W3C writings). There are a lot of examples and discussion on how various special cases should be handled by the browser. The only problem is that none of the browsers fully support CSS specifications. You find that some things work differently in IE or Mozilla from what you might have expected after reading this manual. Still this book is a good starting point when you try to understand why something is behaving unexpectedly.

Web development examples

  • CSS Desktop - a Windows-like desktop simulation written in JavaScript. Pretty nifty although still needs some work.
  • WebCmd - an example of command prompt written using JavaScript and AJAX. This approach could create powerful tools for remote administration through web interface, but I doubt there are many uses for it other than educational. (via http://www.ajaxian.com/archives/2005/06/ajaxian_command.html)


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/17/2005 at 8:33 AM
Categories: Links
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Simplifying exceptions

I’ve been working with JavaScript lately and it does support exceptions. Many people for various reasons choose not to use them, but I do. If something isn’t right, I might decide to throw an exception. I guess this comes from my .NET background. What’s different in JavaScript from .NET is the absence of preprogrammed exceptions to deal with common problems. For example in .NET there’s ArgumentNullException to be thrown when one of the arguments is unexpectedly null. I created something similar in JavaScript to indicate that not initialized argument is invalid.

The problem comes from the code that verifies if the argument is null or not.

function NoNullArgumentsAllowed( arg1 )
{
    if( arg1 == null )
    {
        throw new ArgumentNullException( "arg1", "arg1 cannot be null." );
    }
    // Do something useful
}

Repeating this code for every argument in every method where argument cannot be null gets boring fast and if something is boring I am reluctant to do it and try to find ways to make it either less boring or (preferably and) simpler. Refactoring to the rescue!

function NoNullArgumentsAllowed( arg1 )
{
    CheckIfNull( arg1, "arg1" );
    // Do something useful
}

function CheckIfNull( arg, argName )
{
    if( arg == null )
    {
        throw new ArgumentNullException( argName, argName+" cannot be null." );
    }
}

Now whenever I need to check whether argument is null I can just call CheckIfNull. And then it occurred to me. The logic of comparing the argument to null is always going to be the same, so why not attach it to the exception? That’s right, let exception decide for itself if it should be thrown.

ArgumentNullException.CheckArgument = function( arg, argName )
{
    if( arg == null )
    {
        throw new ArgumentNullException( argName, argName+" cannot be null." );
    }
}

function NoNullArgumentsAllowed( arg1 )
{
    ArgumentNullException.CheckArgument( arg1, "arg1" );
    // Do something useful
}

Now in most cases the logic of throwing the exception is specific to the place it is thrown from. Often though it can be simplified to single true/false answer. To decide if the exception should be thrown we can pass boolean value to the exception checker along with parameters to initialize the exception. Just like it’s done in TDD with assertTrue.

ArgumentException.CheckArgument = function( condition, argName, message )
{
    if( !condition ) // use condition != true to enforce condition to be of boolean true
   {
        throw new ArgumentException( argName, message );
    }
} function NoInvalidArgumentsAllowed( arg1 )
{
    ArgumentNullException.CheckArgument( arg1, "arg1" );
    ArgumentException.CheckArgument(
arg1 == expectedValue, "arg1", "arg1 doesn't equal expectedValue" );
    // Do something useful
}

This isn’t a big change, but I think following this style of programming will make code cleaner and shorter. With elimination of tedious ifs and throws people should also be more inclined to check that everything is what it is expected to be. In not-interpreted environment (like in .NET) where it’s impossible to modify classes dynamically (well, in .NET 2.0 it’s possible, but I’m not going to go there. It’s not as simple as in JavaScript anyway.) and you don’t have access to the exception class source, requires a different approach. The simplest solution would be to just abstract working with exceptions into a separate class, like so:

internal class Exceptions
{
    internal void ArgumentNullException_CheckArgument( arg, argName ){ .. }
    internal void ArgumentException_CheckArgument(
         condition, argName, message, stackTrace ){ .. }
}

So what’d you think? Can this approach make working with exceptions easier for you? What do (would) you do to simplify exception handling?



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/15/2005 at 8:18 AM
Categories: .NET | Web development
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Tree columns

Today I realized there is another problem with the tree control. Actually three. First - there are too many SPAN and DIV elements where I think using list (UL) would be more appropriate. Another is that it’s impossible to set width of each of the columns since each column cell is an inline element and width property of the inline elements is ignored. There is also a small problem with the tree floating and any text following it in the document showing right next to the tree and overlap with the absolutely positioned columns.

First problem was easy enough to fix. All nodes are now LI elements tugged inside of a UL element. Small modifications to the CSS style sheet and everything works just as before.

Second problem wasn’t as easy to fix. For the column cells to recognize width attribute they must be block, not inline, but block elements stack on top of each other. Unless they’re flowing, as I found out. And with the column being absolutely positioned the cells float only to the border of the column aligning the way I want them to be.

The last problem required some additional elements. The whole tree is now wrapped inside of a DIV and is folowed by another DIV, inside of the first DIV, with "clear: both".

There’s also a small problem in Mozilla. The tree block is expanding horizontally correctly when the tree is expanded to show all visible nodes, but is reluctant (sometimes fails) to collapse back to the minimal width when the tree collapses and nodes that caused the tree block to expand disappear. I managed to find some additional information here and here.

This Mozilla behavior isn’t as bad as what I experienced with IE. When the browser window gets small enough width IE freezes. This was due to using “white-space: pre” for some of the elements. Ironically “white-space: pre” is what fixes width shrinking behavior in Mozilla. In the end, I managed to balance things out. IE doesn’t freeze anymore (although it does behave incorrectly, when the window width becomes minimal) and Mozilla from time to time works correctly and collapses the width.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/14/2005 at 8:47 AM
Categories: Web development
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Explorer tree and flowing DIV column

I've mentioned in the past that I’m working on a tree control that would also support any number of columns. I also talked about using DIV instead of TABLE to layout the tree and the problem of lining up the columns in a straight vertical line. Today I will write about the solution I found.

Here’s a simplified example of the tree with all non-essential code removed:

<div id="treeElement" class="tree"> <div id="node1" class="expanded"> <span class="body">Node 1</span> <span class="columns"> <span class="column">Node 1 column 1</span> </span> <div class="children"> <div id="node2" class="leaf"> <span class="body">Node 2</span> <span class="columns"> <span class="column">Node 2 column 1</span> </span> </div> </div> </div> </div>

With the following style sheet applied:

.tree
{
 cursor: default;
 white-space: nowrap;
 float: left;
 position: relative;
}
.tree *
{
 position: relative;
}
.tree .columns
{
 position: absolute;
 top: 0;
 right: -200px;
}
.tree .children
{
margin-left: 20px;
}

Columns are wrapped inside SPAN element (of “columns” class and absolute position). This and negative right coordinate will cause the columns to show up to the right of the tree. There was a problem in Mozilla with column cells and their tree nodes moving down when the tree expands, but collumn cells are nore moving back up when the tree collapses. Making “position: relative” for all elements inside the tree fixed the problem. “top: 0” is required to fix layout problems in IE working in quirks mode and it’s probably a good idea to have both horizontal and vertical coordinates declared to confuse the browser less.

There are more problems with the tree and CSS and I will probably write about them soon.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/13/2005 at 8:53 AM
Categories: Web development
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Worm at another turn of liquid maze (changing blog URL in CS)

After some consideration, I decided to move the blog to a new location. http://cs.emeraldhand.com/blogs/WormInLiquidMaze/ is a new place to look for me. I created a new blog at the old location that informs visitors of the new URL. Plus, in the past I’ve shifted to using FeedBurner to host the feed, so anybody reading me through it should not notice any changes.

The main reason for the move is to get around behavior browsers are showing sometimes when they decided that underscore ( _ ) looks cutter and fuzzier encoded in a hexadecimal number. No, really, why else would they encode it?

Like everything in life, it took longer to do what I wanted than I expected and in then I found a simple way to do it. I don’t want other CS users, who realize that default replacement of white spaces with underscore upon blog creation is not the best way to generate the link, waste their time so I’ll describe simple procedure to change the blog location.

  1. Ensure system account on which ASP.NET is running has modify permission on the cs/blogs directory. In case you’re wondering by default ASP.NET is running under ASPNET account in Windows XP and under Network Service in Windows 2003. If for some reason, you can’t give the required permission to ASP.NET and you have folders with the same name as your blog created in cs/blogs folder you should change the name of the folder manually to the new location where you want the blog to reside.
  2. Go to the blog administration and at the bottom of the screen where it says “Blog name” enter a new name to be used as a URL for the blog location.
  3. This is where it gets tricky. ASP.NET application must now be restarted. To do it the easiest way copy web.config file from remote host to your computer and back, effectively overwriting web.config with it’s copy. This should get ASP.NET to notice that the file was changed and it will restart the application.
  4. Update all external links under your control to point to a new location.
  5. Laugh at people who are trying to use the old link to find your blog.
    - OR –
    If you’re really nice, create a new blog at the old location to inform them of the change. Even people subscribed to the old feed should notice a post on the new blog informing them to update their link.

If you have any comments, question or if you have some idea how to redirect browsers directly to the new blog location from the old without the hassle of a second blog let me know.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: Slava
Posted on: 6/11/2005 at 10:51 AM
Categories: General
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed