Guys, this is our weekly meeting outside of permises and it was held somewhere on the River Nile (very romantic place) and my colleagues were really enjoying the fund and the Ice-Cream, while I was photographing
![]() |
| Weekly Meeting – 19 June 2009 |
This is an open source project that I found on CodePlex and it looks promising in terms of functionality, Hope you enjoy it.
The Object Oriented Paradigm is shifting massively because coupling relational semantics into our fine grained object oriented programming designs is becoming unpopular in today’s enterprise needs and domain engineering. Because of this reasons and many more, object oriented platforms is already taking a big quantum leap since the impedance mismatches between OOP and Relational has made programming against relational database an Herculean task for most development efforts.
The industry is filled with many framework’s that contribute to this change, and “Rapid Entity Framework” is one out of many that will solve most of the mismatches that we face in the persistence industry today. Rapid Entity Framework is an open source framework that was discovered by a motivation to really solve the divide problem between relational DB and object oriented concepts.
With rapid entity framework, you can think about your business domain rather than columns and rows. Its a wise design efforts to really segregate applications according to their duties, “what they do”, this segregation methodologies applied by industry today, should be applied to database and object (Because they are different concept). A database is data centric, and should only contain data and any data manipulation semantics. While on the other hand, an object oriented architecture see object as real life artifacts.
Introducing Rapid Entity Framework
Rapid Entity Framework is another Object Oriented Relational Mapping framework with full object orientation semantics. It runs on the Microsoft .NET environment and its compliant with the .NET languages (C#, VB.NET). Rapid Entity gives you the benefits of persisting and fetching object states in a relational database system without forcing you to implement or inherit framework classes. I see Rapid Entity as the .NET version of the JAVA PERSISTENT FRAMEWORK So if you are a java developer in .NET Land here is the equivalent of JPA. To start with, let us follow a simple rapid example : with the following assumptions :
Customer Class Diagram
The diagram above depicts the structure of the Customer and Address entity classes. There is a one – to – one relationship with both classes, so this will form the basis of our examples. First of all, we need to understand how to persist these entities, so i will be describing the rapid framework classes that we need to do the persistence. The snippet below shows how we can rapidly persist and manipulate an entity (Customer) in our example.
EntityManager manager = new EntityManager();
manager.OpenDatabaseSession();
First of all, the code snippet above is to initialize the EnitityManager class, which in this case is our entry – point to the persistent framework. We are initializing the EntityManager class with the instance of the WebConfigurationFactory. The WebConfigurationFactory class is created once in an application lifetime and it serves as the manager for database connections, and connection string. If you want to know how to setup your WebConfigurationFactory class, click Setting up WebConfigurationFactory . Most web applications that targets Rapid Entity Framework will configure the WebConfigurationFactory in their Global.asax (On_Application StartUp) file or class that is registered as HttpModule, while standalon\or console based application will use the ConfigurationFactory, both classes implements IConfigurationFactory interface.
Now let us create a Customer object and fill the fields with values :
Customer customer = new Customer();
customer.Country = "United Kingdom";
customer.FName = "Ahmed";
customer.LName = "Salako";
customer.Message = "Hello world";
Above code is the initialization of our customer object. To do next is the initialization of an address class. The Address and Customer class are related by a one -to- one. We will initialize an address object and assign values to it and we will assign the address object to the customer object. such as follows :
Address address = new Address();
address.Country = "Nigeria";
address.Customer = customer; //You can notice the bi-directional relationship here.
address.HouseNo = "83";
address.PostCode = "NE 889";
address.Street = "Gotham City";
customer.Address = address; //You can notice the bi-directional relationship here.
*Key Note : Make all your entity properties virtual, because the API uses ghost objects (Like Dynamic Proxy).
The code snippet above assigns an address object to a customer object. All the two objects are not yet persisted, so we will do the persistence by calling the code below :
entitymanager.CreateNewEntity(customer);
entitymanager.ComitAndClose();
Note that we are calling entityManager.CreateNewEntity(customer); we are creating the customer object which will in turn create the address object because their relationships in the mapping is also Cascade. which means when we make changes to customer, the changes in the address object will also be persisted. If we delete customer, the address object will also be deleted if we set the appropriate cascade.
Separating user interface code from everything else is a key principle in well-engineered software. But it’s not always easy to follow and it leads to more abstraction in an application that is hard to understand. Quite a lot design patterns try to target this scenario: MVC, MVP, Supervising Controller, Passive View, PresentationModel, Model-View-ViewModel, etc. The reason for this variety of patterns is that this problem domain is too big to be solved by one generic solution. However, each UI Framework has its own unique characteristics and so they work better with some patterns than with others.
The WPF Application Framework (WAF) provides support for the Model-View-ViewModel Pattern because this one works best with Windows Presentation Foundation (WPF) applications. This pattern is also known as PresentationModel pattern.
MSDN: A variant of the Presentation Model pattern named Model-View-ViewModel is commonly used in Windows Presentation Foundation applications.
Represent the state and behavior of the presentation independently of the GUI controls used in the interface.
The most approved description of this design pattern is done by Martin Fowler. You can read his article online on his website. The following chapters describe our specific .NET implementation of this design pattern.
The following UML class diagram shows the collaborating classes of this design pattern in a logical layered architecture.
Figure 1: The structure of the Model-View-ViewModel Pattern
The types participating in this pattern are:
This specific implementation of the ViewModel pattern has the following liabilities:
The WPF Application Framework (WAF) provides some types which helps you to implement this pattern.
Derive your ViewModel implementation from this class. The ViewModel class provides a default implementation of a weak event listener and it is responsible that the DataContext of the WPF view gets the instance of your ViewModel.
If your ViewModel implementation gets too big or you have low cohesion in your class then you can divide the ViewModel into a root ViewModel class and one or more child ViewModel classes. In this case your child ViewModels must pass the value ‘true’ for the child constructor parameter of the base class. Additionally, the root ViewModel has to expose its child ViewModel objects to the View (e.g. through a property) because the View has only an association to the root ViewModel.
All WPF views that are managed by a ViewModel have to implement this interface. You can create your own interface for exposing properties and methods of the View. We recommend to inherit own View interfaces from the IView interface.
This class provides a simple implementation for the ICommand interface. The constructor requires a delegate which is called when the command is executed. A second delegate can be passed to the constructor which is called when the command needs to refresh its state. With the second delegate it’s possible to define when the command should be disabled. The command state refresh is triggered through the RaiseCanExecuteChanged method.
This command implementation is an ideal candidate for the ViewModel. By using the DelegateCommand, the ViewModel gets informed when it should handle a user interface action (e.g. Button was clicked). You need to expose the commands in the ViewModel through properties and bind in the View on them.
| Share this post : | ![]() |
![]() |