Hi Oleh,
I would say DCI is more like DCI-U. The emphasis is still very
much on the actual end user of the system. DCI also has a goal of
making software more understandable to everyone, and that includes
programmers of course, hence the emphasis on readable code. But
good readable code shouldn't only be readable to the programmer
who wrote it, but to anyone who understands the domain language,
which should use business terms rather than technical programming
terms. I'm not sure how useful it is to try to come up with an
acronym that covers all of this, but for the sake of illustration,
maybe it would be more like DCI-USP where USP is Users,
Stakeholders, and Programmers. Of course the simpler way of saying
this is that DCI is fundamentally more focused on people than
technology - the focus on people is what drives everything else.
--
You received this message because you are subscribed to the Google Groups "object-composition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to object-composit...@googlegroups.com.
To post to this group, send email to object-co...@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
On 4/7/18 4:53 PM, Oleh Novosad wrote:
If DCI is an MVC for a programmer, does it mean that we can extend MVC by adding a concept of Context to it? Different views of the same user's mental model in MVC make sense inside of different contexts same as in DCI.
The relationship between DCI and MVC is briefly discussed in the latest DCI article (not yet published but available on fulloo.info):
For the most part, DCI is concerned with the Model in MVC since the Model is where most use case logic belongs. See also the FAQ entry: http://www.fulloo.info/doku.php?id=how_does_dci_relate_to_mvcMVC and DCI are complementary paradigms. MVC transforms the Model data into a physical form that can readily be assimilated by the user’s brain. DCI is about creating a program that faithfully represents the human mental model. The two meet when MVC is used to bridge the gap between the human mind and the model implied by the DCI-based computer system.
At one point I was exploring how DCI might be used in conjunction with Views and Controllers as well. This actually led me to question whether Controllers are even needed if you have a smart implementation of the observer idiom (commonly known as the "observer pattern" but that's a misnomer in the sense that it's not a true design pattern - separate topic...). I was playing around with the idea that the Controller could be a DCI context and the Models and the Views would be the roles in that Context, but when I started looking into actually implementing this using a modern web UI stack with a state management library (e.g. MobX or Redux), I found that something like a Controller was rarely needed since the built-in observer mechanisms are very good at keeping the Model and View in sync without the need for manual coding. This is just my own observation and not something I've previously brought up with the group, so others might have a different opinion.
I suppose that when using a library like MobX or Redux, the state manager becomes something like a Controller for your whole app without the need for separate controllers for different screens. And of course, applying the observer idiom to the UI is also very common in desktop programming, I'm just not very familiar with that space.
(BTW, MobX and Redux actually take very different approaches...MobX is much more similar to MVC frameworks that came before it, but in the end they serve a similar function.)
Anyway, the larger point is that DCI is the paradigm and can
potentially be applied anywhere you have objects, it just tends to
be more beneficial in some places (like use cases) than others.
Just as you can do traditional OO with MVC, you can do DCI with
MVC. But you might find that regular old OO is sufficient for the
Views and the Controllers (if you even need Controllers).
In case of any confusion, I should mention a common misunderstanding...
The popular concept of an MVC View as described in many books and tutorials is narrower than Trygve's definition. To quote from Trygve's website:
An important aspect of the original MVC was that its Controller was responsible for creating and coordinating its subordinate views. Also, in my later MVC implementations, a view accepts and handles user input relevant to itself. The Controller accepts and handles input relevant to the Controller/View assembly as a wholeIn web development, we are now calling Views "UI Components". I think the name "Component" is actually a good fit because components aren't just concerned with displaying things on the screen, but they can also handle user input events. And as Trygve himself has said, "View" and "Controller" are really roles, and you could even have the same object playing both roles (I think he used the example of a scrollbar). So when I said I rarely find the need for Controllers these days, that was assuming this definition of a View as something that can both display data and handle user input events (either internally or delegating to the Model when the event is received). Of course only some Views should have both responsibilities; many are purely presentational.
(if you even need Controllers).
(if you even need Controllers).
I think C (Controller) in MVC can be replaced with Context. It makes sense. Context has use-case(s), and we present views to User following use-case(s). Views are related to Contexts same as Roles are related to Contexts in DCI. Now DCI-P and MVC-U make a whole.
--
--
On 4/8/18 12:11 AM, Oleh Novosad wrote:
I think C (Controller) in MVC can be replaced with Context. It makes sense. Context has use-case(s), and we present views to User following use-case(s). Views are related to Contexts same as Roles are related to Contexts in DCI. Now DCI-P and MVC-U make a whole.If I'm understanding you correctly, this reflects a common misunderstanding of Controllers - one that I used to have as well. In original MVC, a Controller was never supposed to be a place where you'd put lots of business or use case logic (talking about user goal-level use cases here) -- that was meant to happen in the Model. I think this misinterpretation of Controllers became common in the earlier years of web development when we had "Controllers" handling HTTP requests, but probably started before that. So if you mean that the DCI Context is now where you'd put use case code that you previously would have put in a so-called "Controller", then yes.
--
I agree with Oleh: it could certainly work to implement a
Controller as a Context. Views and Models are interacting objects
so it makes sense to put them in a Context to make that
interaction clearer. In a previous thread (probably a year or two
ago now), Rune brainstormed the idea of a Context for MVC where M
V and C are roles. After thinking about this more recently, I
realized that the main purpose of the Controller is to facilitate
interaction between the Views and the Model(s), so I don't see the
reason for introducing a 4th part of the pattern - the Controller
*is* the Context for the interaction of Models and Views.
But as I said in a previous post, when I actually started
implementing this idea, I began questioning the need for
Controllers in the first place because most of the time, their
function can be automated (other than creating Views in the first
place, but that's a fairly limited function that falls short of
what I would call a Controller, if that's all it's doing). I think
quote from the MobX documentation makes a good
point:
Anything that can be derived from the application state, should be derived. Automatically.
If all of your Views automatically react to changes in the Model and vice versa, then in my experience there's very little need for the plumbing code that would otherwise go in Controllers.
~~~
There's another big factor in this discussion...Oleh mentioned
Ruby on Rails. Rails is a framework that runs only the server, and
as a server-side framework, its implementation of MVC is
considerably different than client-side MVC. Most of my comments
have been about client-side MVC, where the Model View and
Controller can all interact with each other directly. This of
course is much closer to the original MVC which was first applied
to desktop software. While it was great for server-side frameworks
to follow the spirit of MVC, their "Controllers" are of course a
different animal than client-side Controllers, and there was an
important thing they got wrong, which was that aside from code
involving the UI specifically, use case logic belongs in the Model
of MVC, not the Controller. But of course this is harder to
achieve for practical reasons when your controllers are handling
stateless HTTP requests on the server and are not directly
connected to your UI or your client-side Model. And also, without
DCI, putting all use case logic in Models can become a mess.
As I see it, the place where DCI fits best into this picture
(most of the time) is as Contexts apart from MVC. The Views accept
user input events and then trigger the appropriate use case
Context...or, if there's some complexity that warrants it, a
Controller could handle the event rather than the View, and then
the Controller in turn calls the Context. (Note that when I say
"handle the event" I don't necessarily mean processing it; this
could simply be passing some data along to be processed by the use
case Context.)
Of course, the asynchronous nature of GUIs complicates all of
this. I don't think we've landed on a complete solution yet,
especially in the case of use cases that involve multiple
interactions with the user to reach completion (e.g. a
wizard-style interface or a shopping cart system). Synchronous
blocking is one option, but that only works in a multi-threaded
environment (which means it's not a workable solution for web
browsers), and has some technical downsides anyway. In the case of
Ruby and other environments with fibers or coroutines, I agree
that those might be helpful here. IMO there are also simpler
solutions that could work.
Oleh, I have some additional thoughts regarding the preceding
paragraph which I've expressed in previous threads, but rather
than resurface that now, I would encourage you to experiment as
Andreas suggested and then share your findings. I would be
interested to hear where this exploration leads you.
The essence of object orientation is
that objects collaborate to achieve a
goal.
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn.
5A http://folk.uio.no/trygver/
N-0378
Oslo http://fullOO.info
Norway Tel:
(+47) 22 49 57 27
> Den 9. apr. 2018 kl. 01.01 skrev Matthew Browne <mbro...@gmail.com>:
>
> the Controller *is* the Context for the interaction of Models and Views.
I think that is true only for some use cases. For example, when the Model is updating the View, there is not much need to involve the Controller in most cases.
I also think that this design – and this discussion – are somewhat different from the ideas in the original post in this thread.
I see MVC and DCI as 2 orthogonal principles for separation of concerns. An example is my planning example where I first organize the program along MVC lines, and then each seperately along DCI lines:
Model
Context
Data
UI
Context
Data
More at
http://folk.uio.no/trygver/Diverse/PlannningExtract.pdf
But what do you think of the idea of a Controller being implemented as a DCI Context instead of a class?
Is there some compelling reason to avoid the use of DCI in the parts of your code that implement MVC?
On 09.04.2018 20:08, Matthew Browne wrote:
But what do you think of the idea of a Controller being implemented as a DCI Context instead of a class?Confusing class and Context is not a good idea because the concepts are incommensurable. The first deals with the inside of a stand-alone object, the second with a structure of communicating objects (seen from their outsides). The state of a Controller is essential. There's no room for it in a DCI Context.
Matt, when you play around with this I'm curious about the communication between the roles. If there are no communication, or maybe even a hierarchical communication where the controller is basically telling the views what to do, is this Context anything else than a glorified class?
We had a discussion in the group about the Tower of Hanoi game, and found out that not every object should play a role because of a lack of genericity. I suspect this could be a similar case.
The responsibilities of M, V, and C are assumed by objects. They are primarily responsible for maintaining state: The C maintains a digital representation of some user information.
Seen from outside the encapsulation, an object has a unique and immutable identity and can only be accessed through its provided message interface. The object's inside is invisible from its outside. Seen from inside the encapsulation, an object stores its state (e.g. in instance variables) and defines its behavior (e.g. in its methods). The object's outside is invisible from its inside. (The class isn't interesting at runtime.)
Cope's trygve language and Smalltalk support this definition. (Most OO languages don't support it. Their encapsulations are transparent and confuse the definitions of DCI and MVC.)
On 4/12/18 9:16 AM, Trygve Reenskaug wrote:
The responsibilities of M, V, and C are assumed by objects. They are primarily responsible for maintaining state: The C maintains a digital representation of some user information.Did you mean to say "The M maintains a digital representation of some user information"? Yes, the Controller can temporarily store user information too, but reading this and noticing that you didn't go into the M's role, I was just wondering if this was a typo.
The instance variables can be reached (read and written) from anywhere if they have a public attribute. Java etc. have no encapsulation.
On 4/14/18 1:52 PM, Trygve Reenskaug wrote:
The instance variables can be reached (read and written) from anywhere if they have a public attribute. Java etc. have no encapsulation.You can do the same thing in trygve:
Starting a new thread to avoid hijacking the other one...
On 4/14/18 1:52 PM, Trygve Reenskaug wrote:A grave disappointment.
The instance variables can be reached (read and written) from anywhere if they have a public attribute. Java etc. have no encapsulation.You can do the same thing in trygve:
Simplicity, simplicity, simplicity!
Den 15. apr. 2018 kl. 10.43 skrev Trygve Reenskaug <try...@ifi.uio.no>:private means private to the class, not the instance. So your x can be changed from any instance of class Demo. There is no encapsulation.
Den 15. apr. 2018 kl. 03.49 skrev Matthew Browne <mbro...@gmail.com>:2. It might seem like a good idea to expose 'x' as a public property at the time you're originally writing the class, but some future requirement might arise for which you'd like to add some additional logic, e.g. validation before setting the value. But because you already made it public, this would require refactoring not only your class but also all the code that uses Demo.x.
Den 15. apr. 2018 kl. 03.49 skrev Matthew Browne <mbro...@gmail.com>:
I'm guessing that Cope does not view public properties as such a catastrophe either, or he wouldn't have included them in the language.
Den 14. apr. 2018 kl. 22.21 skrev Trygve Reenskaug <try...@ifi.uio.no>:A grave disappointment.
Simplicity, simplicity, simplicity!
Den 15. apr. 2018 kl. 14.46 skrev Matthew Browne <mbro...@gmail.com>:On 4/15/18 5:35 AM, James O Coplien wrote:What are we talking about exactly? Are you referring to the following:Den 15. apr. 2018 kl. 10.43 skrev Trygve Reenskaug <try...@ifi.uio.no>:private means private to the class, not the instance. So your x can be changed from any instance of class Demo. There is no encapsulation.I think this is a bug in trygve. Do you agree?I have implemented and tested a fix for it.
Den 15. apr. 2018 kl. 10.43 skrev Trygve Reenskaug <try...@ifi.uio.no>:
private means private to the class, not the instance. So your x can be changed from any instance of class Demo. There is no encapsulation.
I think this is a bug in trygve. Do you agree?
"What is private in Java?My mental model consists of objects and objects only. Classes are very much in the background. I think of methods as parts of the object. The class is merely a shared repository that saves space. A private member should only be visible within the object in my mental model. This means that a private inst.var. is only visible to the object's own methods. Similarly, a private method is only visible to the object's own methods (i.e. sender=receiver=this). As far as I can see, a public tag is the only meaningful alternative to private.
A private member is only accessible within the same class as it is declared. A member with no access modifier is only accessible within classes in the same package. A protected member is accessible within all classes in the same package and within subclasses in other packages."
Den 15. apr. 2018 kl. 17.50 skrev Trygve Reenskaug <try...@ifi.uio.no>:As I understand it, not being a 3GL language programmer, protection codes in 3GLs apply to the source, not the runtime.
Den 15. apr. 2018 kl. 14.26 skrev Matthew Browne <mbro...@gmail.com>:Oh right. But what about:
aDemo.x = newValue
"What is private in Java?
A private member is only accessible within the same class as it is declared. A member with no access modifier is only accessible within classes in the same package. A protected member is accessible within all classes in the same package and within subclasses in other packages."
Den 16. apr. 2018 kl. 08.19 skrev Trygve Reenskaug <try...@ifi.uio.no>:Specifically, a private property should never show up in a DCI Data object interface
I still see a difference between the meaning of 'private' at compile time and private at runtime.
aDemo.x would only be legal if aDemo is the current object
--
Den 16. apr. 2018 kl. 11.37 skrev Rune Funch Søltoft <funchs...@gmail.com>:I’d argue that mutable data is itself breaking encapsulation and therefor everything we can think of aside immutability is not fixing the root cause but merely the symptom :). For some reason outside FP this problem has only been fixed for primitive types. When integers or strings expose their internal mutable representation all sort of weird things happen:While i < 10 doi = i + 11 = i / 3
Trygve,
Den 16. apr. 2018 kl. 08.19 skrev Trygve Reenskaug <try...@ifi.uio.no>:
Specifically, a private property should never show up in a DCI Data object interface
This statement is unclear.
I thought DCI was a programming technique. Programming is about source code.
For the purposes of this discussion, can we set aside the fact that you can do this:
class Demo {
private int x_
private ExternalClass external_
public foo() {
external_.bar(x_)
}
}
Trygve, correct me if I'm wrong, but I don't think you're
concerned about the fact that you can deliberately pass a private
value outside of the class (as above), but rather that you can
directly access demoInstance.x_
from outside the instance. And it sounds like we all agree that
Cope's fix to limit privacy to the instance level rather than the
class level is a good thing.
In Java, for example, a private member is visible within the source file, while a property private to the object is only visible within the object. aDemo.x would only be legal if aDemo is the current object.
A private member is only accessible within the same class as it is declared.
The responsibilities of M, V, and C are assumed by objects. They are primarily responsible for maintaining state: The M maintains a digital representation of some user information. The V maintains a picture of this information, e.g., as pixels on a screen.
The C creates, manages, and coordinates the Vs, so its state must include information about them.
All this means that we work with the M. V, and C objects in their insides.
(There is no inherent collaboration between M, V, and C,
so DCI has nothing to contribute at the outer level. The M is responsible for warning its dependents (state) whenever the user information changes. M must understand the addDependent: v -message. It must sendupdate-messages to its current dependents whenever appropriate. M does not care about how the dependents will handle the received update-messages. M is a stand-alone object. We are only interested in its insides; it is specified as part of a class somewhere.)
The D in DCI is a set of objects seen from their outsides; their insides are explicitly hidden.
The C seen from its inside declares its roles and links to its Interaction(s) Seen from its outside, it looks like any other D object and can play roles in other Cs (recrusion).
--
You received this message because you are subscribed to the Google Groups "object-composition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to object-composit...@googlegroups.com.
To post to this group, send email to object-co...@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
The essence of object orientation is
that objects collaborate to achieve a
goal.
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn.
5A http://folk.uio.no/trygver/
N-0378
Oslo http://fullOO.info
Norway Tel:
(+47) 22 49 57 27