moffdub | 1 Aug 01:56
Picon
Favicon

Re: Role of the Application Layer in DDD

Since HttpContext is more of a platform/technical detail, I would make
this an Infrastructure Service that is called by some Application Service.

--- In domaindrivendesign <at> yahoogroups.com, "elbandit33" <scott@...> wrote:
>
> 
> So if I am using my Domain Model and Domain Services in a web
> application can my application layer have access to the HttpContext so
> that I can store frequently used items that I want to be around for the
> length for the request?
> 
> e.g.  Below I store the Customer in the HttpContext.Current.Items
> property because many controls on the same page may access the Logged In
> Customer in the same request:
> 
> Public Shared Function getLoggedCustomer() As Model.Customer
> 
>       Dim aCustomer As Model.Customer
>       Diml CustomerID As Long = HttpContext.Current.User.Identity.Name
> 
>       If HttpContext.Current.Items.Contains("Customer") Then
>               aCustomer = CType(HttpContext.Current.Items("Customer"),
> Model.Customer)
>       Else
>               aCustomer = Model.CustomerService.getCustomer(CustomerID)
> 
>               HttpContext.Current.Items.Add("Customer", aCustomer)
>       End If
> 
>       Return aCustomer
(Continue reading)

Pascal Lindelauf | 1 Aug 09:17

Re: Role of the Application Layer in DDD

Thisis getting architecturally smelly. The way I see the logical layering is as follows:

  • At the very bottom there's your resources, like the database, external services etc.
  • On top of that sits the domain layer, which contains (1) the repositories for accessing the resources in the layer below and (2) the domain model. The domain model represents the "business model" if you like for this application. It's completely technology agnostic (core DDD principle)
  • Now you want the domain model to be accessible from the outside, e.g. by users through a user interface. You can build a user interface layer directly on top of your domain layer, but then you'll h ave all the repository-access logic and transaction logic in the user interface, which could be considered a bit of a burden on the user interface layer developers. In that case it is common to place an application layer between the user interface layer and the domain layer to make life easy for the UI developer. But what is crucial is that UI-specific concepts remain the UI layer and *not* in the application layer. HttpContext is a web concept (so specific to the UI you chose) and is therefore not a concept you would want to be aware of in your application layer. Think of it this way: you should actually be able to switch over to a completely different UI technology (e.g. windows forms app or some voice-controlled interface) while still using the exact same application layer.

So in case of moffdub's example: I wouldn't want an Application Service (assuming you mean a service in the application layer) to be dependent on an infrastructure service. Instead, have the UI layer extract all the data from the HttpContext and use that as input to the application layer services.

Pascal


