Blogs

Gary's Blog

XAF – Application Model and Model Editor Improvements V2010 Vol1

     

In this post I want to let you know about a number of exciting improvements to the Application Model and to the Model Editor that will be available in V2010 Vol1. Firstly, we have greatly optimised the model generation. In fact generation now happens around 100 times faster than in previous versions! So what does that mean for your users? Well it means that the average XAF application now launches around 60% faster than before! But we’re not finished there, application startup time also consists of the time spent collecting information on the types used in the application and we have targeted this area for improvement in the 10.2 release timeframe. If you want to keep up to date with our progress in this particular area, you can track this suggestion.

The next improvement I want to tell you about is to the Model Editor. If you’ve been using XAF in a non trivial way, you may have noticed that if you open the Model Editor you can be visually swamped by the attributes – wouldn’t it be really cool if you could group those attributes by category? Well, good news, now you can! As of 10.1 you’ll be able to decorate your interface attributes with CategoryAttribute and that will cause the Model Editor to group those attributes by the specified category. All the standard XAF application model attributes belong to one of the common categories described here. If an attribute is not decorated with CategortyAttribute then it will appear in the Misc. category by default. An example of this is shown below:

Another improvement to the Model Editor is that it is now possible to select members of complex properties in a drop-down editor, containing a tree structure of your business model as shown below:

screenshot

Another improvement is that identifiers for the most nodes are now generated automatically. If you extend the application model and follow the naming convention for node identifiers, then their values will be generated automatically. We recommend that you declare the 'Id' property (the last character is in lower case). This property will always be recognized as the key even if the KeyPropertyAttribute doesn't point to it. Although this is a small feature, it will save time when customizing the application model and also overcome some previous limitation, like the one mentioned here.

The last improvement I’m going to talk about in this post is the fact that it is now possible to use the DC technology to easily inject additional business logic into the application model. Let’s consider a couple of examples:

Example 1

Before:

<Element Name=""EditorStateRule="""" ="" >
  <Attribute Name=""TypeInfo="""" RefNodeName=""/Application/BOModel/Class"" Required=""True"" />
  …

Now:

public interface IModelEditorStateRule : IModelNode, IEditorStateRule {
    …
    [ModelPersistentName("TypeInfo")]
    [DataSourceProperty("Application.BOModel"), Required]
    IModelClass ModelClass { get; set; }
    …
}

Note that XAF’s DataSourcePropertyAttribute is used in the same manner as when you want to provide a data source for a lookup property in your business class. Since our interface is derived from the IModelNode one we can access its Application property and its nested properties. Also note that for the backward compatibility (for example, not to lose old model differences) the ModelPersistentNameAttribute is used to map the new property to the old name.

Example 2

Before:

<Element Name=""NavigationItems="""" ="" >
  ...
  <Attribute Name=""Current="""" RefNodeName=""{DevExpress.ExpressApp.Core.DictionaryHelpers.CurrentNavigationItemNodeProvider=""}""/>
  ...
</Element>

Now:

public interface IModelNavigationItems : IModelNode, IModelList<IModelNavigationItem> {
...
    [Browsable(false)]
    IModelList<IModelNavigationItem> AllItems { get; }
    [ModelPersistentName("Current")]
    [DataSourceProperty("AllItems")]
    IModelNavigationItem StartupNavigationItem { get; set; }
    ...
    [DomainLogic(typeof(IModelNavigationItems))]
    public static class ModelNavigationItemsDomainLogic {
            ...
    public static IModelList<IModelNavigationItem> Get_AllItems(IModelNavigationItems navigationItems) {
        CalculatedModelNodeList<IModelNavigationItem> result = new CalculatedModelNodeList<IModelNavigationItem>();
        foreach(IModelNavigationItem navigationItem in navigationItems) {
            result.Add(navigationItem);
            result.AddRange(GetChildItems(navigationItem));
        }
    return result;
    }
            ...
}
…

Here we have introduced a hidden ([Browsable(false)]) service property (AllItems) and set it as a data source for our StartupNavigationItem attribute. It’s exactly the same as the popular Scenario 4 in the help topic about filtering lookups.

Example 3

Before:

<Element Name="Class" ...="" >
  ...
  <Attribute Name="GroupName" IsReadOnly="True"/>
  <Attribute Name="IsNavigationItem"   IsReadOnly="true" Choice="True,False" />
  ...

Now:

public interface IModelClassNavigation {
    [ReadOnly(true)]
    bool IsNavigationItem { get; set; }
    [ReadOnly(true)]
    string GroupName { get; set; }
}    
[DomainLogic(typeof(IModelClassNavigation))]
public static class ModelClassNavigationItemDomainLogic {
    public static bool Get_IsNavigationItem(IModelClass modelClass) {
       ...
    }
    public static string Get_GroupName(IModelClass modelClass) {
       ...
    }
    ...
}

Here we added a domain logic to calculate default values for read-only attributes shown for the class node in the BOModel.

Example 4

Before:

<Element Name="Filters" Multiple="False">
  <Attribute Name="CurrentFilterID" 
     RefNodeName="{DevExpress.ExpressApp.Core.DictionaryHelpers.ChildrenRefNodeProvider}" />
  

Now:

public interface IModelListViewFilters : IModelNode, IModelList<IModelListViewFilterItem>
{
    [ModelPersistentName("CurrentFilterId")]
    [DataSourceProperty("this")]
    IModelListViewFilterItem CurrentFilter { get; set; }
}

Okay, that’s enough examples for today, I don’t want your heads to start spinning :-)

