Distinct seperation of GUI from the rest of the model

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 03-Apr-2009 22:45:29   

Hi, i am using self servicing for a web project and have my business layer (BL) for all kinds of data access. i never call the entity properties or methods on gui. there is always the BL in between. The question is; is there a way to proihibit using entity methods on the GUI layer? All create, edit, modify, delete actions are taken care of in BL but one can easily change it on GUI by creating an entity, setting up its properties and calling the built in methods. Is there a way to make sure this wont happen?

thank you -shane

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 04-Apr-2009 10:50:58   

we designed adapter for precisely that situation: persistence is separated from the entity classes. Selfservicing doesn't offer this, so you have to be careful what you're doing, especially with lazy loading.

Frans Bouma | Lead developer LLBLGen Pro
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 04-Apr-2009 14:35:00   

so can i not do this on gui side if Adapter is used?:

CustomerEntity customer = new CustomerEntity();

customer.CustomerID = "FOO"; customer.CompanyName = "Foo Inc."; customer.Country = "USA";

DataAccessAdapter adapter = new DataAccessAdapter(); adapter.SaveEntity(customer, true);

i dont think i get this part. As long as i have a reference to both projects Adapter creates, isnt it possible to use the code above in GUI also? what is stopping me?

thank you -shane

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 10-Apr-2009 20:40:26   

e106199 wrote:

what is stopping me?

Good practice? No one is stopping you to do such things, the difference is that with the adapter you have an option not to do it.

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 10-Apr-2009 20:55:23   

To prevent this - All you really need to do is make sure your main web project does not have a project reference to the Adapter project.

Ryan

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 10-Apr-2009 23:07:42   

You could also use dependency injection to get an IDataAccessAdapter of your choosing. We are happily targetting both Oracle and SQL Server with the exact same GUI codebase using this strategy.

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 10-Apr-2009 23:22:05   

Nice, Seth!