--- In domaindrivendesign <at> yahoogroups.com, "moffdub" <moffdub <at> ...> wrote:
>
> Since HttpContext is more of a platform/technical detail, I would make
> this an Infrastructure Service that is called by some Application Service.
>
> --- In domaindrivendesign <at> yahoogroups.com, "elbandit33" scott <at> wrote:
> >
> >
> > So if I am using my Domain Model and Domain Services in a web
> > application can my application layer have access to the HttpContext so
> > that I can store frequently used items that I want to be around for the
> > length for the request?
> >
> > e.g. Below I store the Customer in the HttpContext.Current.Items
> > property because many controls on the same page may access the Logged In
> > Customer in the same request:
> >
> > Public Shared Function getLoggedCustomer() As Mode l.Customer
> >
> > Dim aCustomer As Model.Customer
> > Diml CustomerID As Long = HttpContext.Current.User.Identity.Name
> >
> > If HttpContext.Current.Items.Contains("Customer") Then
> > aCustomer = CType(HttpContext.Current.Items("Customer"),
> > Model.Customer)
> > Else
> > aCustomer = Model.CustomerService.getCustomer(CustomerID)
> >
> > HttpContext.Current.Items.Add("Customer", aCustomer)
> > End If
> >
> > Return aCustomer
> >
> > End Function
> >
> > Would this be a correct use of the Application Layer? Or should I
> > delegate the work of storing the Customer object in some sort of web
> > infrastructure layer?
> >
> > Thanks for your help
> > Scott
> >
> > --- In domaindrivendesign <at> yahoogroups.com, John Roth <JohnRoth1 <at> >
> > wrote:
> > >
> > > Yes. In fact, the definition in the DDD book simply
> > > echos the definition of the Application Layer used
> > > by a number of other authors.
> > >
> > > Distinguishing between the two layers is not easy
> > > unless you have two or more _different_
> > > application layers that both use the same domain
> > > layer for different purposes.
> > >
> > > John Roth
> &g t; >
> > >
> > >
> > > ----- Original Message -----
> > > From: "elbandit33" scott <at>
> > > To: domaindrivendesign <at> yahoogroups.com
> > > Sent: Wednesday, July 30, 2008 8:59 AM
> > > Subject: [domaindrivendesign] Role of the Application Layer in DDD
> > >
> > >
> > > From the DDD Quickly definition of the Application Layer it states:
> > >
> > > "This is a thin layer which coordinates the application
> > > activity. It does not contain business logic. It does not
> > > hold the state of the business objects, but it can hold
> > > the state of an application task progress."
> > >
> > > Fo r an E-Commerce type application would the Application Layer have
> > > methods similar to these below:
> > >
> > >
> > > Public Shared SubPlaceOrder(BasketID as String)
> > >
> > > ' Call domain service
> > > Dim aBasket as Basket = BasketService.GetBasket(BasketID )
> > >
> > > Dim anOrder as Order = OrderService.CreateOrder(aBasket)
> > >
> > > ' Call infrastructure service
> > > infrastructure.sendOrderConfirmationEmail(anOrder)
> > >
> > > End Sub
> > >
> > > Public Shared Function getProductsByCategory(ID as integer) as List
> > > (Of Products)
> > >
> > > R eturn ProductService.getProductsByCategory(ID)
> > >
> > > End Function
> > >
> > > Thanks
> > > Scott
> > >
> >
>
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
elbandit33 | 1 Aug 10:03
Picon
Gravatar

Re: Role of the Application Layer in DDD

Of course yes, so something like this would be more ideal:~

' Application Layer
Public Shared Function getCustomer(ByVal CustomerID As Long) As Model.Customer
           ' This then calls the Domain Service
     &nbsp ;     Return Model.CustomerService.getCustomer(CustomerID)
End Function

' Infrastructure.Web.UI
Public Shared Function getLoggedCustomer() As Model.Customer

       Dim aCustomer As Model.Customer
       Dim CustomerID As Long = HttpContext.Current.User.Identity.Name

       If HttpContext.Current.Items.Contains("Customer") Then
                   aCustomer = CType(HttpContext.Current.Items("Customer"), Model.Customer)
       Else
                   ' C alls the application layer. The Application Layer is a thin layer that defines the API of the application
                   aCustomer = Application.AppCustomerService.getCustomer(CustomerID)
                   HttpContext.Current.Items.Add("Customer", aCustomer)
       End If

       Return aCustomer

End Function

This then satisfys the definition of the application layer :

"This is a thin layer which coordinates the application
activity. It does not contain business logic. It does not
hold the state of the business objects, but it can hold
the state of an application task progress."

If my application ever had the requirement to log all access to the Customer files then I could amend my Application layer o something like:

' Application Layer
Public Shared Function getCustomer(ByVal CustomerID As Long) As Model.Customer

       ' Log the request
       infrastructure.logRequest(String.Format("Customer: {0}", CustomerID))

       '  Calls the Domain Service
       Return Model.CustomerService.getCustomer(CustomerID)
End Function

The Application would then be unaware of any UI and so I could use a windows form.

