Quantcast
Channel: XAF Team Blog
Viewing all articles
Browse latest Browse all 148

Migrating a legacy real world application

$
0
0

Recently we made the decision to port our Winforms VideoRent real world application into XAF, thus was the XVideoRental app born. With my LEGO designer hat Smileon I will go through all migration steps.

The XVideoRental app utilizes XAF recourses –>Native modules, Code Central examples along with open sourced project and community contributed suggestions. To bring this app to fruition, we spent all of the production time gathering ready-to-use implemantations and placing them in a reusable project agnostic library. This will save you from having to write a lot of the code from scratch. In addition since all these ready-to-use implementations already existed in our community project (eXpand), we created a second open source version of XVideoRental where this project agnostic library does not exist, this spending even less resources for building it!

The overview post explained that the XVideoRental contains almost zero designed time code and everything is described declaratively in XAF’s Application Model xafml file, allowing for full customization upon distribution.

There are many demands on today’s Real world applications. Features, and lots of them, are what users want. Since we had to take the time to invent something entirely new, our first releases fell short of providing a rich-feature app. Creating from scratch especially for such comprehensive framework like XAF, takes time and resource, and we simply had to prepare a domain-specific language (DSL) that would bridge business requirements with our existing technical knowledge. But the basic app is now of the way. Using the application model and the Security System, XAF fully describes and configures the behavior of platform agnostic applications. Both the Application Model and the Security System are the technology abstractions that will serve to minimize development costs of real world applications.

We recommend:

1.  Watch the BUILDING A PROJECT MANAGER APPPLICATION IN 5 MIN video where we used the same LEGO designer approach as in the XVideoRental app in a simpler application our MainDemo.



2.  Go for a quick overview of the XVideoRental app by reading XVideoRental real world application (RWA) – The overview.
3.  Check out the next table, these simple statistics clearly illustrate the tremendous advantages of developing with XAF.

  Number of projects Classes Lines of code
Legacy VideoRent
Location:
Four non reusable projects  256 27965
XAF XVideoRental• 1 project agnostic library
• 1 non reusable module
• 1 front end application almost unmodified as  created from VS templates
-
77
5
-
806
126
Open Sourced XVideoRental • References open sourced libs (project agnostic lib not exist)
• 1 non reusable module
• 1 front end application almost unmodified as  created from VS templates
-
36
5
-
807
126

In short, the legacy app uses 256 classes. The XVideoRental app utilizes less 77 and 90% of them are simply concrete implementations from the referenced project agnostic library. I want to draw your attention to the 3rd row,with only 36 classes!

Legacy app location:               %Public%\Documents\DXperience 12.2 Demos\Common\DevExpress.VideoRent.Win\CS\
XAF app location:                   %Public%\Documents\DXperience 12.2 Demos\eXpressApp Framework\XVideoRental\CS\
Open source XAF app location:
http://www.expandframework.com/downloads/download.html–>Demos\XVideoRental\

4.  Finally go through the list below where we compare the legacy and XAF applications side by side.

Legacy VideoRent

XAF XVideoRental

Data Access 

• The legacy app uses ORM technology and our XPO to describe the video rent business. However, special skills are needed, as well as extra efforts, in order to create a clear separation from  other layers, this way many helper classes will exist even for very common tasks such as database connectivity.

• XAF has built-in support for both XPO and MS Entity Framework. We can utilize the legacy domain model by simply copying &- pasting the classes. Helper classes are of no use, because XAF can handle all common tasks transparently for us!

• In real world application, requires an importing mechanism for initial data. The legacy app imports data from xml files with the exactly the same schema as its business objects. Therefore, even for a small change in the BO design, we need to modify and retest this mechanism.

• The XVideoRental app plugs-in an abstract domain-agnostic importing engine described in Fast prototyping requires an initial data import mechanism blog and allows us to modify the structure of BO in the minimum time possible. In addition, Supplying Initial Data is well documented, saving us time when it comes to making architectural decisions.

• In a real world application, sequential number integration is essential. However, special design and knowledge is needed to be able to build something reliable.

• The XVideoRental app is an XAF app, and XAF already provides a solution to such a common developer task. For an example please see E2829. So  the developer only needs to integrate, and not think about the technical difficulties or showstoppers.