If you want to see more examples,  you can check out the sources and the docs (once they are available <grin>). They’ll describe the most common cases, in which domain logic can be effectively used to extend the application model.

The bottom line is that things become easier with the improvements to XAF. For example, in previous versions to achieve the same tasks you had to use complicated approaches that quite often utilized undocumented schema attributes and internal classes from the DevExpress.ExpressApp.Core.DictionaryHelpers namespace. This, of course, made life difficult for inexperienced users, not to mention the fact that we don’t recommend that developers use undocumented classes :-) 

Now the same, well-understood technology, used to implement business logic in your classes, can be used in the application model and Model Editor, which means you can now use the same techniques and approaches that you are familiar with.

Well that’s all for this post, until next time, happy XAFing! :-)

Published Apr 13 2010, 02:47 PM by Gary Short (DevExpress)
Filed under: ,
Technorati tags: V2010 V1, XAF
Bookmark and Share

Comments

 

Twitter Trackbacks for XAF ??? Application Model and Model Editor Improvements V2010 Vol1 - Gary's Blog [devexpress.com] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 XAF ??? Application Model and Model Editor Improvements V2010 Vol1 - Gary's Blog         [devexpress.com]        on Topsy.com

April 14, 2010 7:50 AM
 

Jascha said:

Hi Gary,

Could we have a proper series of in-depth posts introducing and expanding on DC technology. It looks very promising but all these teasers, while quick to put together from your perspective, leave me (and perhaps others) wanting to know more about what looks like a key differentiating technology that is at the heart of XAF 10.

I'm not sure if that comes under the remit of evangelism but we could do with something with some depth here!

Jascha

April 15, 2010 4:25 AM
 

battulga said:

Hi Gary,

Why did not XPO support multi primary key?

April 15, 2010 6:28 AM
 

Dennis (DevExpress Support) said:

Hi Jascha,

Thanks for your feedback. We believe that the XAF documentation as well as the examples in the Code Central should close the current gaps and make the new technology more accessible to XAF developers.

Although, I think that I should mention that DC will be in CTP in the 10.1 so perhaps we will need more time to provide thorough documentation.

For now, feel free to ask questions if any. We will be glad to explain how the example code works, what's supported and what's not. Any feedback is welcome.

BTW, I am now working on an example demonstrating how to unit test domain logic consumed by the application model interfaces. I hope that might be the "depth" you are so longing for.

Plus, the beta and the release is coming very soon, and you will be learn still more from the sources, if of course you have some time for that. But this is of course the worst and most unlikely scenario - as I said, we hope that some documentation will be available by then.

So, please stay tuned!

April 15, 2010 6:10 PM
 

Arno Harskamp said:

Just one question about DC, since I am getting a strong feeling I'm tuning into nothing but radio silence ;)

Is.... the direct interface between XAF and XPO going to be killed or not, now or in the near future, now DC is making this prominent appearance? Am I forced to start using the DC layer and attempt to rewrite all my BOs the DC between now and the near future in order to to continue using XAF?

This is a key question I and our company as a whole would like an answer to. Rather yesterday than tomorrow.

Thank you!

April 23, 2010 8:09 AM
 

Gary Short (DevExpress) said:

Hello Arno,

No, you will not be forced to use the new DC technology. The current BO method has a number of weaknesses, some customers never bump up against these weaknesses and so they have no problem using the current method and are free to continue to do so in the future. However, some customers do encounter these weaknesses and those customers will be able to move to the new DC technology to overcome them.

On a more general note, if you require an urgent answer to a question it's better to email me. I spend a lot of my time travelling around and whilst I am not able to write blog comments and forum posts from my iPhone, I can answer email and so you'll get a faster response via that medium. My email address is garys@devexpress.com, feel free to mail me anytime. :-)

April 23, 2010 8:48 AM
 

Arno Harskamp said:

Contact!

Hello Gary, good to hear from you. I am not sure if and what may have been going wrong, but we indeed used e-mail only.

At 03/05/10 to "Gary Short" <gary@garyshort.org> "Betr.: Re: Q248090"

At 04/16/10 to "garys@devexpress.com" Subj: "DC, XPO Security, 2010.1 Beta"

I replied to the mail from you that came from the .org domain, and after a month of no response I sent a reminder to the devexpress.com domain.

Would you be so kind to figure out whether you received any of those mails at all? That would be much appreciated.

Regards,

Arno.

April 23, 2010 11:08 AM
 

Gary Short (DevExpress) said:

@Arno, I have replied to all emails that I have received from you. If you still have outstanding issues, can you please resend? I'm not aware of having had any email problems, but that does not mean there hasn't been any. :-)

April 23, 2010 11:25 AM
 

Joe Hendricks said:

Awesome! Time for a new DX TV Channel Video :-)

April 23, 2010 3:12 PM
 

Robin 1 said:

Is the video available ?

July 10, 2010 12:21 PM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.