Thanks I have just got to the Ah-ha moment (not the popular 80's group).

Scott

--- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf" <pascal <at> ...> wrote:
>
>
> Thisis getting architecturally smelly. The way I see the logical
> layering is as follows:
>
> * At the very bottom there's your resources, like the
> database, external services etc.
> * On top of that sits the domain layer, which contains (1) the
> repositories for accessing the resources in the layer below and (2)
> the domain model. The domain model represents the "business
> model" if you like for this application. It's completely
&g t; technology agnostic (core DDD principle)
> * Now you want the domain model to be accessible from the
> outside, e.g. by users through a user interface. You can build a
> user interface layer directly on top of your domain layer, but then
> you'll have all the repository-access logic and transaction
> logic in the user interface, which could be considered a bit of a
> burden on the user interface layer developers. In that case it is
> common to place an application layer between the user interface layer
> and the domain layer to make life easy for the UI developer. But
> what is crucial is that UI-specific concepts remain the UI layer and
> *not* in the application layer. HttpContext is a web concept (so
> specific to t he UI you chose) and is therefore not a concept you
> would want to be aware of in your application layer. Think of it
> this way: you should actually be able to switch over to a completely
> different UI technology (e.g. windows forms app or some
> voice-controlled interface) while still using the exact same
> application layer.
>
> So in case of moffdub's example: I wouldn't want an Application
> Service (assuming you mean a service in the application layer) to be
> dependent on an infrastructure service. Instead, have the UI layer
> extract all the data from the HttpContext and use that as input to the
> application layer services.
>
> Pascal
>
>
> --- In domaindrivendesign <at> yahoogroups .com, "moffdub" moffdub <at>
> wrote:
> >
> > Since HttpContext is more of a platform/technical detail, I would make
> > this an Infrastructure Service that is called by some Application
> Service.
> >
> > --- In domaindrivendesign <at> yahoogroups.com, "elbandit33" scott <at> wrote:
> > >
> > >
> > > So if I am using my Domain Model and Domain Services in a web
> > > application can my application layer have access to the HttpContext
> so
> > > that I can store frequently used items that I want to be around for
> the
> > > length for the request?
> > >
> > > e.g. Below I store the Customer in the HttpContext.Current.Items
> > &g t; property because many controls on the same page may access the
> Logged In
> > > Customer in the same request:
> > >
> > > Public Shared Function getLoggedCustomer() As Model.Customer
> > >
> > > Dim aCustomer As Model.Customer
> > > Diml CustomerID As Long =
> HttpContext.Current.User.Identity.Name
> > >
> > > If HttpContext.Current.Items.Contains("Customer") Then
> > > aCustomer =
> CType(HttpContext.Current.Items("Customer"),
> > > Model.Customer)
> > > Else
> > > aCustomer =
> Model.CustomerService.getCustomer(CustomerID)
> > >
> > > HttpContext.Current.Items.Add("Customer", aCustomer)
&gt ; > > End If
> > >
> > > Return aCustomer
> > >
> > > End Function
> > >
> > > Would this be a correct use of the Application Layer? Or should I
> > > delegate the work of storing the Customer object in some sort of web
> > > infrastructure layer?
> > >
> > > Thanks for your help
> > > Scott
> > >
> > > --- In domaindrivendesign <at> yahoogroups.com, John Roth <JohnRoth1 <at> >
> > > wrote:
> > > >
> > > > Yes. In fact, the definition in the DDD book simply
> > > > echos the definition of the Application Layer used
> > > > by a number of other authors.
> & gt; > >
> > > > Distinguishing between the two layers is not easy
> > > > unless you have two or more _different_
> > > > application layers that both use the same domain
> > > > layer for different purposes.
> > > >
> > > > John Roth
> > > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "elbandit33" scott <at>
> > > > To: domaindrivendesign <at> yahoogroups.com
> > > > Sent: Wednesday, July 30, 2008 8:59 AM
> > > > Subject: [domaindrivendesign] Role of the Application Layer in DDD
> > > >
> > > >
> > > > From the DDD Q uickly definition of the Application Layer it
> states:
> > > >
> > > > "This is a thin layer which coordinates the application
> > > > activity. It does not contain business logic. It does not
> > > > hold the state of the business objects, but it can hold
> > > > the state of an application task progress."
> > > >
> > > > For an E-Commerce type application would the Application Layer
> have
> > > > methods similar to these below:
> > > >
> > > >
> > > > Public Shared SubPlaceOrder(BasketID as String)
> > > >
> > > > ' Call domain service
> > > > Dim aBasket as Basket = BasketService.GetBasket(BasketID )
> > > >
> > > > Dim anOrder as Order = OrderService.CreateOrder(aBasket)
> > > >
> > > > ' Call infrastructure service
> > > > infrastructure.sendOrderConfirmationEmail(anOrder)
> > > >
> > > > End Sub
> > > >
> > > > Public Shared Function getProductsByCategory(ID as integer) as
> List
> > > > (Of Products)
> > > >
> > > > Return ProductService.getProductsByCategory(ID)
> > > >
> > > > End Function
> > > >
> > > > Thanks
> > > > Scott
> > > >
> > >
> >
&gt ;

__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Pascal Lindelauf | 1 Aug 11:05

Re: Role of the Application Layer in DDD

There you go. That's indeed a far better separation of concerns.

 

One last thing: I would expect the getCustomer on the application layer to actually grab the customer from the CustomerRepository: I wouldn't expect another service-thingie; I wouldn't know what you would put in there in addition to what's already in the repository and the application layer itself.

 

Pascal.

 

P.S. Actually, having an A-ha moment which *is* referring to that popular 80's group isn't all that bad either. Now where did I store "Take on me.mp3"? ;)


