Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes <ofv@xxxxxxxxxx>
- Date: Wed, 13 Feb 2008 21:42:12 +0100
Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx> writes:
Óscar Fuentes wrote:
Neil Madden <nem@xxxxxxxxxxxxx> writes:
Obviously not, the -variable is the Model. The bindings are the
Controller. Do you feel Tk lacks in this area as well?
<sigh>
If your implementation of MVC is a View that directly updates the Model,
(and even worse, each widget updates a part of the Model as the user
interacts with the View) you are not using MVC, you are using something
else.
So you don't consider the bindings, and the code behind the bindings,
to be considered a controller? Can we get a simple yes or no to that
question? That might help me better understand where you're coming
from.
The bindings are (part of) the Model, and I've expressed this several
times.
If I have, for example, three views on a single model, each view
represented by a single checkbutton (just to keep this example
simple), and on each checkbutton is a binding that causes the model to
be updated, I consider that model/view/controller even though I may
not have personally written the bindings. In reality I would likely
have a collection of variables (model), a collection of widgets
(view), and a collection of bindings (controller). I guess if you
don't see that as model/view/controller that would explain the
disconnect we're all having in this thread.
Yes, that could be regarded as a simple MVC.
The disconnection comes from the value we assign to some things: having
several simultaneous views for the same changing model is important for
you, and so you value -variable as convenient (up to some point: what
happens if you use radiobuttons on a view and a list on another one?;
what happens if you have a [text] widget for the same data on several
views? if the Controller wants to disable change for one part of the
data, does -variable help?) For me, is more important having a
consistent and simple base, even when I need to work a bit more on
scenarios like the one you mention (which is quite rare, in my
experience).
Even though many will agree it's not a definitive source, wikipedia
describes the role of the controller as "Processes and responds to
events, typically user actions, and may invoke changes on the model."
To me, bindings and the use of -variable fit that description handily.
Not for me. If your checkbutton changes the Model, it is doing the role
of View and Controller, which goes against the separation of roles that
MVC advocates.
But my gripe comes from the fact that [checkbutton] *forces* you to fake
the scenario you guys are describing: a mini-semi-MVC consisting of a
variable and a checkbutton, that is a part of the bigger, "serious" MVC
implementation.
I think we'll just have to agree to disagree. I'd need to see an
actual problem that -variable causes in practice,
The problem is having to deal with two separate entities (the widget and
the variable) for achieving a goal.
I guess for some of this, this is a feature and timesaver rather than
a problem to deal with. The model is the variable, the view is the
checkbutton, and the controller is the combination of the -variable
and widget bindings that link one to the other.
Brian, do you really think on terms of MVC when you put a [checkbutton]
on some toplevel? Or do you think "I need to get a yes/no data, so I put
a [checkbutton] here and make-up a variable for holding the value, which
is later for used for taking this or this other route down here".
Applying the MVC pattern is a conscious process (unless the system
forces you to use it, which is *not* the case of Tk which, fortunately,
does not enter into such high-level approaches). You apply MVC on a
e-commerce web form, or on a display of stock market state. This
requires a previous *design* and a conscious decision of applying the
MVC pattern.
But so much for discussing MVC. I'm interested in the wisdom of the
existence of -variable. The fact that widgets directly and immediately
modify their variables and that only some widgets supports it, discards
-variable as a tool for implementing real MVC applications.
This is unnecesary complexity, and
adds possible bugs due to actions (or lack of) on the variable, such as
not unsetting it after the widget is destroyed (memory leak) or not
initializing it properly when it is reused.
Let's qualify that as "unnecessary complexity for the way you design
software". For me it greatly *reduces* complexity because I don't have
to implement a controller for many of my applications. Tk takes care
of that for me, freeing me to concentrate on more important things
(like reading USENET! :0)
If the only thing your Controller does is to copy data from/to widgets
and variables, well, yes. But this is a trivial Controller. People does
not usually care about features that solve trivial problems.
Maybe it doesn't fit the model/view/controller pattern as you see it,
but no matter what name we give it, there seems to be overwhelming
evidence that -variable is a much bigger win than a loss.
I fail to see this evidence. If it is so good, why other frameworks does
not implement it? Why is it not extended to all Tk widgets?
Sincerely, IMO this is a clear case of the tool making the habit.
Take that with a grain of salt though, as my only proof is a dozen
years of Tk programming with only once hearing anyone opine that
-variable is bad (to my recollection). Maybe I just hang around in the
wrong crowd.
Being inside a community for a long time is not good for understanding
points of view that comes from the outside.
--
Oscar
.
- Follow-Ups:
- Re: ttk::checkbutton - I think, it's a bug
- From: Bryan Oakley
- Re: ttk::checkbutton - I think, it's a bug
- References:
- ttk::checkbutton - I think, it's a bug
- From: ZB
- Re: ttk::checkbutton - I think, it's a bug
- From: Gerald W. Lester
- Re: ttk::checkbutton - I think, it's a bug
- From: ZB
- Re: ttk::checkbutton - I think, it's a bug
- From: Gerry Snyder
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Bryan Oakley
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Bryan Oakley
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Donal K. Fellows
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Bryan Oakley
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Neil Madden
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Neil Madden
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Neil Madden
- Re: ttk::checkbutton - I think, it's a bug
- From: Óscar Fuentes
- Re: ttk::checkbutton - I think, it's a bug
- From: Bryan Oakley
- ttk::checkbutton - I think, it's a bug
- Prev by Date: about BWidget
- Next by Date: Building starkits in windows.
- Previous by thread: Re: ttk::checkbutton - I think, it's a bug
- Next by thread: Re: ttk::checkbutton - I think, it's a bug
- Index(es):