Business Layer - Suggestion request

Posts   
 
    
sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 03-Dec-2003 14:50:04   

Hi Otis, I am seeking suggestions/recommandations.

It seems to me that the layer that LLBL Pro generates could be clasified as Data Access layer (please excuse and correct me if I am wrong).

If this assumtion is correct, then there is a need for a 'Business Entity (BE)' and a 'Business Process (BP)' layer. Business The Business Entity layer would encapsulated for example a OrderHeaderEntiry and OrderDetailsEntity (generated by LLBL).

The Business Process layer would encapsulate BE's and provide funtionality such as 'PlaceOrder'. This functionlity would carry out the required business rules e.g. security - is the client logedon, check inventory etc.

The question to you is: 1. Can I inherit all the properties of LLBL generated entity i.e. OrderHeaderEntity in my BE class, and if required overide them. If yes, then an example would be useful. 2. Is there a better way to implement rater then this 3 layer architecture.

Suggestions would be great! Thanks in advance.

Regards. SP

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39618
Joined: 17-Aug-2003
# Posted on: 03-Dec-2003 17:50:39   

sparmar2000 wrote:

It seems to me that the layer that LLBL Pro generates could be clasified as Data Access layer (please excuse and correct me if I am wrong).

With the risk of starting a naming-game, I think the layer generated with the current template set can be seen as a BL Facade tier: it's not a raw DAL, because it hides away data-access code, it lets you work with entities, not with data read from a database. simple_smile

If this assumtion is correct, then there is a need for a 'Business Entity (BE)' and a 'Business Process (BP)' layer. Business The Business Entity layer would encapsulated for example a OrderHeaderEntiry and OrderDetailsEntity (generated by LLBL). The Business Process layer would encapsulate BE's and provide funtionality such as 'PlaceOrder'. This functionlity would carry out the required business rules e.g. security - is the client logedon, check inventory etc.

Beware by using inheritance for this. Some people argue to simply inherit BE's and add BL code to these classes, however BL code most of the time spans more than 1 entity plus is often part of a process (i.e. multiple steps towards a goal). Better, IMHO, is using Managers, like 'OrderManager', which manages ... Orders simple_smile and consumes entity objects generated by LLBLGen Pro, which can be order entities, customer entities etc.... It exposes a set of functionality to manage orders, which can be the target of the GUI.

The question to you is: 1. Can I inherit all the properties of LLBL generated entity i.e. OrderHeaderEntity in my BE class, and if required overide them. If yes, then an example would be useful.

The current template set has a limitation that when you inherit from a generated entity class, you can't create collections with these classes automatically. You can overcome this somewhat by using the derived entity classes generated in the two-class scenario. You can override properties in the derived entity classes (for example: entity Foo has two classes (hence the two-class scenario wink ): FooEntity (which is the derived class) and FooEntityBase (which contains the raw plumbing code)). You can thus override Foo's properties in FooEntity, since these are defined virtual. By using the Two class scenario Full/Safe (set this in your preferences as your prefered scenario before starting!), you can generate this code and preserve your own code.

  1. Is there a better way to implement rater then this 3 layer architecture.

I'd go for a middle tier, with your BL code, inside 'Manager' classes. The big advantage is that these manager classes can offer a logical API to the GUI, and can consume the BL facade tier LLBLGen Pro generates, and because you concentrate logic which belongs together, for example logic which forms a business process, the application is more maintainable because you know where what is done (which business process is implemented where), in a separated manner (which is the whole purpose of n-tier development).

Frans Bouma | Lead developer LLBLGen Pro
sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 03-Dec-2003 19:42:36   

Thanks for this Otis.

It seems to me that you are suggesting that all I need is a BL that will consist of my business rules nd business process i.e. _OrderManager _that has for example a method _PlaceOrder _that will interact with OrderEntity, OrderLinesEntity and InventoryEntity generated by LLBL Pro.

Having established this, I have generated the code based on the 2 class template. It seems to me that for every table on the database, there are 2 classes; Base class and a 'entity' class.

In order to avoid redefining properties in my BL, I was hoping to 'inherit' then from the EntityBase Classes. However a class can only inherit once. Could you suggest a better way?

Thanks is advance.

Regards. SP

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 04-Dec-2003 01:25:29   

Ah Otis...just seen the example and that helps me a lot.

Thanks anyway.

Regards. SP