Archive for April 29th, 2008

29th Apr 2008

Setting the Initial Sort for a Flex DataGrid Component

A client asked me recently to to have the data being displayed in a Data Grid be initially sorted by store name (See Creating an Image Reflection in Flex to view the project in question). The way you do this is by sorting the Datagrid’s data provider. To do this, you need to create a sort object, assign it some sort fields, set that sort object as the dataprovider’s sort object (so you have to be using some sort of sortable collection to do it this way) and refresh the collection. This looks something like this:

private var storesXMLCollection:XMLListCollection = new XMLListCollection();
private var initSort:Sort = new Sort();

/ /SortField(name:String = null, caseInsensitive:Boolean = false, descending:Boolean = false, numeric:Boolean = false) so in this case companyName is the XML Node I am sorting on and the second parameter indicates that the sort should be case insensitive.

this.initSort.fields = [new SortField(“companyName”, true)];

this.storesXMLCollection.sort = this.initSort;

//once the sort object has been applied, refresh the collection.


Posted by Posted by Jeremy Wischusen under Filed under ActionScript 3, Flex Comments No Comments »

29th Apr 2008

Nothing Left To Take Away

Recently I have bee reading this book
Beautiful Code : Leading Programmers Explain How They Think by Greg Wilson (Editor) , Andy Oram (Editor)

and I just got through a chapter entitled “The Most Beautiful Code I Never Wrote”. The main idea expressed in this chapter is that a project is not finished when there is nothing more to add, but rather when there is nothing left to take away.

This immediately struck me as true based on my own experience, but perhaps a bit counter intuitive.  It is easy to conceptualize a task in terms of what needs to be accomplished (added), but we may often forget that it is equally important to review what has already been done to see what can be improved or refined. Many times the first attempt at a project is just an attempt to get it done (normally under the constraints of an unrealistic deadline). Looking back now, most of my best projects (and most satisfying) are the ones I went back and reviewed and found simpler ways to accomplish what I had done.

In the world of tight deadlines, we do not always get the luxury of doing this, however, the sentiment of nothing left to take away is an important one and should at least be remembered if not always implemented.

Some notable quotes from the chapter:

  • Simplicity does not precede complexity, it follows it. (Perlis)
  • Make everything as simple as possible, but no simpler. (Einstein)
  • A designer knows he has achieved perfections not when there is nothing to add, but when there is nothing left to take away (Saint-Exupery)

And to sign off,

If I had more time, I would have written you a shorter letter. (Pascal)

Posted by Posted by Jeremy Wischusen under Filed under Application Design and Architecture, General Comments No Comments »