Developing an Object Oriented Business Component Using WCF and Visual Studio 2008 - Understanding the WCF Business Component
(Page 2 of 5 )
The object oriented approach followed in this article is simple and yet powerful. Let us try to understand the classes included as part of the component.
The class “Product” (Product.vb) is specially created to hold one row of the “Products” table (of the “Northwind” database) in the form of an object. It is also called an “Entity” class. This is the basic unit of the Business Component to hold the data (which can be passed through tiers).
The “Products” class (Products.vb) is mainly used to hold more than one row of the “Products” table in the form of a collection. It is also called an “Entity Collection” class. When we need to have a set of rows grouped together as a single object, this class helps us a lot.
Next comes the “IProductService” interface (IProductService.vb). This defines the skeleton of all services (or operations) offered by our WCF Business Component. Each of these operations works as an interface between the consumer (WCF consumers) and our component. These operations generally interact with databases (or even other business components). As it is an interface, it doesn’t contain any implements of those operations.
When it comes to implementing the “IProductService” interface, the “ProductFactoryService” class (ProductFactoryService.vb) enters the picture. It implements each and every operation declared in “IProductService.” This is the true “Business Logic Implementation” class which may include data validations, computations and business calculations, transactions, interaction with databases, populating entity objects, and so forth.
Database interactions can be directly included as part of “ProductFactoryService.” But it is always better to separate data access into a different class. This approach of separation not only gives you a great advantage as far as scalability (say you wanted to access Microsoft Enterprise Library in future), but also acts as a common data access gateway for all of your business logic implementation classes.
Now that you understand the object oriented structure implemented as part of WCF Business Component, it is time to go through the code.
Next: Understanding the WCF Business Component: Source Code for Entity classes >>
More BrainDump Articles
More By Jagadish Chaterjee