tag:blogger.com,1999:blog-8336318365940619669.post3418458493730896767..comments2024-03-01T16:50:39.029+01:00Comments on Horsdal Consult: DCI in C#Christian Horsdalhttp://www.blogger.com/profile/07782376855026802670noreply@blogger.comBlogger38125tag:blogger.com,1999:blog-8336318365940619669.post-16449147708874381262013-03-06T09:38:43.645+01:002013-03-06T09:38:43.645+01:00This is my implementation of the DCI in C# using t...This is my implementation of the DCI in C# using the decorator pattern. What do you guys think.<br /><br />http://pastie.org/6403027Orsonhttps://www.blogger.com/profile/13498091263286678249noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-30764671410471134262012-09-25T15:01:59.908+02:002012-09-25T15:01:59.908+02:00Regarding the PS: I'm not sure I understand yo...Regarding the PS: I'm not sure I understand your question - could you maybe give an example? (and tbh i think you'd get better answer if you post to the object-composition google group).Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-79883797930375140812012-09-25T14:04:58.989+02:002012-09-25T14:04:58.989+02:00Any kind of answers can make me happy !Any kind of answers can make me happy !Abohttps://www.blogger.com/profile/16734416100094423917noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-84511525381531050762012-09-05T14:07:42.146+02:002012-09-05T14:07:42.146+02:00Thanks Christian for the answer, I'm doing my ...Thanks Christian for the answer, I'm doing my master thesis based on the DCI, Now I'm implementing an small application based on the DCI architecture, I have several places that some Property (like the Balance) is defined in the role (like TransferMoneySource) just because the role method(like transferTo)need that data, <br />I wanna see is there any possiblity (more nice looking) solution for using that that neither by down-casting nor by defining in the role ? <br /><br />*PS : having a property for getting access to data or even having the function returning a certain data is still something regarding to object not the role we just doing that because we don't wanna downcast the object!<br />Is it(in original DCI document) such that we just can operational methods that actually related to the roles is the interaction part or we can have any kind of function (like a getter for example)?Abohttps://www.blogger.com/profile/16734416100094423917noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-55833215033614407282012-09-05T13:56:37.829+02:002012-09-05T13:56:37.829+02:00This comment has been removed by the author.Abohttps://www.blogger.com/profile/16734416100094423917noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-85315117252219564242012-09-04T15:20:57.734+02:002012-09-04T15:20:57.734+02:00This comment has been removed by the author.Abohttps://www.blogger.com/profile/16734416100094423917noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-35518683779834517852012-09-04T15:12:24.202+02:002012-09-04T15:12:24.202+02:00This comment has been removed by the author.Abohttps://www.blogger.com/profile/16734416100094423917noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-81379325886120724982012-09-04T11:36:41.376+02:002012-09-04T11:36:41.376+02:00Just because "Balance" is a C# property ...Just because "Balance" is a C# property does not mean it's equal to a data field. It's just a getter, that could calculate the balance on demand or whatever you might like.<br />The Balance is on the TransferMoneySource to enable the TransferTo method to check for sufficient funds before transferring, without resorting to downcasts.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-74433092221949675632012-09-04T11:29:21.672+02:002012-09-04T11:29:21.672+02:00In the original DCI documents we are not suppose t...In the original DCI documents we are not suppose to have a data field in the roles section (such as "Balance" property).<br />And the another point is that all of the accounts have the "Balance" property, means that it is not related to a certain role.<br />What is the resaon behind having the Balance in the "TransferMoneySoruce" ? <br />Abohttps://www.blogger.com/profile/16734416100094423917noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-46583044596085331102012-04-25T09:17:13.364+02:002012-04-25T09:17:13.364+02:00@Igor: I'd either not mock out the roles, but ...@Igor: I'd either not mock out the roles, but mock out the dumb data objects, or I'd mock out the whole context. Remember roles are scoped to a particular context in DCI, so their implementation should be seen as completely hidden to code outside the context.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-71445350133485057802012-04-25T07:45:56.632+02:002012-04-25T07:45:56.632+02:00Christian, any idea on Unit Testing impact with DC...Christian, any idea on Unit Testing impact with DCI implemented as extension static method? Sure you can test them individually. But how to intercept them in mocks and stubs if you are testing the place where Role is used?Anonymoushttps://www.blogger.com/profile/05169820922360650598noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-1296663215296835952012-04-13T14:36:09.889+02:002012-04-13T14:36:09.889+02:00@Fritz: The balance between what to put into the c...@Fritz: The balance between what to put into the context and what to put into roles is one to some extent one of personal taste IMO. I think what you suggest makes sense.<br />In this post I chose to keep the context small and focused only on setting up the context (pun intended), and then let the roles implement the business logic. <br />But since roles should be scoped to a single context, this a local design decision that depends on how the code for a particular use case turns out best.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-43043365833890012232012-04-13T14:26:59.755+02:002012-04-13T14:26:59.755+02:00I admit I am new to DCI, but I think your implemen...I admit I am new to DCI, but I think your implementation does the right thing in the wrong place. As far as I am concerned the TransferMoneySourceTrait in not necessary at all - it's code belongs directly into the TransferMoneyContext.Execute (as it wont be used anywhere else).<br />Traits are used to make the objects able to play their roles. In your case that is not even necessaray, because Account already has all functions.<br />In the example of Coplien the account only had like: balance, add() and remove(). The MoneySource-Role then added Withdraw() - and THAT is the place where the source-account object needed to be be augmented: The sourceAccount needed to be extended to implement the withdraw...Anonymoushttps://www.blogger.com/profile/07311142553128467543noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-5936988959620158382011-11-12T14:37:51.657+01:002011-11-12T14:37:51.657+01:00@Christian: object schizophrenia? Please explain. ...@Christian: object schizophrenia? Please explain. It's a shame that implementing this approach is more suited to a dynamic language. As you said you can do in C#, but you'll end up making C# act like a dynamic language. Linfu's implementation is example of that. I want a Ruby definition of a mix in, mixins being able to interact with the calling class or other mixins. Spent a lot of time past few days researching this to come to this conclusion. Oh well, guess I'll keep learning Node. :)A'braham Barakhyahunoreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-30001618182774172762011-11-11T14:35:37.168+01:002011-11-11T14:35:37.168+01:00@Marcus:
You may want to go to http://fulloo.inf...@Marcus: <br /><br />You may want to go to http://fulloo.info/ where there is a download page, where you can Trygve's canonical BabyIDE sample.<br /><br />You may also find the collection of samples at https://github.com/DCI/dci-examples interesting.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-18244370838028567312011-11-11T13:43:53.449+01:002011-11-11T13:43:53.449+01:00A very interesting sample. I would be very interes...A very interesting sample. I would be very interested in studying a complete example.<br /><br />Best regards,<br />Marcus NordquistMarcus Nordquisthttp://www.donkeypix.comnoreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-3176099917791203612011-11-10T10:18:34.424+01:002011-11-10T10:18:34.424+01:00Thanks for the clarification. I just thought somet...Thanks for the clarification. I just thought something was missing to the C# code example in the 'Lean architecture' book :-)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-80072374064130112242011-11-09T21:32:58.791+01:002011-11-09T21:32:58.791+01:00@A'braham: By Composite Oriented Development d...@A'braham: By Composite Oriented Development do you mean stuff like Qi4J? -In which case yes there certainly an overlap with DCI. I believe one largest DCI systems out in the wild today is build using Qi4J.<br /><br />You can get a fair bit of the way with dynamic proxies (like Castles og Linfus) but you typically dont get all the way, since you have some sort of a wrapper around your objects at run time, which may lead to problems with object schizophrenia.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-22000430794871130972011-11-09T18:07:01.543+01:002011-11-09T18:07:01.543+01:00Seems similiar to Composite Oriented Development, ...Seems similiar to Composite Oriented Development, and something Udi Dahan talked about.<br /><br />The Dynamic Proxy library (part of Castle) and it's ability to create mixins should allow for full DCI for .net.A'braham Barakhyahunoreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-74247612680281768692011-08-30T08:19:00.152+02:002011-08-30T08:19:00.152+02:00Great article!
I borrowed some of your code for a...Great article!<br /><br />I borrowed some of your code for a project I created here: http://joel.net/data-context-and-interaction-dci-windows-workflow-csharpjoelnethttps://www.blogger.com/profile/16603707768926349646noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-12402288139200369522011-03-11T09:59:55.745+01:002011-03-11T09:59:55.745+01:00@Vitalii That's a good point. OTOH it's al...@Vitalii That's a good point. OTOH it's also about making do with what is possible in current tools.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-65469160601290207352011-03-11T09:41:32.607+01:002011-03-11T09:41:32.607+01:00The issue I possibly see is that instance methods ...The issue I possibly see is that instance methods have a priority over extension methods in C# whereas in a "DCI vision" role methods (implemented in this post's example as extension methods) has a priority over RolePlayer's methods.Vitaliinoreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-76451107244174751972010-07-24T16:05:19.443+02:002010-07-24T16:05:19.443+02:00@Lars-Erik:
I mostly agree with your comment. I a...@Lars-Erik: <br />I mostly agree with your comment. I also tend to prefer very specific names, so if there are separate SavingsAccount roles I would agree that their usage should be specific in the names. <br /><br />In real world scenarios I would have the names of contexts correspond to use case names.<br /><br />I generally dont like to include things like 'core' or 'base' or ... in identifiers; it feels unnatural to me.<br /><br />And: Thanks for your feedback.Christian Horsdalhttps://www.blogger.com/profile/07782376855026802670noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-16117855518290520182010-07-01T12:25:56.667+02:002010-07-01T12:25:56.667+02:00I attended the whole DCI track held by Trygve and ...I attended the whole DCI track held by Trygve and James at last year's Øredev in Malmö.<br /><br />I asked James if Coad's DNC could be applied in order to solve the same problem in C# since we don't have mixins, nor a dynamic language (we have dynamic, ExpandoObject(), and DynamicObject as of now).<br /><br />He said he only knew vaguely about Coad's work in the area, and therefore couldn't answer the question.<br /><br />For me, having implemented DDD and DNC in C# in the past, DCI is basically a more elegant solution to the same problem as DNC tries to solve if you're in a language environment that fully supports it. For that reason; I have continued to use DNC in C#.MartinRLhttps://www.blogger.com/profile/17794301976274938698noreply@blogger.comtag:blogger.com,1999:blog-8336318365940619669.post-42999542612892685862010-06-24T15:18:26.097+02:002010-06-24T15:18:26.097+02:00Not much different, most of my example code is ref...Not much different, most of my example code is refer to your code, i just add some amendment this is related to persistence issue (NHibernate).<br /><br />MoneyTransfer is Moment Interval for me based on my understanding from color modeling camp, but you refer it to context which is DCI approach.I also make MoneyTransfer as an abstract so that i can instantiate it with concrete object like SavingToCurrentAccountTransfer (easy to persist).<br /><br />I've a working example using WinForm + NHibernate + Autofac. Please email to me if interestedryzamhttps://www.blogger.com/profile/08948488698923418322noreply@blogger.com