--- In domaindrivendesign <at> yahoogroups.com, "elbandit33" <scott <at> ...> wrote:
>
>
> Of course yes, so something like this would be more ideal:~
>
> ' Application Layer
> Public Shared Function getCustomer(ByVal CustomerID As Long) As
> Model.Customer
> ' This then calls the Domain Service
> Return Model.CustomerService.getCustomer(CustomerID)
> End Function
>
> ' Infrastructure.Web.UI
> Public Shared Function getLoggedCustomer() As Model.Customer
>
> Dim aCustomer As Model.Customer
> Dim CustomerID As Long = HttpContext.Current.User.Identity.Name
>
> If HttpContext.Current.Items.Contains("Customer") Then
> aCustomer =
> CType(HttpContext.Current.Items("Customer"), Model.Customer)
> Else
> ' Calls the application layer. The Application Layer
> is a thin layer that defines the API of the application
> aCustomer =
> Application.AppCustomerService.getCustomer(CustomerID)
> HttpContext.Current.Items.Add("Customer", aCustomer)
> End If
>
> Return aCustomer
>
> End Function
>
> This then satisfys the definition of the application layer :
>
> "This is a thin layer which coordinates the application
> activity. It does not contain business logic. It does not
> hold the state of the business objects, but it can hold
> the state of an application task progress."
>
> If my application ever had the requirement to log all access to the
> Customer files then I could amend my Application layer o something like:
>
> ' Application Layer
> Public Shared Function getCustomer(ByVal CustomerID As Long) As
> Model.Customer
>
> ' Log the request
> infrastructure.logRequest(String.Format("Customer: {0}",
> CustomerID))
>
> ' Calls the Domain Service
> Return Model.CustomerService.getCustomer(CustomerID)
> End Function
>
> The Application would then be unaware of any UI and so I could use a
> windows form.
>
> Thanks I have just got to the Ah-ha moment (not the popular 80's group).
>
> Scott
>
> --- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf"
> pascal <at> wrote:
> >
> >
> > Thisis getting architecturally smelly. The way I see the logical
> > layering is as follows:
> >
> > * At the very bottom there's your resources, like the
> > database, external services etc.
> > * On top of that sits the domain layer, which contains (1) the
> > repositories for accessing the resources in the layer below and (2)
> > the domain model. The domain model represents the "business
> > model" if you like for this application. It's completely
> > technology agnostic (core DDD principle)
&g t; > * Now you want the domain model to be accessible from the
> > outside, e.g. by users through a user interface. You can build a
> > user interface layer directly on top of your domain layer, but then
> > you'll have all the repository-access logic and transaction
> > logic in the user interface, which could be considered a bit of a
> > burden on the user interface layer developers. In that case it is
> > common to place an application layer between the user interface layer
> > and the domain layer to make life easy for the UI developer. But
> > what is crucial is that UI-specific concepts remain the UI layer and
> > *not* in the application layer. HttpContext is a web concept (so
> > specific to the UI you chose) and is therefore not a concept you
> > would want to be aware of in your application layer. Think of it
> > this way: you should actually be able to switch over to a completely
> > different UI technology (e.g. windows forms app or some
> > voice-controlled interface) while still using the exact same
> > application layer.
> >
> > So in case of moffdub's example: I wouldn't want an Application
> > Service (assuming you mean a service in the application layer) to be
> > dependent on an infrastructure service. Instead, have the UI layer
> > extract all the data from the HttpContext and use that as input to the
> > application layer services.
> >
> > Pas cal
> >
> >
> > --- In domaindrivendesign <at> yahoogroups.com, "moffdub" moffdub <at>
> > wrote:
> > >
> > > Since HttpContext is more of a platform/technical detail, I would
> make
> > > this an Infrastructure Service that is called by some Application
> > Service.
> > >
> > > --- In domaindrivendesign <at> yahoogroups.com, "elbandit33" scott <at>
> wrote:
> > > >
> > > >
> > > > So if I am using my Domain Model and Domain Services in a web
> > > > application can my application layer have access to the
> HttpContext
> > so
> > > > that I can store frequently used items that I want to be around
&g t; for
> > the
> > > > length for the request?
> > > >
> > > > e.g. Below I store the Customer in the HttpContext.Current.Items
> > > > property because many controls on the same page may access the
> > Logged In
> > > > Customer in the same request:
> > > >
> > > > Public Shared Function getLoggedCustomer() As Model.Customer
> > > >
> > > > Dim aCustomer As Model.Customer
> > > > Diml CustomerID As Long =
> > HttpContext.Current.User.Identity.Name
> > > >
> > > > If HttpContext.Current.Items.Contains("Customer") Then
> > > > aCustomer =
> > CType(HttpContext.C urrent.Items("Customer"),
> > > > Model.Customer)
> > > > Else
> > > > aCustomer =
> > Model.CustomerService.getCustomer(CustomerID)
> > > >
> > > > HttpContext.Current.Items.Add("Customer", aCustomer)
> > > > End If
> > > >
> > > > Return aCustomer
> > > >
> > > > End Function
> > > >
> > > > Would this be a correct use of the Application Layer? Or should I
> > > > delegate the work of storing the Customer object in some sort of
> web
> > > > infrastructure layer?
> > > >
> > > > Thanks for your help
> > > > Scott
> > > >
> > > > --- In domaindrivendesign <at> yahoogroups.com, John Roth <JohnRoth1 <at> >
> > > > wrote:
> > > > >
> > > > > Yes. In fact, the definition in the DDD book simply
> > > > > echos the definition of the Application Layer used
> > > > > by a number of other authors.
> > > > >
> > > > > Distinguishing between the two layers is not easy
> > > > > unless you have two or more _different_
> > > > > application layers that both use the same domain
> > > > > layer for different purposes.
> > > > >
> > > > > John Roth
> > > > >
> & gt; > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "elbandit33" scott <at>
> > > > > To: domaindrivendesign <at> yahoogroups.com
> > > > > Sent: Wednesday, July 30, 2008 8:59 AM
> > > > > Subject: [domaindrivendesign] Role of the Application Layer in
> DDD
> > > > >
> > > > >
> > > > > From the DDD Quickly definition of the Application Layer it
> > states:
> > > > >
> > > > > "This is a thin layer which coordinates the application
> > > > > activity. It does not contain business logic. It does not
> > > > > hold the sta te of the business objects, but it can hold
> > > > > the state of an application task progress."
> > > > >
> > > > > For an E-Commerce type application would the Application Layer
> > have
> > > > > methods similar to these below:
> > > > >
> > > > >
> > > > > Public Shared SubPlaceOrder(BasketID as String)
> > > > >
> > > > > ' Call domain service
> > > > > Dim aBasket as Basket = BasketService.GetBasket(BasketID )
> > > > >
> > > > > Dim anOrder as Order = OrderService.CreateOrder(aBasket)
> > > > >
> > > > > ' Call infrastructu re service
> > > > > infrastructure.sendOrderConfirmationEmail(anOrder)
> > > > >
> > > > > End Sub
> > > > >
> > > > > Public Shared Function getProductsByCategory(ID as integer) as
> > List
> > > > > (Of Products)
> > > > >
> > > > > Return ProductService.getProductsByCategory(ID)
> > > > >
> > > > > End Function
> > > > >
> > > > > Thanks
> > > > > Scott
> > > > >
> > > >
> > >
> >
>
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
moffdub | 1 Aug 13:10
Picon
Favicon

Re: Role of the Application Layer in DDD

--- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf"
<pascal@...> wrote:
>
> But
> what is     crucial is that UI-specific concepts remain the UI layer and
> *not* in the     application layer. HttpContext is a web concept (so
> specific to the UI you     chose) and is therefore not a concept you
> would want to be aware of in     your application layer. Think of it
> this way: you should actually be able     to switch over to a completely
> different UI technology (e.g. windows forms     app or some
> voice-controlled interface) while still using the exact same    
> application layer.
> 
> So in case of moffdub's example: I wouldn't want an Application
> Service (assuming you mean a service in the application layer) to be
> dependent on an infrastructure service. Instead, have the UI layer
> extract all the data from the HttpContext and use that as input to the
> application layer services.

Hang on a second. What I meant was you have an infrastructure service
that is responsible for caching, say, DataCacheService, and the app
layer is dependent on that interface. Caching definitely sounds to me
like a technical detail and not a "job of the application." This way,
you are still able to switch to an entirely different UI.

The fact that the caching mechanism happens to be an HttpContext in
this case is a happy coincidence. Both the UI and the DataCacheService
happen to use the same framwork for their work. If you switched to
Windows Forms, you'd need to implement DataCacheService differently. 

The original post I replied to made it seem like the problem was not
tossing data to and from the UI. Indeed, you still want to extract
input from the UI before handing it to an application service that
processes it; this includes any objects you then determine you want to
cache. But having an application service have explicit knowledge that
there is an HttpContext to work with for caching seems like a smell to
me as well.

------------------------------------

elbandit33 | 1 Aug 16:09
Picon
Gravatar

Re: Role of the Application Layer in DDD

Yes all my CustomerService in the Domain layer is doing is simply calling the Customer Repository FindByID method. So I could change the Application Layer Service to:

' Application Layer

' I don't want to have to create the Repository on every call so I store it as a static variable
Private Shared _CustomerRepository As ICustomerRepository = Infrastructure.GetRepository(Repository.Customer)

Public Sh ared Function getCustomer(ByVal CustomerID As Long) As Model.Customer

            ' Call the repository directly
            Return _CustomerRepository.findByID(CustomerID)

End Function



--- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf" <pascal <at> ...> wrote:
>
>
> There you go. That's indeed a far better separation of concerns.
>
>
>
> One last thing: I would expect the getCustomer on the application layer
> to actually grab the customer from the CustomerRepository: I
> wouldn't expect another service-thingie; I wouldn't know what
> you would put in there in addition to what's already in the
> repository and the application layer itself.
>
>
>
> Pascal.
>
>
>
> P.S. Actually, having an A-ha moment whic h *is* referring to that
> popular 80's group isn't all that bad either. Now where did I
> store "Take on me.mp3"? ;)
>

