Need your advice on 'use case controller classes'

Need your advice on 'use case controller classes'

Old forum URL: forums.lhotka.net/forums/t/1749.aspx


stefan posted on Monday, November 13, 2006

Hi @ all!

Imagine a scenario that handles companies.
Each company could have 0-many branches.
Each branch would bring its own number of contact persons.

Now to the use case in question:
The user should be able to move one contact person from its branch to a fellow-branch.
This being a representative use case for many others that could be triggered from the main
'company'-form in some sort or another (buttons, contextmenu, ...).

I think I am doing well not integrating the logic for these cases inside my main BO classes
(in the example being company, companybranch, contactperson), as they would blow up.
Although all this being behavioural code...

Would you recommend using CLSA base classes for these 'use case controller'-logic?
If yes, what benefit would I get from using them, as there would be no to little persistance logic,
and which classes would be appropriate (just the CommandBaseObject ? ).

I wonder what's the best approach for organizing all that usecase-code. Thinking of the
MS-Access project I worked on for years, 'Modules' come to my mind, but wasn't that
procedural thinking...

In case all that has already been discussed here, I would appreciate some search keywords!

Thanks in advance


Stefan

JoeFallon1 replied on Monday, November 13, 2006

The new top level BO for your use case will contain Readonly properties for the other BOs you mentioned. This top level BO will be responsible for fetching the others (during the New contructor or else DP_Create or Lazy loading.)

In a recent thread it was discussed as to the best way to move data from one BO to another. Most of us prefer to create a new BO of the correct type and then pass in the "other" BO to a CopyData method which reads the values from the old BO and puts them into the new BO. This method gives you the ability to omit certain fields (GUIDs, etc.).

So I can see your top level BO having such a method.

Then when you want to move data from one to the other you call the CopyData method and pass in the original BO. If you want to delete the data in the original location you can do that in another method call if you want.

Anyway - that is the general idea.

 

Copyright (c) Marimer LLC