rajesh.51kannan | 1 Apr 13:27 2014
Picon

What is meant by domain logic and does that comes in the domain model class?



Hi,
   I'm new to DDD and I have collected some domain objects for payment gateway project. Now my task is to write domain logic for those domain objects. I can't understand, what is domain logic?.  Anyone give some illustration for domain logic and it would be very helpful for me.

Thanks,
Rajesh


__._,_.___


__,_._,___
varun.bhargava80 | 25 Mar 08:23 2014
Picon

Avoid injecting Service/Repository in an Entity



Hi Everyone,

From what I've read, this is really bad. But I have the following use case so wondering how to do this in the proper DDD way. The business rule is contrived but it is very similar to what i have in real life. I just cannot disclose the use case due to NDAs.

I have a class named Class. A class can have students in it. There is a business rule such that if a student with the same surname belongs to any current of any other class, they cannot be added to the class.

So on Class, i have a method named AddStudent. Just wondering how would the algorithm be implemented in a proper DDD sense

public class Class
{
public v oid AddStudent(Student student)
{
// Call a repository to get all the students enrolled in all classes
// If any students surname matches the surname of the student passed in, do not thing
// otherwise add the student
}
}






__._,_.___


__,_._,___
fratting | 20 Mar 01:42 2014
Picon
Picon

Application Service



In a SOA sense, a service can serve many applications (front ends).
In a DDD sense, an application (presentation layer) interacts with the application service layer to execute domain behavior.

While there's slight variation in terminology from the two perspectives the associations between application and presentation layer typically seem to align as the front-end facing layer of a software solution.

So to the question...
Is it fair to say that there can be many DDD application services standing in front of a domain model, each servicing a specific application?

If the application service itself was physically implemented as a web service is it more common to s ee a single application (web) service serve multiple application front-ends? Or Is it more common for there to be a one-to-one relationship between the application and the application (web) service?

Thinking about it I'd tend to think the Api exposed by an application service could vary depending on the needs of the specific application it services and not all that uncommon to have a one-to-one relationship (even if application service is physically a web service).

Thoughts?


__._,_.___


__,_._,___
Tom Eugelink | 12 Mar 07:09 2014

translation


I have an interesting discussion going on in my team and could use some ideas.

We are writing software for the Dutch healthcare system. Usually software written by Dutch developers
uses English identifiers, this make hiring external help much more easy. But if you use DDD and start
developing based on a Ubiquitous Language, then that will be in Dutch. Even more so, because a lot of the
concepts used in our healthcare system are typical for our healtcare system and are very hard to translate.

So I am a proponent of using Dutch identfiers; if the client calls it Squirrel it should be named Squirrel in
the software. But this is a hard sell. Are there any other non-english developers with the same problem?
And how did you fare?

Tom

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

songoko20000 | 8 Mar 02:22 2014
Picon

How to test value objects when they have dependencies?



**TL;DR**  
How do you test a value object in isolation from its dependencies without stubbing or injecting them?


----------


In Misko Hevery's blog post [To “new” or not to “new”…][1] he advocates the following (quoted from the blog post):

>  - An Injectable class can ask for other Injectables in its constructor.(Sometimes I refer to Injectables as Service Objects, but
> that term is overloaded.). Injectable can never ask for a non-Injectable (Newable) in its constructor.
>  - Newables can ask for other Newables in their constructor, but not for Injectables (Sometimes I refer to Newables as Value Object, but
> again, the term is overloaded)

Now if I have a `Quantity` value object like this:

    class Quantity{
    
    $quantity=0;
   
    public function __construct($quantity){
    $intValidator = new Zend_Validate_Int();
    if(!$intValidator->isValid($quantity)){
    throw new Exception("Quantity must be an integer.");
    }
   
    $gtValidator = new Zend_Validate_GreaterThan(0);
    if(!$gtvalidator->isValid($quantity)){
    throw new Exception("Quantity must be greater than zero.");
    }
   
    $this->quantity=$quantity;
    }
    }

My `Quantity` value object depends on at least 2 validators for its proper construction. Normally I would have injected those validators through the constructor, so that I can **stub** them during testing. 

However, according to Misko a newable shouldn't ask for injectables in its constructor. Frankly a `Quantity` object that looks like this  
`$quantity=new Quantity(1,$intValidator,$gtValidator);` looks really awkward.

Using a dependency injection framework to create a value object is even more awkward. However now my dependencies are hard coded in the `Quantity` constructor and I have no way to alter them if the business logic changes.

How do you design the value object properly for testing and adherence to the separation between injectables and newables?

Notes:

 1. This is just a very very simplified example. My real object my have serious logic in it that may use other dependencies as well.
 2. I used a PHP example just for illustration. Answers in other languages are appreciated.



__._,_.___


__,_._,___
Dariusz Lenartowicz | 7 Mar 19:39 2014
Picon

Aggregate root, factory method and entity as a result

Hi,
I'm looking for some advice.

Suppouse I have Tenant AR which can create User entity (User is not AR 
within this particular context), so code can looks like this:

     var tenantId = sessionContextService.TenantId;
     var tenant = tenantRepo.Get(tenantId);
     var user = tenant.CreateUser(username, password); // there I can 
validate invariants
     userRepo.Add(user);

To achive this User class should have public ctor:

     public User(Tenant tenant, string username, string password)

but nobody prevent me to do this:

     var tenantId = sessionContextService.TenantId;
     var tenant = tenantRepo.Get(tenantId);
     var user = new User(tenant, username, password);
     userRepo.Add(user);

