hi Bryce,
Isn't the view and controller always seperate in RPG and DDS no
matter what? MVC comes in to play mostly in the web world where you
can have code that is responsible for formatting the screen data as
well as generation of said data. But in the case of coding in RPG
and DDS the DDS is the view.
It's true that the DDS is *part* of the view, but it's not the whole
thing. There's still some view logic in your RPG code, such as any
EXFMT statements, code that loads the subfile, code that handles F-keys,
etc.
Any code that's particular to the display method is part of the view.
Think of it this way: You should be able to replace one view with
another view, and have it work. i.e. if you wanted your program to
output to a fully GUI screen (such as a Windows screen) instead of a
5250 display, you should be able to bind to a GUI VIEW module instead of
a 5250 view module, and have it work.
You can't do that simply by replacing the DDS with something else,
because EXFMT, the SFILE RRN, the F-key logic, etc, will really only
work with a DDS display file.
You have to replace all of the code that's particular to the UI -- so
all of that code MUST be part of the view.
RPG is your controller and the data structures and database tables
would be your model. So just by coding in RPG and DDS you are
already coding in MVC as long as you use external datastructures and
tables.
Same is true on the MODEL end... there's more to the model than purely
the database. First of all, many people code additional business logic
apart from purely writing stuff to a DB and reading it back. They have
other stuff like calculations (how is tax calculated? How are discounts
calculated? multiply what by what?) error checking, etc, that's not
actually part of the database.
Second, the code that actually does the read, write, etc to the database
is part of the model. i.e. the SQL statements, or RPG CHAIN, READ,
WRITE, SETLL, etc op-codes are all part of it.
Just like the view, you should be able to completely replace the model
(or, it should at least be conceivable to do so) with a totally
unrelated one and have it work.
Please feel free to correct me if I've missed something.
Done.
As an Amazon Associate we earn from qualifying purchases.