__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Pascal Lindelauf | 1 Aug 16:20

Re: Role of the Application Layer in DDD

Indeed, that's it!

Pascal.

--- In domaindrivendesign <at> yahoogroups.com, "elbandit33" <scott@...>
wrote:
>
>
> Yes all my CustomerService in the Domain layer is doing is simply
> calling the Customer Repository FindByID method. So I could change the
> Application Layer Service to:
>
> ' Application Layer
>
> ' I don't want to have to create the Repository on every call so I
store
> it as a static variable
> Private Shared _CustomerRepository As ICustomerRepository =
> Infrastructure.GetRepository(Repository.Customer)
>
> Public Shared Function getCustomer(ByVal CustomerID As Long) As
> Model.Customer
>
>              ' Call the repository directly
>              Return _CustomerRepository.findByID(CustomerID)
>
> End Function
>
>
>
> --- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf"
> pascal@ wrote:
> >
> >
> > There you go. That's indeed a far better separation of concerns.
> >
> >
> >
> > One last thing: I would expect the getCustomer on the application
> layer
> > to actually grab the customer from the CustomerRepository: I
> > wouldn't expect another service-thingie; I wouldn't know what
> > you would put in there in addition to what's already in the
> > repository and the application layer itself.
> >
> >
> >
> > Pascal.
> >
> >
> >
> > P.S. Actually, having an A-ha moment which *is* referring to that
> > popular 80's group isn't all that bad either. Now where did I
> > store "Take on me.mp3"? ;)
> >
>