How to force creation of User entity through CreateUser method on tenant 
AR?
Is it only matter of discipline or there are some solutions for that 
situations?

Best regards
Darek

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Caleb Cushing | 14 Feb 01:24 2014
Picon

getting things like loggers into the model

So I asked this question on StackOverflow and the basic answer I've
been getting comes down to using an anemic model (or at least that's
my interpretation of people saying my entities should not have
business logic)

http://stackoverflow.com/questions/21743823/cdi-injecting-services-into-jpa-managed-entities/21749132

My example uses a Setter, but that's really a side effect of me trying
to use an exceptionally stupid example so that it's easily understood.

my basic desire is to be able to have access to things like a logger
in the model, largely for debugging purposes, or to fire events that
can be then tracked by some external class.

what I'm thinking right now is

Repository {
 <at> Inject
Logger
 <at> Inject
Event
...
AggregateRoot.wireServices( Logger, Event );

and then passing it through the model

However other idea's are welcome.
-- 
Caleb Cushing

http://xenoterracide.com

Calendar:
https://www.google.com/calendar/embed?src=xenoterracide%40gmail.com&ctz=America/Chicago

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/

gbilodeau | 2 Feb 00:23 2014
Picon

Validating aggregate collections: when and whose job is it?



Hi all,

I would like to have your input on a relatively simple problem that has me looking everywere for guidelines.  Here it goes.

Let's consider a relatively simple subset of the application on which I'm working.  Aside from other considerations, this application allows users to:
- manage the inner structure of their company: head office, departments, employees, etc.
- manage the relationships their company has with external customers

If we focus on the relationship management part, we learn that a customer can be:
- registered: referring to a company already registered in the application, or
- virtual: not referring to any registered company (and basi cally a placeholder until the company actually registers)

There are two main rules that must be respected:
1. for a given company, no virtual company can be created with a given website if that website is already owned by an existing company (basically, don't create virtual customers when registered customers exist), and
2. for a given company, no two customers, virtual or registered, must own the same website

To clarify, considering two registered companies, company1 (website company1.com) and company2 (company2.com):
1. company1 cannot add a virtual customer with website company2.com, instead it must add company2 as a registered customer
2. company1 cannot add twice the virtual customer compan y3 with website company3.com

Although we could get into a discussion of which contexts exist, for the moment let's consider a single "company management" context with two aggregates: 
- Company { companyId, name, website }
- Customer { customerId, ownerCompanyId, name, website, registeredCompanyId }

There are two basic questions: when are the two above business rules validated and by whom? I see two options:

1. The rules can be verified when instantiating the Customer aggregate or when saving it to the data store. Validating at instantiation time benefits us since we know that there can never be an invalid Customer in memory. Instantiation would be performed by the Company ag gregate. That would require Company or its Company.createCustomer methods to have access reference to both a CompanyRepository and a CustomerRepository to lookup any Company or Customer by website. Introducing a dependency between Company and these repositories doesn't produce a clean and intuitive API, plus doesn't feel like a very healthy dependency.
2. The rules can be verified when saving to the data store. This would be performed by the CustomerRepository implementation. This approach removes the Company - repository dependencies, and having an invalid Customer in memory isn't really an issue.  But is validation logic really part of a Repository's responsibilities? Also, this would require the CustomerRepository.add and CustomerRepository.update method s to have a reference to a CompanyRepository to lookup any Company website. Introducing a dependency between two repositories doesn't feel right: my understanding is that a repository should only manage instances of a given aggregate regardless of its environment, but maybe this is too short-sighted.

What do you think? How do you usually model these kinds of business rules?

Thanks a bunch!
GB



__._,_.___

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

__,_._,___
Caleb Cushing | 20 Jan 17:01 2014
Picon

Repositories Global only or contextual?

So say I'm implementing a repository for a Todo app. We'll call it Tasks,

class Tasks implements Set { ... }

assume that for this a repository is just the set interface, and tasks
are just strings

for (Task t : Tasks) {
    System.out.println( t );
}

should this code iterate all of the tasks in the system? or
should/could it simply iterate the tasks of the currently
authenticated user?

If it's all tasks how should one go about getting to just the users tasks?
-- 
Caleb Cushing

http://xenoterracide.com

Calendar:
https://www.google.com/calendar/embed?src=xenoterracide%40gmail.com&ctz=America/Chicago

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

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/

steott | 10 Jan 16:23 2014
Picon

http://dddcommunity.org/ down?



Since a few days http://dddcommunity.org/ seems to be down, I cannot see anything in it. Does anybody know about the status of the site? Is it going to be online again soon?

__._,_.___

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

__,_._,___
drupalspring | 10 Jan 22:21 2014
Picon

How to differentiate a concept is domain logic or application logic ?



Domain layer encapsulates the domain logic . Application layer encapsulates  application logic . My question is that how to differentiate a concept is the domain logic or application logic ?

From what I read ,if a concept is  communicated by domain experts/users in their jobs , then that concept should be modeled and located in the domain layer . So I have the following questions :

(1) I don't think the domain expert will care about how to persist the state of a domain entity , so why repository is located in the domain layer?

(2) Most domain expert only care about how the application can help them to do their daily jobs . They care  and talk about different use cases and their flow to do that use cases in their daily job . So why the use cases and t heir flow is encapsulated in the application service which is in the application layer?

__._,_.___

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

__,_._,___

Gmane