Simple Exercise: Populate Drop-Down List from Authors in a Database

Posts   
1  /  2
 
    
Dave avatar
Dave
User
Posts: 48
Joined: 28-Jan-2004
# Posted on: 10-Jun-2004 20:00:55   

I appreciate all the input from Matt, Wayne, Bert, Fishy, and everyone else.

Interfaces appear overkill in a 3-tier web applications that quite frankly doesn't change often enough to warrant that level of abstraction. I have yet to come across a problem with referencing business objects in the code-behind of my web pages and doesn't look like anyone else has either. This is good news, because I don't need to change my Codesmith templates simple_smile

My apologies, Wayne, if I sounded like I didn't want someone to critique my code, because that is exactly what I wanted. Being an independent developer working from home, I don't get the chance to share code and information with other developers as well as learn from them at the workplace. This forum is my chance to do that.

Thanks for keeping me grounded...

Posts: 497
Joined: 08-Apr-2004
# Posted on: 10-Jun-2004 20:58:38   

wayne wrote:

I might be wrong but as far as i know is it impossible to put code in a Interface. Interfaces are purely a representation of methods, events and proeprties that is suppose to be implemented by classes with non common anchestors or classes with common ancestors but with non common functionality wanting to have common functionality implementation.

Yep,. interfaces cannot contain code, just "contracts". But the SiteManager is not an interface - I assumed it was the "BL" - Dave?

Posts: 497
Joined: 08-Apr-2004
# Posted on: 10-Jun-2004 21:07:41   

fishy, I thought you always worked with entitycollections in your pl, or did I get that wrong?

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 10-Jun-2004 21:18:34   

MattWoberts wrote:

fishy, I thought you always worked with entitycollections in your pl, or did I get that wrong?

If I need to combine (de-normalize) multiple tables (EntityCollections) I will create an arraylist in the bl to be passed up to my pl.

Most of the time I can get away with just EntityCollections.

Posts: 497
Joined: 08-Apr-2004
# Posted on: 10-Jun-2004 21:21:19   

Hey Dave,

For a really good use of interfaces, see DevilDogs post here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=834

About halfway down, he demonstrates a sample app using interfaces (ISeason) which is implemenetd in a class (Season). In his sample using interfaces gets no more seperation than using his season class, but a cool benefit he has as a result is that if he wants classes that aren't specific to an entity, he can create them that implement multiple entities (his example was a class representing a reservation).

Just thought you might be interested in that...

Posts: 497
Joined: 08-Apr-2004
# Posted on: 10-Jun-2004 21:22:42   

Fishy wrote:

If I need to combine (de-normalize) multiple tables (EntityCollections) I will create an arraylist in the bl to be passed up to my pl.

Most of the time I can get away with just EntityCollections.

An arrayList of what, custom entities (classes) ? Just curious... wink

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 10-Jun-2004 21:34:21   

MattWoberts wrote:

Fishy wrote:

If I need to combine (de-normalize) multiple tables (EntityCollections) I will create an arraylist in the bl to be passed up to my pl.

Most of the time I can get away with just EntityCollections.

An arrayList of what, custom entities (classes) ? Just curious... wink

Yes, Classes. I tried using Structs but for some reason they don't bind disappointed

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 10-Jun-2004 21:36:17   

Hi Matt

Still curiouse...what are you using adapter or self serv...?

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 10-Jun-2004 21:55:34   

Fran's has been noticiably quiet wink

No Otis interuptis?

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 10-Jun-2004 22:03:41   

Otis has more important things to do at the momment like add more features and doing documentation. stuck_out_tongue_winking_eye

You know how all programmers enjoy documentation - don't youwink stuck_out_tongue_winking_eye

I also think that he might want to stay neutral in the Architecture conversations - Remember his imput carries alot of weight.simple_smile - There is so many different ways to do N-Tier design.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 10-Jun-2004 22:12:16   

Fishy wrote:

Fran's has been noticiably quiet wink

No Otis interuptis?

Heh simple_smile This forum is good for expressing views on topics without having me jumping in all the time. I jump in from time to time, don't worry simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Dave avatar
Dave
User
Posts: 48
Joined: 28-Jan-2004
# Posted on: 10-Jun-2004 22:24:29   

MattWoberts wrote:

wayne wrote:

I might be wrong but as far as i know is it impossible to put code in a Interface. Interfaces are purely a representation of methods, events and proeprties that is suppose to be implemented by classes with non common anchestors or classes with common ancestors but with non common functionality wanting to have common functionality implementation.

Yep,. interfaces cannot contain code, just "contracts". But the SiteManager is not an interface - I assumed it was the "BL" - Dave?

It sits in the business layer and provides a level of abstraction. I may have a manager type class in my web applications that oversee the dishing out of important business objects. Sometimes I don't want the client to create the business objects directly, because I may change them or may not know which one I will be using at that time.

The example I previously gave was contrived. A better example may be my e-commerce framework where I have a StoreManager class. It sits in the business layer. If a page (presentation layer) on the website needs the product catalog service (business object), he doesn't create it directly, he asks the store manager.

IProductCatalog catalog = StoreManager.GetProductCatalog();

Same thing with the shopping cart. If a page on the website needs the shopping cart, it has to ask the StoreManager.

IShoppingCart cart = StoreManager.GetShoppingCart();

The presentation layer has to interact with the product catalog and shopping cart through the public interface.

Inside those StoreManager methods, like GetShoppingCart(), I am running some business logic (Wayne may suspect differently simple_smile ) trying to figure out which class to create and return as well as possibly populating ctor parameters that the presentation layer does not need to know about. Like the Abstract Factory design pattern I guess.

However, the nice thing is that I don't have to change my presentation layer (pages) if ShoppingCartBasic is returned instead of ShoppingCartPro. I only care about the service contract - IShoppingCart.

I also do this same interface stuff with credit card processing and shipping. Some customers choose online credit card processing and some don't. Or perhaps the payment gateway is down. You decide which class to return inside StoreManager.GetCreditCardProcessor() based on some parameters separate from the user interface.

I am sure Frans could show me the err of my ways, but it has worked out fairly well. Hope this helps simple_smile

Dave avatar
Dave
User
Posts: 48
Joined: 28-Jan-2004
# Posted on: 10-Jun-2004 22:26:43   

MattWoberts wrote:

Hey Dave,

For a really good use of interfaces, see DevilDogs post here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=834

About halfway down, he demonstrates a sample app using interfaces (ISeason) which is implemenetd in a class (Season). In his sample using interfaces gets no more seperation than using his season class, but a cool benefit he has as a result is that if he wants classes that aren't specific to an entity, he can create them that implement multiple entities (his example was a class representing a reservation).

Just thought you might be interested in that...

Thanks, Matt. I will check out the message. I appreciate your help!

Posts: 497
Joined: 08-Apr-2004
# Posted on: 11-Jun-2004 09:21:07   

Wayne - I am using Adaptor model!

Matt.

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 11-Jun-2004 09:35:57   

Thanks - why did i think that you where using self serv..?

Posts: 497
Joined: 08-Apr-2004
# Posted on: 11-Jun-2004 10:56:01   

Dunno, guess you had a 50% chance of getting it right wink

Yeah, the reason we went that way initially was for multi-database support. Turns out I really like working with the adaptor model too wink

1  /  2