------------------------------------

Pascal Lindelauf | 1 Aug 16:23

Re: Role of the Application Layer in DDD

Agreed. That last sentence is indeed the essence.

Pascal.

--- In domaindrivendesign <at> yahoogroups.com, "moffdub" <moffdub@...>
wrote:
>
> --- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf"
> pascal@ wrote:
> >
> > But
> > what is     crucial is that UI-specific concepts remain the UI layer
and
> > *not* in the     application layer. HttpContext is a web concept (so
> > specific to the UI you     chose) and is therefore not a concept you
> > would want to be aware of in     your application layer. Think of it
> > this way: you should actually be able     to switch over to a
completely
> > different UI technology (e.g. windows forms     app or some
> > voice-controlled interface) while still using the exact same
> > application layer.
> >
> > So in case of moffdub's example: I wouldn't want an Application
> > Service (assuming you mean a service in the application layer) to be
> > dependent on an infrastructure service. Instead, have the UI layer
> > extract all the data from the HttpContext and use that as input to
the
> > application layer services.
>
> Hang on a second. What I meant was you have an infrastructure service
> that is responsible for caching, say, DataCacheService, and the app
> layer is dependent on that interface. Caching definitely sounds to me
> like a technical detail and not a "job of the application." This way,
> you are still able to switch to an entirely different UI.
>
> The fact that the caching mechanism happens to be an HttpContext in
> this case is a happy coincidence. Both the UI and the DataCacheService
> happen to use the same framwork for their work. If you switched to
> Windows Forms, you'd need to implement DataCacheService differently.
>
> The original post I replied to made it seem like the problem was not
> tossing data to and from the UI. Indeed, you still want to extract
> input from the UI before handing it to an application service that
> processes it; this includes any objects you then determine you want to
> cache. But having an application service have explicit knowledge that
> there is an HttpContext to work with for caching seems like a smell to
> me as well.
>

