A simulation of customers buying books?
Or a piece of software to run on a till? If so, why would the customer be an actor (doesn't interact with the system)? Why would the till want to know about books (and not EAN codes etc)?
Stefan
> - Payment methods are toggled with the "T" key: Cash - simply
> open
> the till once the agent hits the "C" key. Once the till is closed,
> the receipt is printed. Electronic Payment - the agent hits the "C"
> --
> You received this message because you are subscribed to the Google
> Groups "object-composition" group.
> To post to this group, send email to object-
> compo...@googlegroups.com.
> To unsubscribe from this group, send email to object-
> composition...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/object-composition?hl=en.
My best bet for DCI is to apply all your OO skills. Roles are just objects, only you need to think of them in terms of the roles they play, not so much their actual class. (But I'm not sold to the idea that this comes naturally and is really just the mental model of the user put to work, so I'm really not the best person to ask here. My guess would be that users rather think within concepts that are closer to classes, and that class-independent roles are an additional step towards more abstraction.)
In classic OO, your design decisions are among other things guided by technical realities. Say, if you put method X in the wrong class, your design might suffer in the category of cohesion/coupling, or open/closed. In DCI, I don't see any of these consequences within a single context, so I guess you can concentrate fully on implementing as truthful to your mental model as you want.
Also, I think role modeling will get more interesting as additional roles are added. A method-call ping-pong between roles might not be too much help compared to simpler designs. What's the problem you're trying to solve? Where in the design is your challenge? What's the easiest way to think about it? I would assume the answers are somewhere there.
Don't know if this answer is any help.
Stefan
> -----Original Message-----
> From: object-co...@googlegroups.com [mailto:object-
> compo...@googlegroups.com] On Behalf Of Ant Kutschera
> Thanks for the tip that a customer is not an actor.
Why not?
> Roles are just objects,
Well, not in DCI, not in UML, not in English. Where is a role an object?
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn. 5A http://folk.uio.no/trygver/
N-0378 Oslo Tel: (+47) 22 49 57 27
Norway
Actors interact with the system, so what is an actor and what is not depends on your system boundaries. A business use case would include the customer, this system use case does not because the customer only interacts with the employee (an actor), not the system (till).
At least that's what I always thought.
http://practicalanalyst.com/2008/05/21/quick-tip-to-help-identify-use-case-actors/
Stefan
Of course, it is played by an object. But thinking about which role gets a method is not so much different from thinking which object should get it, is it?
Let's look at how the system evolves. A typical situation is that you identify the main use cases and design an object model around them with the help of domain experts (what the system is). Then you implement more and more use cases on this model (what the system does), and they evolve together, incrementally.
Now one difference in DCI is that the use case is implemented in its own module, with all the behavior isolated from the objects. But we still need objects to play these roles, so we cannot look at it isolated. There need to be objects (or systems of objects) in the object model that can play these roles.
(And of course roles can serve as an additional abstraction, they do not necessarily depend on concrete or abstract classes. They do have structural requirements though.)
My conclusion is that we can fully exploit our OO experience when modeling roles and role methods within a context, and any other mindset could possibly be misleading (e.g. SOA). There are differences, some additional things to consider, maybe some to unlearn, but it's a good starting point.
Stefan
Do you think this is an either/or decision?
Even in OO, we (hopefully) tend to service-shaped interfaces within applications where they make sense.
So it won't make much of a difference whether we do SOA or OO, in any case the interface between the part that adds product prices and the part that handles the payment will end up being a service, not a collection of fine-grained objects interacting with each other.
SOA goes further because there are additional constraints (e.g. can't join simply data from different services in a query). But the seed of this thought is already in OO.
So it won't be identical, but we can try and think of services as contexts and operations as interactions. SOA stops here, DCI starts here: How do we implement a context?
Lets model the objects to support the operation, or look at the existing object model if we already have one.
Context: Credit Card Payment
Interaction: Pay
Puh. Probably just a call to a subroutine that blocks execution until payment is completed or cancelled. No luck doing role modeling here.
Next try.
Context: Till
Interaction: Price Entry
Let's assume a loop that get's keyboard/scanner input until the bill is complete. I would not model keyboard, scanner screen etc. as objects/roles, assuming there are system classes/methods to access them. It's really just a loop of readline, dispatch, process, printline.
So we're left with what? I/O. A product DB/service that gives us a price for each EAN code. A bill that accumulates all prices. I don't see anything else.
> If I knew what the roles were, I could create a DCI solution.
>
> I can guess what the roles might be, but I don't want to guess. I
> want the person who wrote the use case to tell me. Just like they
> told me what objects were involved in their model, and the potential
> actors.
Now who does what? The only active object/roles I can see here are the till itself (processing input, creating output), the bill and maybe the log.
Everything from adding/removing products/quantities to calculating sales tax is probably going to be part of the bill, partly in its core object form, partly attached as role methods.
The till has methods that dispatch line input into methods that process it. It's not a business entity, more of a controller.
But I don't see the customer arriving at this conclusion. We have to guide them there, work together.
> > Don't know if this answer is any help.
>
> To be frank, not really :-) But thank you anyway, at least you tried
> - no one else has!
Getting some flak already here for stepping out of my comfort zone. Glad you appreciate it.
> Maybe one way to identify role is to look for verbs (behaviour) in the
> use case?
>
> If I look for the verbs, they are (sort of):
>
> - Retrieve Product
> - Display results
> - Updates total and tax on screen
> - Toggle Payment type
> - Check paper
> - Create sales order
> - Create sales log entry
> - Print Receipt
>
> Assuming this is the correct approach to identifying roles, I guess I
> now have to ask myself who plays the roles, and what would the role be
> called.
Exactly. What objects are already available in my object model? Does the concept of a bill or a log already exist? Do I have to modify or extend it? Create new ones?
What is the role contract of bill? Does the role contract alone tell me that it's a bill? Then why not call it bill? Or is there a better contextual name?
Or can it be described with more abstract words, leaving the context open to other implementations? Then I should express this in the role name.
In this sample, I'd probably go for role name 'bill'.
> I had hoped that the role name would be in the use case, but
> I don't think it is. Maybe because the use case is badly written, or
> maybe because that's normal. I don't know...
>
> So players could be:
>
> - Till: retrieve product -> the role
> is a "Catalogue", or "ProductFinder"
> - Till: display results, update total/tax -> the role is a
> "Screen"
> - User: toggle payment -> the role is
> PaymentToggler (hehe, crazy!), or simply SalesAgent*
> - Till: check paper, print receipt -> the role is
> "Printer"
> - Till: create Sales order -> the role
> is , "SalesOrderCreator" or maybe accountant
> - Till: create sales log -> the role
> is "Accountant"
>
> * I identified the sales agent as an actor. Perhaps that is the
> role, and the data is a human or employee?
>
> I had hoped "Printer" would have been explicitly mentioned in the use
> case. But it isn't.
>
> Does that mean I have modified the mental model???
Maybe the mental model was just too detailed in the first place? We model with the customer, we try to speak the same language, guide them into understanding how the system works in order to get better results quicker.
Does any of this really depend on the customer understanding how the printer works? If yes (say, a complex interaction between printing and paper refills), then we should model it. If it's just a technical detail, let's keep it that. We don't model database access or window management with the customer either.
Again, might not help you a lot. Helps me to sort my own thoughts though, so thanks for starting this thread.
Stefan
I guess an important insight here is that the use case does not alwayslist the roles or role names, but it probably does list the data class
names.
His use case book is worth a read.
(Alistair worked a bit with Trygve some time back, too... :-) )
> --
> You received this message because you are subscribed to the Google Groups "object-composition" group.
> To post to this group, send email to object-co...@googlegroups.com.
> To unsubscribe from this group, send email to object-composit...@googlegroups.com.
I think it should. It's the object in the center of everything your use case does. You add items to a bill, calculate the tax and put it on the bill, and then have the customer pay the bill's total amount. There might be other useful models too, but you need some business-centric way to think of and speak about this use case in order to get the user involved in modeling.
Your use case description is extremely UI centric. That's natural, users think in terms of UI interactions. But if you want to take it all a step further and model objects and roles together with the users, you need to lead them there. The DDD blue book says it best, I think.
> So our mental models are different. We need to unify them, before we
> continue - except we won't because I already started programming ;-)
>
> I guess an important insight here is that the use case does not always
> list the roles or role names, but it probably does list the data class
> names.
It can list the roles and names if you guide the user there.
You will need to write the use case in a way that lets the users see and understand the UI interactions that are so important to them, but still be precise about what goes on with business objects. (e.g. in terms of a ubiquitous language in DDD)
The implementation will want to separate these things. Whether the UI can or should be implemented using DCI too, and how this will look, is a separate discussion. Forget what I wrote about having a read/dispatch/execute loop in a till object/role, that's UI code and should be kept separate.
> Alternatively, perhaps we should introduce some role names and then
> modify the use case to use them. That is the part I am still unsure
> about. One goal of DCI is that the code should read like the use
> case. In OO and SOA it is quite acceptable (in my experience) for use
> cases to differ from the implementation, because there is the design
> which sits between them which maps the use cases to the design.
If you want to keep them in sync, you have to either modify the use case or adjust your code to any nonsensical use case description. Few use cases will be fit to be coded literally from the start.
> Does anyone have a problem if we go back and modify the use case?
I don't. But you can work together with the user on the mental model, the ubiquitous language etc. from the start. Maybe you'll manage to get the use cases right from the start?
> And if we do, does it make using an agile process a prerequisite for
> using DCI? In say RUP or the Waterfall process, I would have
> difficulty modifying use cases when I come to do the design, because
> the use cases are completed and signed up before I am allowed to start
> the design. I have even worked in places where the sign off is a
> prerequisite for getting the design/implementation budget.
That's one of the problems with waterfalls. Requirements engineers write stuff that can't be designed. Designers and architects take the requirements and create designs that can't be implemented. Waterfall doesn't work, with or without DCI.
RUP is prescriptive and heavy, but iterative. Get sign off for baselines and go into detail later, you can always go back and improve artifacts. Think of use case analysis in RUP: you begin with an unstructured collection of textual descriptions, and then you start modeling them using extends and include relationships.
I'm more inclined towards Agile/Lean, but I don't think it's specific for DCI.
Now let me try and rephrase your use case in a way that lets us see actual business objects, roles, and interactions. I'll go with the bill object.
Assumption: your description does not go into a lot of detail about credit card payments, though that's at least as complex as the rest of the use case. I'll assume that credit card payments are handled by another system. It could also be an internal operation, but then it would most likely be a separate use case with an include-relationship from this one. Maybe not from the start, but definitely when our use cases are detailed enough to be implemented in a literal way.
Use case: Sales transaction
A sales agent enters several items into the till and then has the customer pay the amount.
Actors:
- Sales Agent (primary actor)
- Payment System (secondary actor)
- Customer (optional, could be modeled as an offstage actor if we want. Just found out that those exist.)
Basic flow:
1. for each item the customer brings
1.1 the Sales Agent scans the barcode
1.2 the till looks up the barcode in the catalog
1.3 the till adds the product name and price to the bill
1.4 salex tax is calculated
1.5 the bill's total is updated to include the new item and sales tax
1.6 the till shows this bill item and the bill's new total amount on the screen
2. the Sales Agent completes the bill by chosing a payment type
3. if the payment is cash
3.1 the Sales Agent enters the amount received
3.2 the till displays the change
3.2 the till's drawer opens and the total amount is logged as cash in the Sales Log
4. if the payment type is credit card
4.1 the amount is sent to the Payment System
4.2 the Payment System returns a transaction number
4.3 the amount is logged in the Sales Log with the transaction number
5. the till prints a receipt for the bill
6. the items on the bill get logged to the Sales Log
Alternative flows:
- barcode must be entered manually
- cancel a product (prices don't match)
- cancel the whole transaction
- payment cannot be completed
- printer runs out of paper
Now, still ignoring the UI, it's pretty easy to find roles for a DCI implementation.
Catalog
Bill
Sales Log
Should product be a role too? That's tougher. If it is, we need to create a new context whenever we retrieve a product, because it can't be bound to a context while an interaction is already running. But maybe we can take a shortcut and just pass the product around as a parameter, without role binding? It would be a methodless role anyway.
The role contract will probably include these methods:
Catalog: GetProduct
Bill: AddProduct, RemoveProduct, GetTotal
Sales Log: AddItem (description, amount) (just to make it interesting, I assume that the sales log can only log individual lines)
The only methodful role in my implementation is Sales Log. Role methods:
AddCashTransaction (bill)
AddCreditCardTransaction (bill, transactionID)
So let's create a SalesTransaction context with several operations. (Alternatively several contexts depending on whether we need product as a role. I assume we don't.)
context SalesTransaction (Catalog, Bill, SalesLog)
interaction AddProduct (barcode) {
p = Catalog.GetProduct (barcode)
Bill.AddProduct (p)
}
We could also implement this as a RoleMethod of Bill and have the interaction just invoke Bill.AddProduct(barcode), but I don't see the advantage.
interaction PayWithCreditCard {
transactionID = PaymentSystem.Pay (Bill.GetTotal())
SalesLog.AddCreditCardTransaction (Bill, transactionID)
}
role method SalesLog.AddCreditCardTransaction (bill, transactionID) {
for each item in bill
self.Log (product.Name, product.Amount)
self.Log ("Credit card payment " + transactionID, bill.GetTotal()
}
If we have a use case description that tells us what really happens to our objects, it's quite straightforward to identify and implement roles.
Are the role names good?
Bill could also be CurrentBill, but I think that goes without saying
There's only one Catalog and one Sales Log in the system, so they don't need to be qualified further.
Would we want more abstract role names? Such that the use case would not be bound to Catalogs and Bills, but more abstract concepts? Like I said before, I think that's another level of abstraction that doesn't come naturally and should only applied when necessary. I can't even think of an abstract role that fulfills the Bill contract but is not a bill.
It's quite a good sample to work on, I only wish the role methods were a bit more interesting.
Stefan
how does this use case and dci code help get away from
functional/procedural decomposition, if at all?
thanks.
> how does this use case and dci code help get away from
> functional/procedural decomposition, if at all?
By thinking about the algorithm in terms of roles, and thinking about the system structure in terms of objects, both at the same time.
Data structures aren't a bad thing.
Procedural decomposition isn't a bad thing. We all chunk algorithms into decomposed procedures. The question is: What are the procedure boundaries? Most users model them as falling along role boundaries.
There are no role boundaries in FORTRAN or Pascal.
yeah, i can grok that. if i were a master's student with free time i'd
try to do an overview paper of how people see that gray area /
spectrum / range of options / context-dependent-ness.
or google up some summaries.
http://faculty.washington.edu/jtenenbg/courses/360/f02/project/usecaseguidelines.html
> But this is a different use case, so I cannot reuse the role!
Grumble. I have run into this a number of times. We've discussed it before with an "ideological" conclusion that roles are indeed local to Contexts. There's something about that that I still find unsatisfying.
I have also worked this into my forthcoming example (it's coming... really...)
I think there is something worth pursuing here.
> yeah, i can grok that. if i were a master's student with free time i'd
> try to do an overview paper of how people see that gray area /
> spectrum / range of options / context-dependent-ness.
Just become a professor and then make it the problem of your Ph.D. and MS students :-) (I seriously wish that I could do that!)
Just a thought: if you feel a need to share roles, would that mean that your roles and contexts are too coarse-grained? I can imagine that an often used "protocol" could be factored out into its own context-and-roles set (what's the name for that btw? a design pattern? ;-) ), which would then be triggered or wired in some way so that other sets can benefit from the behavior.
> --
> You received this message because you are subscribed to the Google Groups "object-composition" group.
> To post to this group, send email to object-co...@googlegroups.com.
> To unsubscribe from this group, send email to object-composit...@googlegroups.com.
/Johan
--
To me, the simplest for of a role is just well choosed variable name for an object.
Such as:
var source = new Account();
var destination = new Account();
Above you see two Roles: source(account) and destination(account).
Usually that is not enough, but we need Roles with methods instead.
We think about use cases and algorithm in terms of roles. We have always thought. It's just DCI that finally supports that thinking.
-Risto
> We have to be careful, not to fill that sub-context
Ant, I don't understand what you mean by "sub-context".
> We have to be careful, not to fill that sub-context with lots and lots
> of similar things (hence reducing code duplication), because doing so
> pushes us in the direction of a service based solution. What I mean
> is, all the behaviour which acts on a certain type of data is found in
> one component. We could end up with this sub context being a
> CatalogueService.
Are you referring to something like RM-ODP did with their universal notion of Account, Customer, etc., independent of context?
Hi AntDo you really need to create a role just for doing lookup/query into the database? Eg : Catalogue/ProductFinder
> Just a thought: if you feel a need to share roles, would that mean that your roles and contexts are too coarse-grained?
Maybe.
I'm doing an exercise in a Manhattan version of Dijkstra's algorithm. One context implements the use case of creating the path. Another context computes the minimum distance between nodes. Both of them have a role called Map (the map of the grid), which is identical.
I feel uncomfortable merging these two contexts, which makes me lean in the direction of answering "no" to your question. What do you think?
My current thinking on this is that we're looking at this all wrong, constrained by current languages. I think that the right way might be radically different than anything we've yet talked about here. The fundamental problem is that the structure of the issue is multi-dimensional, and we tend to think in about two and a half dimensions.
--
The usual sequence for developing a use case is: user story –> user narrative –> use case. User stories are good for little more than tagging other artefacts, so we'll skip that.
Start by writing a user narrative (NOT a user story). It is just an informal story that describes, from a human perspective, around the use case. Choose names carefully as they will be hints for an actor. It should be a half page or so in length.
There are two notions of the word "role" in DCI. One is the identifier, as Risto indicates below. In the book I call those "methodless roles." They are just a name.
Names evoke a meaning in a Context. (Read that fist as a statement purely about natural language, then about programming.) Identifiers alone have no meaning, no semantics. The semantics are in methodful roles.
One might be led to believe that Risto's mail confuses the two.
It's a problem to have two copies of a substantial body of code, because the cost of coordinated update is substantial. It is not a problem to have the same methodless role name in several Contexts from the perspective of coordinated update, because the cost of such update is trivial.
On Aug 25, 2011, at 6:14 , Risto Välimäki wrote:To me, the simplest for of a role is just well choosed variable name for an object.
Such as:
var source = new Account();
var destination = new Account();Above you see two Roles: source(account) and destination(account).
Usually that is not enough, but we need Roles with methods instead.
We think about use cases and algorithm in terms of roles. We have always thought. It's just DCI that finally supports that thinking.
Huh? "var sourceaccount" itself doesn't have meaning or semantics? That's news to me. If I wanted no meaning or no semantics, I could have used "var a" instead. Which, is quite standard with for example "int i, j, k" and so on with meaningless variables without any kind of semantics.We probably have really different definitions for terms "meaning" and "semantics".
And of course it's not a problem to have the same methodless or methodful role name in several Context, because those Roles are always local to their Contexts.
You would not do that in a real-world app, so why to it in a sample?
Stefan
> --
> You received this message because you are subscribed to the Google
> Groups "object-composition" group.
> To post to this group, send email to object-
> To unsubscribe from this group, send email to object-
> composition...@googlegroups.com.
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn. 5A http://folk.uio.no/trygver/
N-0378 Oslo Tel: (+47) 22 49 57 27
Norway
On Aug 25, 11:32 am, Risto Välimäki <risto.valim...@gmail.com> wrote:> Think of these first. Do not start thinking about Views and user interfacesThe use case talks a lot about the UI. I wrote it that way, since I
> untill all your Roles, roleplayers and UC steps are defined.
think that is how James did it in his Lean Arch. book (can't quite
remember, and don't have Jims book to hand right now). I then listed
the behaviours which the system should do, as part of the use case -
perhaps not conventional, but I wanted to show the steps which the
system does. They hardly mention UI.
These things are usually in different layers (separate assemblies/packages/...). I don't see a single context span both UI and domain.
Stefan
> -----Original Message-----
> From: object-co...@googlegroups.com [mailto:object-
> compo...@googlegroups.com] On Behalf Of Ant Kutschera
> Sent: Thursday, August 25, 2011 11:48 AM
> To: object-composition
> Subject: Re: Identifying Roles
>
we could probably call it a mechanism.
Talking about specific things about UI in UC definition is usually considered Bad Idea.
Use Case definition should express the needs of users. UX and UI teams then should translate those UCs into sketch wireframes (some prefer working prototypes though, but they are expensive) and then after some iterations into polished UIs.
"Customer buys books"1. Customer finds Interesting Books (from where?, I guess from Catalog?)2. Customer adds books to Basket3. Customer pays for content of the Basket (to whom? I guess to the Till?)
> On Aug 25, 12:22 pm, "Wenig, Stefan" <stefan.we...@rubicon.eu> wrote:
>> I didn't see the code, so I might be wrong, but it seems you have a Screen role in the same context you use to handle your business logic (filling carts, calculating taxes...)
>>
>> These things are usually in different layers (separate assemblies/packages/...). I don't see a single context span both UI and domain.
>
> No, the code which responds to user inputs (call it a controller,
> although for experimentation, it is actually a role in my code), calls
> a context to do the business stuff, which modifies the data. After
> that context completes, the controller tells the UI to update itself.
It might be better to use MVC. In MVC it's not the controller's job to tell the UI to update itself. Updating the UI is the UI's decision. All that the UI needs to know is that there is a potential for change in its View, and it's the Model role's job to let the Views know that — not the Controller.
> I am not sure I would really use DCI for the view and controller.
It's been done and I liked what I saw then. Trygve, where does your example live?
> Do you mean you vote to use a role, or not?
Let me defer my answer until we get the user narrative down and some use cases developed. To me, a Catalog is a perfectly good role that is rich with many operations. It can be implemented in many ways. Sounds like a role to me.
> It's sometimes worth trying crazy things, just to see if
> they can improve the world :-)
You radical, you.
> -----Original Message-----
> From: object-co...@googlegroups.com [mailto:object-
> compo...@googlegroups.com] On Behalf Of Ant Kutschera
> Sent: Thursday, August 25, 2011 12:55 PM
> To: object-composition
> Subject: Re: Identifying Roles
>
Actors interact with the system, so what is an actor and what is not depends on your system boundaries. A business use case would include the customer, this system use case does not because the customer only interacts with the employee (an actor), not the system (till).
At least that's what I always thought.
http://practicalanalyst.com/2008/05/21/quick-tip-to-help-identify-use-case-actors/
I find the rest of your points to be right on: refreshingly poignant, in the best possible way.
On Aug 23, 2011, at 1:58 , Wenig, Stefan wrote:
>> From: James O. Coplien
>> Sent: Monday, August 22, 2011 10:30 PM
>>
>> On Aug 22, 2011, at 8:11 , Wenig, Stefan wrote:
>>
>>> Roles are just objects,
>>
>> Well, not in DCI, not in UML, not in English. Where is a role an
>> object?
>
> Of course, it is played by an object. But thinking about which role gets a method is not so much different from thinking which object should get it, is it?
>
> Let's look at how the system evolves. A typical situation is that you identify the main use cases and design an object model around them with the help of domain experts (what the system is). Then you implement more and more use cases on this model (what the system does), and they evolve together, incrementally.
>
> Now one difference in DCI is that the use case is implemented in its own module, with all the behavior isolated from the objects. But we still need objects to play these roles, so we cannot look at it isolated. There need to be objects (or systems of objects) in the object model that can play these roles.
>
> (And of course roles can serve as an additional abstraction, they do not necessarily depend on concrete or abstract classes. They do have structural requirements though.)
>
> My conclusion is that we can fully exploit our OO experience when modeling roles and role methods within a context, and any other mindset could possibly be misleading (e.g. SOA). There are differences, some additional things to consider, maybe some to unlearn, but it's a good starting point.
>
> Stefan
>
> --
> You received this message because you are subscribed to the Google Groups "object-composition" group.
> To post to this group, send email to object-co...@googlegroups.com.
> To unsubscribe from this group, send email to object-composit...@googlegroups.com.
2011/8/24 James O. Coplien <jcop...@gmail.com>Grumble. I have run into this a number of times. We've discussed it before with an "ideological" conclusion that roles are indeed local to Contexts. There's something about that that I still find unsatisfying.
On Aug 24, 2011, at 8:24 , Ant Kutschera wrote:
> But this is a different use case, so I cannot reuse the role!
I have also worked this into my forthcoming example (it's coming... really...)
I think there is something worth pursuing here.I have found, that oftentimes similar things needed in different use cases need at leas a bit customization. And if you have to write for example a Role so that it fits two different Contexts, you quite likely have to add "ifs", parameters and so on so that the clean Role code gets polluted. And when you need to change the Use Case 1 a little bit, you make just a little change to your (shared) Role, and then your Use Case 2 will accidentally blow out.For the sake of maintainability, cleaner code and even faster development, just keep your Roles local to the Context. (And yes, there are lots of other reasons to do this also.)Btw. while we obviously think in terms of Roles when we think about UCs, the fact that a Catalog is a Role doesn't mean that we could not have Catalog Data class as well. To me, Catalog doesn't sound like much of a interaction, but more like database search. So in this case the solution is quite obvious (to me, at least, you may disagree with this):1. Have a (or many, if you need to, and you may) Data class called Catalog, that has needed data abstraction methods and means of search Products (Product ids?) from the database.2. Have a Catalog Role for each UC you need Catalog. Add all your Context-related Catalog methods into those Roles. If I am right, you are mostly just asking your Data object to get Products from database.-Risto
> Didn't your Lean Architecture book have a use case that had two
> columns, one with the users perspective, and one with a more techie
> one (or at least from the point of view of what the system does)?
The columnar format is Rebecca Wirfs-Brocks. The first column is for the primary actor(s) and the second is for the system and its response.
The second column is NOT a techie perspective. It is a business perspective on the responses of the system under construction. Good use cases leave convey the business needs without constraining the technology: you don't want to over-constrain the developers.
This is a common error and misapplication of use cases, especially when developers, nerds, and CS people write them.
I googled around a bit, and it seems that Cockburn favors adding a list of stakeholders to the list of actors. The Wikipedia article calls them Off-stage Actors. All good with me. It just never really occurred to me to pack stakeholder requirements into use case descriptions, but I get the idea.
> The distinction between system and business use cases very rarely adds
> value. It usually adds confusion.
Are you saying there's artifacts in UP that are not strictly necessary for success? I'm shocked ;-)
Aren't you ever concerned that the tool Mafia will be coming after you when traceability is built into the code, and no expensive tools are required to keep track? It's similar to what MDSOC + hyperslices/use case slices/FOSD + mixin slices achieve when you suddenly structure your code base along several dimensions, one of them being the structure of your requirements. Putting an end to scattering and tangling.
http://en.wikipedia.org/wiki/Data,_Context_and_Interaction doesn't list this as an explicit goal of DCI (although #2 comes close). I'd consider including it.
> It relates more closely to
> Jacobsson's use case theory than to anything in practice. We've seen it
> useful only once: in a legal registration system, where the process is
> so large and encompasses so many bank contexts that it was useful to
> characterize business use cases for the big picture view, and system
> use cases for each business within the bank where registration was a
> small part of a larger use case. The latter was useful for developing
> the system. The business use cases really weren't useful for what we
> call Contexts in DCI: they were useful for delineating the what-the-
> system-is part of domain analysis. But to call both of these "use
> cases" just added confusion for all but the use case experts, and it
> would have maybe been better just to use the system use cases, because
> they are what drive the functional implementation.
So you'd just go for system use cases with a little stakeholder sugar on top, so it's comprehensible what purpose they are serving? Makes sense, thanks for the comment.
Stefan
> Aren't you ever concerned that the tool Mafia will be coming after you when traceability is built into the code,
Yeah, promises, promises. Idiots have been promising traceability, artificial intelligence and world peace for years. You can rarely prove it possible in particular and can always prove it to be impossible in general. I'm not holding my breath.
> Putting an end to scattering and tangling.
>
> http://en.wikipedia.org/wiki/Data,_Context_and_Interaction doesn't list this as an explicit goal of DCI (although #2 comes close). I'd consider including it.
Good thought. Please put it in the comments section on Wikipedia so we don't lose it. (Hmmm, that's kind of a recursive application of this notion...)
But try refactoring it out of the constructor, into execute — it shouldn't be a big problem.
> My point that it wasn't in any role methods. i.e. the context is
> assigning roles,
that's its job.
> and doing a lot more than just "starting the
> interaction".
Yes, such as the initializations. Anything else?
And the question / issue is .... ?
> And "that's the execute method which is where most of the use case
> logic should end up" does not IMHO match very well with "assign roles
> and *start the interaction*".
It is a contextual question — literally. From an architectural perspective the Roles are part of the Context, and therefore the use case logic is encapsulated in the Context.
From a low-level coding perspective there is a Context class and there are the roles within it. The Context class itself is mainly boilerplate to just kick off the interaction, while the Roles carry out the work.
So it's purely a question of English semantics as to whether you consider the Context as being the instance doing the work — a matter of scope and perspective of the conversation.
Who said there was such a things as a class Jim? :)
" CollaborationsThis has a strong taste of the DCI Context. (Also see the description of the Collaboration metaclass on page 174.)
Objects in a system typically cooperate with each other to produce the behavior of a system. The behavior is the
functionality that the system is required to implement.
A behavior of a collaboration will eventually be exhibited by a set of cooperating instances (specified by classifiers) that
communicate with each other by sending signals or invoking operations. However, to understand the mechanisms used in
a design, it may be important to describe only those aspects of these classifiers and their interactions that are involved in
accomplishing a task or a related set of tasks, projected from these classifiers. Collaborations allow us to describe only
the relevant aspects of the cooperation of a set of instances by identifying the specific roles that the instances will play.
Interfaces allow the externally observable properties of an instance to be specified without determining the classifier that
will eventually be used to specify this instance. Consequentially, the roles in a collaboration will often be typed by
interfaces and will then prescribe properties that the participating instances must exhibit, but will not determine what class
will specify the participating instances."
I hope this can help clarify a wide spread misunderstanding. The UML 1.x Collaboration is fundamentally different the DCI Context and the UML 2.x Collaboration.
To unsubscribe from this group, send email to object-composit...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/object-composition?hl=en.
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn. 5A http://folk.uio.no/trygver/
N-0378 Oslo Tel: (+47) 22 49 57 27
Norway
Neither all features nor all contents of the participating instances
nor all links between these instances are always required in a
particular collaboration. Therefore, a collaboration is often defined
in terms of roles typed by interfaces. An interface is a description
of a set of properties (externally observable features) required or
provided by an instance. An interface can be viewed as a projection of
the externally observable features of a classifier realizing the
interface. Instances of different classifiers can play a role defined
by a given interface, as long as these classifiers realize the
interface (i.e., have all the required properties). Several interfaces
may be realized by the same classifier, even in the same context, but
their features may be different subsets of the features of the
realizing classifier.
Maybe. Depends on the implementation. You can do DCI in ruby and you don't need any of this. You can do it in Java with my BehaviourInjector, and it uses interfaces. I guess the important thing for me, is that it is much easier to find roles on a collaboration diagram, than in a use case diagram. That is what I was all excited about.