Tuesday, June 10, 2008
CalculatedMeasures in Flex OLAP
Sunday, June 1, 2008
Here is a GroupingCollection with good performance !
Replace the GroupingCollection instance in any application with GroupingCollection2 and check the performance. When I tested it with 8K records with 4 grouping fields it was able to group in 5 seconds which seems to be good (in comparsion).
Please note this has not gone through extensive testing. I would be glad to fix any bugs found.
If you are one of those who doesn't have patience to build and test an app, here is the one I built. Here is the source.
If you think it is worth your time drop a note about your findings !!
Wednesday, May 28, 2008
Grouping XML data using GroupingCollection
There is not much to describe so :
<mx:XML id="inputData" >
<Tulokset>
<Tulos id="xxx" group="xx" />
<Tulos id="xxx" group="xx" />
<Tulos id="xxx" group="xx" />
</Tulokset>
</mx:XML>
<mx:AdvancedDataGrid creationComplete="gc.refresh()">
<mx:dataProvider>
<mx:GroupingCollection source="{inputData.Tulos}" id="gc">
<mx:Grouping>
<mx:GroupingField name="@group" />
</mx:Grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="@id" />
</mx:columns>
</mx:AdvancedDataGrid>
The source is here.
Update: The below example shows how to use grouping when the data is in child nodes instead of attributes. This is a bit tricky because GroupingCollection is derived from HierarchicalData which treats child nodes as children by default. This leads to problems when we try to display the data after grouping. The trick is to make use of the childrenField property and point it to something like "undefined".
<mx:XML id="inputData" >
<Tulokset>
<Tulos>
<id>xx1</id>
<group>xxx</group>
</Tulos>
<Tulos>
<id>xx2</id>
<group>xxx</group>
</Tulos>
<Tulos>
<id>xx3</id>
<group>xxx</group>
</Tulos>
</Tulokset>
</mx:XML>
<mx:AdvancedDataGrid creationComplete="gc.refresh()">
<mx:dataProvider>
<mx:GroupingCollection source="{inputData.Tulos}" id="gc" childrenField="undefined">
<mx:Grouping>
<mx:GroupingField name="group" />
</mx:Grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="id" />
</mx:columns>
</mx:AdvancedDataGrid>
The source is here.
Please note that childrenField is also helpful when we are trying to display XML data with data and children as child nodes. Use it to point to the proper node name which contains the children. In the following example we need to set childrenField="details" to work properly.
<mx:XML id="special">
<rows>
<row>
<name>A</name>
<fund>100</fund>
<details>
<row>
<name>a</name>
<fund>20</fund>
</row>
<row>
<name>b</name>
<fund>80</fund>
</row>
</details>
</row>
<row>
<name>C</name>
<fund>200</fund>
<details>
<row>
<name>a</name>
<fund>80</fund>
</row>
<row>
<name>b</name>
<fund>80</fund>
</row>
<row>
<name>c</name>
<fund>40</fund>
</row>
</details>
</row>
</rows>
</mx:XML>
<mx:AdvancedDataGrid >
<mx:dataProvider>
<mx:HierarchicalData source="{special.row}" childrenField="details" >
</mx:HierarchicalData>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="name" />
<mx:AdvancedDataGridColumn dataField="fund" />
</mx:columns>
</mx:AdvancedDataGrid>
Object/Array and ObjectProxy/ArrayCollection binding problems
Many seems to be stumble upon this problem. Very similar to Object not dispatching any event for property value changes Array also doesn't dispatch any event for items added/deleted from it. Due to this when an object or array is used in the dataProvider of a list based control or comboBox etc any updates to the object or array would not get reflected in the UI.
The following sample should make it clear.
The first DG is fed with a ArrayCollection of Objects and the second DG has ObjectProxies. Select a item in the DGs and edit the values displayed in the text inputs. To complete the editing hit "Enter". Notice that in the first DG the values don't get reflected immediately where as in second DG it does.
To support Object based dataProviders the list based controls in Flex make a explicit call to ICollectionView.itemUpdated() to force a change event. This is the reason edits in list based controls get propagated to other list based controls when both of them are using the same colletion as input.
The source is here.
As noted in the forum discussion, when HierarchicalData is built using Objects/Arrays (to represent children) the changes to the Array would not get propagated to ADG. Hence it is necessary to construct the HierarchicalData using ObjectProxies and ArrayCollections.
Thursday, May 15, 2008
Fixing itemRenderer memory leak in AdvancedDataGrid on columns change
I think I found the workaround for this issue. We need to override the set columns method in a extended ADG class and add the code to free the dictionary holding on to the itemRenderers. Here is the code.
<?xml version="1.0" encoding="utf-8"?>
<mx:AdvancedDataGrid xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
override public function set columns(value:Array):void
{
super.columns = value;
itemRendererToFactoryMap = new Dictionary(false);
}
]]>
</mx:Script>
</mx:AdvancedDataGrid>
Thursday, April 17, 2008
Why do people shy away from giving useful 360 degree feedback?
I can understand the case where feedback provider holds back this thoughts when there is a fear that his or her name would be revealed and it may spoil a good relationship or cause unnecessary trouble in office or life.
But when the feedback is being provided for a good cause why do people shy away from giving a complete feedback? Why do they provide 180 degree feedback which only leads in a direction but doesn't complete the circle leaving the seaker to ponder all over for the correct point?
Take example of ADG performance poll. There are votes for good, ok and bad. Good and OK are understandable because it is kind of known as testing and many in house scenarios has proved that the performance is acceptable (if not great) in many use cases. But BAD was (kind of) unexpected because of so many hours of testing which has gone in.
Bad performance can arise because of many reasons. For example it can be due to bad performance of GroupingCollection as Doug has kindly pointed out. It can be due to complex custom itemRenderers being used. It can be due to a genuine problem in a particular control flow inside ADG. But without a complete feedabck (pointers to the exact problem faced if not samples) it would be impossible to work on anything. It would be similar to searching for a black coat in a dark room or worse for a non existent coat in a dark room.
This also goes along the same lines as my post about software patches. If customers don't make use of available source and public bug base and provide a good feedback even a very good intention/path provided to help customers goes waste.
In this context I don't know whom to blame for the situation as customers we find ourselves in, because we are not making full use of the easy avenues open in front of us to make a product worthy of the money we have paid for. Or is it that customers have accepted the situation and are showing indifference towards demanding what they rightly deserve?
Wednesday, April 9, 2008
Software patches good/bad/ugly?
In early days when the auto update feature was unheard of I used to think software patches are ugly. One needed to keep visiting the website of the product frequently to check whether a patch was available to fix the problems one is facing with the product.
Once patches became more and more popular and available I used to think them as bad. That was becuase sometimes patches used to have more serious problems than the original product. And once you have applied a patch it was not easy to remove it and a complete uninstall-install cycle was required to get back to square one. The "The update requires a system restart. Restart now?" screen only served to add more fuel to the bad feeling.
Now that auto updates are default and internet is thought as part of your desktop I have beginning to think that patches are good! I think the quality of patches is better now compared to earlier days, may be due to companies having automated testing tools to assure quality.
My latest thought is that "Not having (releasing) patches is really really a bad thing". Pushing a product out of the door having already planned for patches is bad. But at the same time knowing that customers are suffering with a released product, asking them to wait for the next release (which would be more than a year later) is just pathetic. Because every release comes with its own new features and new bugs. Companies don't push out new releases without new features as they won't earn any money with a release (patch) aimed at fixing serious bugs or performance issues in the previous release. The problem with this kind of approach is that the attitude about a bug changes in the following way.
Version 1.0 release : We are releasing a great product which would help our users in a great way by boosting their productivity. We would fix all serious bugs soon.
Customer: Great. Let me use it.
Version 2.0 release : We have lot of new features for you. In this release we have addressed all serious bugs (read it as bugs reported by great parteners and volume customers) in the previous release.
Customer: But what about other serious bugs faced by me?
Company: We would fix all bugs soon.
Customer: They are only fixing bugs for the new features and few more bugs from volume customers.
Version 3.0 release : We have lot of new features. We have revelutionized the workflow. We have rewritten many parts of the code to boost peformance. etc... Of-course now we are open-source !
Customer: Now it is Open-source ? Great! But what about bugs which were in 1.0 release?
Company: Oh! our customers have lived with these bugs for more than 2 years, now they have almost stopped complaining.....they can live with it! If they complain more, let us ask them to upgrade to the new version and follow a new workflow/API for the same feature which we have introduced. And anyway we are open-source let them grab the source and fix the bug themselves. We can't spend our precious development time over fixing those old bugs.
Customer: Where I can find a developer and time to study this piece of open-source product and fix bugs for me? ...?....?
As customers who have paid their hard earned money I think we deserve a better treatment. Don't you think so?