------------------------------------

scott | 1 Aug 16:25
Picon
Gravatar

Re: Re: Role of the Application Layer in DDD


Thanks for your help!
Scott


On Fri Aug 1 15:20 , 'Pascal Lindelauf' <pascal <at> lindelauf.com> sent:

Indeed, that's it!

Pascal.

--- In domaindrivendesign <at> yahoogroups.com, "elbandit33" <scott <at> ...>
wrote:
>
>
> Yes all my CustomerService in the Domain layer is doing is simply
> calling the Customer Repository FindByID method. So I could change the
> Application Layer Service to:
>
> ' Application Layer
>
> ' I don't want to have to create the Repository on every call so I
store
> it as a static variable
> Private Shared _CustomerRepository As ICustomerRepository =
> Infrastructure.GetRepository(Repository.Customer)
>
> Public Shared Function getCustomer(ByVal CustomerID As Long) As
> Model.Customer
>
> ' Call the repository directly
> Return _CustomerRepository.findByID(CustomerID)
>
> End Function
>
>
>
> --- In domaindrivendesign <at> yahoogroups.com, "Pascal Lindelauf"
> pascal <at> wrote:
> >
> >
> > There you go. That's indeed a far better separation of concerns.
> >
> >
> >
> > One last thing: I would expect the getCustomer on the application
> layer
> > to actually grab the customer from the CustomerRepository: I
> > wouldn't expect another service-thingie; I wouldn't know what
> > you would put in there in addition to what's already in the
> > repository and the application layer itself.
> >
> >
> >
> > Pascal.
> >
> >
> >
> > P.S. Actually, having an A-ha moment which *is* referring to that
> > popular 80's group isn't all that bad either. Now where did I
> > store "Take on me.mp3"? ;)
> >
>

__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
matthias.kampen | 1 Aug 16:42
Picon
Favicon

Do you allow that aggregates / entities get temporarily in an invalid state?

Hello,

do you allow that aggregates / entities get temporarily in an invalid
state?

If you have an entity which has several public methods that modify the
state of the object. Do you always implement such methods in a way
that the resulting state is valid? Or do you just make sure that all
entities are valid at the end of a transaction?

Do you allow the following example:

someObj = new Obj(); //Valid State

someObj.doSomething1(someArgs); // Results in invalid state
someObj.doSomething2(someOtherArgs); // State is now valid

someObj.validate(); //Checks whether state is valid (maybe called by
unitOfWork before commit)

Kind regards
Matthias

------------------------------------


Gmane