I don’t pretend to know a lot about the Model-View-Controller (MVC) design pattern, but for a Xojo web application with a single web page should the App class be the controller as opposed to the WebPage class?
Hmm… I don’t really see a need for the type of MVC that you describe. This may generate nice spaghetti code. But without any type of example I can’t really see if this is something interesting or not.
Patrick, the site (xojogurus.com) seems a little broken…
Some links (at least the ones that point to email) don’t point correctly, and the “Buy now” doesn’t work (lists the contents of a directory)…
However, I would be interested to see your implementation of MVC. It is especially important in a project, since I want to deploy it both on desktop and as a web application, so the Model and the Controller in most cases is identical, and the only difference is in the “View” classes…
Thanks Patrick for replying, I will check out your links.
Please check your sites links. Many are broken and it makes evaluation difficult.
Sorry about the delay in getting the xojogurus site up and running. Mavricks broke some of my tools.
I’m not quite following the logic here. Why would it rely on “cut & paste programming” if in the previous sentence “they simply call a function in a module or class what is part of the main codebase”?
And “having to paste into every control in every window”? Make a subclass, or create a universal method, or
XOJO and other Visual Basic Like programming environments attract all different levels or programmers. A good programmer would certainly favor a function call from UI events, and better yet use some sort of universal method… which is exactly what the MVC Library does.
Without the MVC style of messaging you still need to add code to every UI control you with to elecit a response from. Now add features like mouseover effects on every button and checkbox and you have a lot of cut and paste going on - even if it is a one-liner.
My goal was to develop a light and tight codebase that would remove the requirement to add code to UI controls, databases or networking. Of course a talented programmer might want to superclass some native controls in a different way than the MVC controls do, but 90% of the time you can just use the MVC controls and not have to worry about what goes on behind the scenes and know that they work on all mvc controls in any window without any extra code being written.
The only code the programmer really needs to write is switch-case or if-then control structures that can react to the incoming messages from the UI, network, database, timers, and threaded processes. Since a few us us here have been coding for over 30 years, it is likely that a lot of the described benefits of MVC for XOJO might seem frivolous, but not everyone has that kind of experience.
Xojo abstracts so much for you already it always seems a little silly to me to abstract it further. How little should a window know about being a window before its completely irrelevant that it is a window?
In traditional languages its really easy in a single class file to build an entire application. MVC helps there by creating a structure and flow to your application so that file does not get unwieldy. Xojo does this for you. In Xojo the framework calls what you see as control/window events probably through a series of AddHandler’s from their original platform-native objects. So in essence Xojo’s framework is already acting as the controller and delegating to your desired “events”.
If Xojo needs anything it needs less UI abstraction and more work on the Model side of MVC. Powerful ways to abstract databases, database schema migrations, versioning, etc.
I am developing an app for desktop and web. I think for this situation, the MVC approach is the way to go. After looking at the examples on the code-blog which don’t use control sets, I have a situation I am not sure how to approach. I use a lot of control sets in control containers for a dynamic UI. Would those be managed (adding or deleting controls in the set at runtime) by methods in the container or would you manage them with a class?