Architecture 

The legacy app has a design time modularization based on Forms/UserControls/(Business Concept). It is not possible, however to extend this modularization without adding new Forms and recompiling the whole application inside VS. In addition, due to a lack of documentation, determining the best place to write code for specific behavior can still cause big headaches.

Application life cycle is component centric and was invented on demand for the current application.

The XVideoRental demo is using XAF’s well-documented and simple to use MVC architecture. While the discussed application is a simple fat client app, demanding users looking for something more advanced may also find ready–to-use client-server solutions in XAF.

• VS templates to quickly create modules which by design are reusable and independent from the main application.
•  A well documentedApplication life cycle that guides us to where we need to write code (e.g.: Setup, Login, View Activation, etc.)
• A Simple to follow tutorial on how to Extend Functionality.
• A Detailed guide of all the main concepts for building business applications.

Data Validation 

A real world application without strong validation support is unstable and has huge support issues.
Building a validation engine is not a simple task and requires third party components, which raise the cost of a project. 
Therefore, the legacy application time frame and budget, along with the lack of validation support, wouldn’t allow any investment here.

Creating validation rules does not require you to be a developer, even end-users can create them, because it is simple, intuitive and not more difficult than creating a filtering rule in your Outlook. All that is needed is the installation of a built-in Validation module!

Data Representation 

The legacy application has a large number of components. Repetitive work was invested to:

XAF has native support for a large number of DX components and automatic UI generation (CRUD detail and list forms, navigation and menu systems - all based on data models).  This is a huge time saver because almost every typical business application contains a good percentage of list and detail forms, navigation and menu systems - all linked together without any effort on your side.

• Create a large number of data entry forms, drag & drop numerous controls on it, arrange their positions and configure data bindings
• Providing a consistent look and feel is not an easy job, and requires a deep knowledge of a large number of components, as well as a special design.
• Querying the database through XPO, creating CRUD operations, supporting transactions are hard tasks, so they exists in a basic version.
• In an agile real world, the navigation menu system should be controlled as declaratively as possible. However, the legacy app does not conform to this requirement resulting in huge update times for every customer request.
• Extend XtraReports for every Business object we want to create reports for.
• Design reports inside VS making their support  impossible in the real world.
• Design analysis views inside VS making their support impossible in the real world.

• We plugged-in a mechanism that allows you to control any component at runtime, starting with Dressing up our classes – Date with a model tonight!.
• A business rule driven Pivot editor borrowed from How to rule the Pivot page where we explained how to marry business requirements with a complex component like Pivot.
• Legacy code was converted on the spot to declarative as explained in Tooltips to the max - expressive UI.
• From Visiting dashboards, we add a ready-to-use extension that provides collaboration for our views.
• We met and exceeded over expectations by installing a community module like in Dashboards in the real world – A Scotland strike.

Application Configuration 

Although most of the components can persist their state, there is no application level integration by default. In addition, component serialization does not have a friendly design and is hard to edit and support. A legacy developer would have to create an integration mechanism deep in the application’s infrastructure. This is costly. Wrap-up was basic and targeted only a few major forms producing an inconsistent feeling.

The XVideoRental app is an XAF application which by design is described declaratively in XAF’s Application Model. Using the Model Editor at runtime an end user can modify any part of the app which is described in Application Model.

We could store that Application model in a database using the ModelDifference module but we chose not too because our job was to create a legacy app clone and not to reach the sky with the endless features of XAF.

Application Security 

The legacy developer tried to create a basic security implementation. However he soon realized building a reliable Security system was simply impossible with the current budget.

So, unfortunately there is no investment in implementing a security system.

In this case, we already have a mature plug n’ play Security module. This flexibility allows us to plugin more features such as User Friendly permissions and  metadata based permission policies

Reporting 

The major advantage of business applications is the ability to create and print reports.

Therefore, the legacy app must have a dedicated project for reporting. In this app, the developer had to use Visual Studio to design a report. As a result, he lost the opportunity to update it on demand(a common need) after project distribution.

At the same time, these reports are extended and bound to VideoRent business objects, making the whole implementation not reusable from any other project.

The XVideoRental app uses the built-inReports Module, which natively integrates our award winning XtraReports Suite and provides a runtime designer.

The module saves the reports in the database so our job was to copy & paste the Reports layout from the legacy app and distribute it as discussed in Distribute the Created Reports with the Application page.

Moreover, we provided collaboration/filtering with other views utilizing the usual a no code approach as discussed in Visiting dashboards blog.

Data Printing and Export 

A legacy developer would have to write special code for each component that he/she wished to print or export. Although this functionality is very useful, such a time commitment would not be practical in the real world.

The XVideoRental app can export data from the grid, pivot, chart, tree view, layout and others to a wide number of formats (PDF, RTF, TXT, CSV, HTML, MNT, XLS, XJSX, PNG, GIF, JPG, BMP, TIFF, WMF, EMF) without spending even a minute to install or configure the system! Of course, this is all thanks to XAF, which has a built-in generic mechanism for all controls out of the box!

Data Analysis 

The legacy app has a structure to support only a few data analysis views for the four major Business Objects which are Customer, Movie, Receipt and Rent. The large amount of code located inside UI form for each analysis view, makes the solution impossible to maintain. This occurs because for each new customer request, the developer must change the code, recompile and then redistribute the app again. A common example is a calculated value, which needs a UI for input and a special algorithm to create it.

XVideoRental uses the built-inPivot Chart Module, which shifts development to the runtime, allowing business users to modify the analysis display at any time. This app uses the extended Pivot from discussed in How to rule the Pivot. Empowering the app with the dashboard suite discussed in Dashboards in the real world – A Scotland strike! was as simple as dragiing & dropping the module from the VS toolbox!. Integration of runtime calculated members as in Domain Components+ Calculated properties + Application Model.

Localization 

Where there are techniques for localizing .NET applications via satellite assemblies, they don’t localize application specific data and are very time consuming. Thus, the legacy app does not really support localization.

XAF supports all standard localization approaches and also addresses the problems that occur with them. With XAF, it is always possible to localizeany part of your application at runtime (e.g., correct certain values from satellite assemblies). A convenient wizard provides the capability to use online translation services from MS, Google, etc. So, it is possible to leave the localization job to non-programmers who can easily import/export data without exiting the application.

Customizing Controls Appearance 

Even for the simplest operation, like making a bold grid column or hiding a control from a view, development time is needed to cover the recompilation and redistribution of the application.

The XVideoRental app addresses this declaratively using the Conditional appearance module and the technic described in Dressing up our classes – Date with a model tonight! blog, where any component can be serialized and controlled declaratively from XAF’s application model using the runtime Model editor.

This process is control-agnostic and we were spared from digging into the specifics of each control – XAF did everything for us!

Implementing Custom Business Requirements 

Lets go over a concrete example here. The legacy app uses tooltips to create a more expressive UI. However, even if the developer wrote a decoupled class at the end, he/she would have to attach it to various controls and forms. This makes the whole design not flexible, since changes require a developer’s presence.

XVideoRental can use the same decoupled class from the legacy application. However, it simply attaches the behavior to the application model, instead of attaching it to controls and forms. This solution is project agnostic and allows for later changesby a non-programmer at runtime! This process is discussed in detail in the Tooltips to the max - expressive UI article.

Getting Help and Support 

One cannot help but notice that application and its developer are simply married. If for any reason they separate, then everything would become very unstable and tricky. It would really be hard to find another developer to continue supporting a legacy app. Even if one manages to fin the right person, the cost would be overwelming, since the new developer would have no help docs or support of any kind with which to catch up.

The XVideoRental app uses bricks/samples from XAF’s code central and community project. Thus by design there is a large number of developers that can support its code base. Let’s not to forget the unmatched documentation and support we can get from the XAF team.

   

Conclusion

Even though XAF does not contain solutions to each and every business problem in the world,  the framework is very strong in provides its own extensibility ( "preventing the lock-in effect").  It is a quick and easy to plugin solutions to common business problems, after all, XAF is a Domain Specific Language that can bridge business requirements with our existing technical tools and/knowledge!

Until next time,

Happy XAF’ing!

Subscribe to XAF feed
Subscribe to community feed


Viewing all articles
Browse latest Browse all 148

Trending Articles