MVC design questions

M

Martin Gregorie

Hmm. The more i think about it, the more i think a single class might be
a good idea. But it would involve putting both search- and
update-specific code in the model. Which isn't necessarily so bad - a
well-rounded class supporting both read and write operations is a fairly
common thing to find in a domain object layer. It really depends how
complex the code you want to put in the model is.
Yes, that's looking steadily better the more I think about it. Instead of
a single CRUD GUI program I've got two, the idea being that one can be
given to anybody because it can't damage the database (no insert/update/
delete capability at all while the other, which can do these things, is
intended only for suitable authorised users: most data is bulk loaded and
the update GUI is only there for removing to odd piece of junk and
tidying up. IOW, a single model for these GUIs isn't a bad idea.
"Of course"! There's no law against CLI programs having object models!
Although if they exist purely to move data in and out of databases, a
model may be an unnecessary complication.
That fits in this case. The bulk loader is near as dammit loading a data
warehouse. Think of it as throwing each item of input into the fact table
and adding a few dimensions to speed up searches. The second CLI is a
bulk unloader which is essentially just dumping the fact table, so
neither program has any need of a model.
Right. Get your backspace key out.
As I said elsewhere, I'll merge the two models and do the same with the
corresponding JDBC layer.
Are you serious, or is my irony detector broken?
I have almost no OO background and have no idea who the currently
recognised OO design gurus are. I've heard of Booch, but have never seen
him mentioned here. Hence the question.
These are the two most important books about the craft of
objected-oriented software ever written:
Thanks. Thats exactly what I wanted to know.

BTW, and to show where I'm coming from, apart from K&R, I think the best
non-OO programming books in my library are:

1) Software Tools in Pascal (Kernighan & Plauger)
2) Algorithms (Sedgewick)
3) The Practise of Programming (Kernighan & Pike)
4) Algorithms + Data Structures = Programs (Wirth)
5) An Introduction to Database Systems (Date)

and, no, I don't have a copy of Knuth. So far Sedgewick and Wirth have
filled that need.

(1) is still about the best book I know about designing reusability into
code modules while (3) should be read by every programming neophyte, OO
or non-OO for its advice in code readability and designing testability
into your code. As for (5), Date is great. He manages to combine an
understanding of DB principles with good design and implementation
guidance.
 
T

Tom Anderson

Yes, that's looking steadily better the more I think about it. Instead
of a single CRUD GUI program I've got two, the idea being that one can
be given to anybody because it can't damage the database (no
insert/update/ delete capability at all while the other, which can do
these things, is intended only for suitable authorised users: most data
is bulk loaded and the update GUI is only there for removing to odd
piece of junk and tidying up.

I think relying on control over software distribution to maintain database
security is probably not the best idea. You probably know this, of course,
and for a lightweight, non-mission-critical app, controlling the software
might be enough.

If possible, though, i'd suggest creating two user accounts in the
database, one with full access, and one only with read rights, and
controlling the distribution of the passwords. In fact, i'd create three -
a full-access account for the DBA, an account with the ability to edit the
data, but not do DDL, for the update app, and a read-only one for the
search app. Or an account for each actual user, but that becomes more of a
headache to manage - but perhaps necessary.
IOW, a single model for these GUIs isn't a bad idea.

That i agree with.
I have almost no OO background and have no idea who the currently
recognised OO design gurus are.

Fair enough.
I've heard of Booch, but have never seen him mentioned here. Hence the
question.

I think he's one of the ones with good facial hair. Ah yes:

http://yuiblog.com/assets/booch.jpg

Booch was one of the top chiefs in the early-mid '90s wave of OO design
thinking. That era was dominated by big ideas - big processes (Rational,
Booch, OMT), big notations (UML), big books, big words. People thought
that big, complex problems had to be solved with correspondingly big and
complex tools of various kinds.

I would say that subsequent history has shown this to be mistaken: what's
worked has typically been more focused, more about getting foundational
things right, running before we can walk. Design patterns are about this -
getting the structure of code right at the level of classes and clusters
of classes, not whole architectures. Unit testing is all about this -
writing and enforcing specifications at the level of methods and classes.
Drawing diagrams with boxes and arrows (and using much of the UML
notation), but not making drawing diagrams an activity in itself.

Rumbaugh and Jacobson are other big names from this period. They're all
very smart guys, and i don't for a second mean to downplay the importance
of their work: that huge burst of talking and writing was the birth of
serious thinking about OO design, and we could no more have reached the
stage we're at now (which i have to say is by no means a mature stage -
it's still mostly guesswork) without it than classical music could have
happened without the baroque (or, perhaps, than we could have developed
bronze tools without what we'd learned from flint).
Thanks. Thats exactly what I wanted to know.

BTW, and to show where I'm coming from, apart from K&R, I think the best
non-OO programming books in my library are:

1) Software Tools in Pascal (Kernighan & Plauger)
2) Algorithms (Sedgewick)

I love that book! My first (and only, really) algorithms book. It has a
few warts, but i learned a lot from it. Patricia trees, in particularly,
are something that have stayed with me. His stuff on sorting is excellent
on the basics, but i would have loved to have read about the things that
come after quicksort and mergesort (although maybe those were only
developed after the book was published, now i come to think of it).
3) The Practise of Programming (Kernighan & Pike)
4) Algorithms + Data Structures = Programs (Wirth)
5) An Introduction to Database Systems (Date)

Also a classic. Rigorous but lucid. I had the sixth edition.
and, no, I don't have a copy of Knuth. So far Sedgewick and Wirth have
filled that need.

I can imagine. Knuth is to algorithms books what the Oxford English is to
Dictionaries: definitive, scholarly, and endlessly fascinating, but a bit
heavy to be a practical handbook.
(1) is still about the best book I know about designing reusability into
code modules while (3) should be read by every programming neophyte, OO
or non-OO for its advice in code readability and designing testability
into your code.

I don't know them. They both sound interesting, though - i'll see if i can
find a copy of the K&P in particular.
As for (5), Date is great. He manages to combine an understanding of DB
principles with good design and implementation guidance.

Should be compulsory reading!

tom
 
M

Martin Gregorie

I think relying on control over software distribution to maintain
database security is probably not the best idea. You probably know this,
of course, and for a lightweight, non-mission-critical app, controlling
the software might be enough.
Yes you're right, of course, about the security aspects. However, I'm
also a fan of not showing people what they can't have, i.e. menus with
grayed-out entries. Far better to remove the item entirely because some
people take the suppressed-but-visible item as a challenge. The two GUIs
is pretty crude, but it does meet that requirement.
If possible, though, i'd suggest creating two user accounts in the
database, one with full access, and one only with read rights, and
controlling the distribution of the passwords.
The initial idea is to limit updating to one Linux login, but distribute
the enquiry tool to anybody who needs it (other Linux accounts, Windows
boxes) on the lan, and lock PostgresQL down to accepting connections
solely from the LAN. Not brilliant, I know but the data isn't
particularly sensitive or mission critical, and this split will do for
starters and would easily lend itself to differently privileged logins
since PostgresQL's default is to use the login name as as the database
user name. I have one or two ideas about improvements....
I don't know them. They both sound interesting, though - i'll see if i
can find a copy of the K&P in particular.
Like Sedgewick, the code in K&P is lucid enough to translate 'on the fly'
into other languages. The Pascal version is a re-release. The original
book used RATFOR code. Its a language implemented as a FORTRAN pre-
processor, rather like the first C++ implementations or (I think) GNU
implementations of Ada, COBOL, FORTRAN and Java. I've never seen any
RATFOR code.
 
A

Andreas Leitgeb

Martin Gregorie said:
However, I'm
also a fan of not showing people what they can't have, i.e. menus with
grayed-out entries. Far better to remove the item entirely because some
people take the suppressed-but-visible item as a challenge.

I don't share this opinion completely.

If I see a grayed out menu-item, then I know: The feature would be
right here, but the program considers it inappropriate at the moment.

If I do not see a certain menu-item I expected to see, I damn the
designers for probably having moved it somewhere else, and go for
searching it through all the menues.

The human brain "caches"(*) item-positions, so adding or removing
items causes the user to rescan the list, rather than target the
pre-expected position directly. (Just my own experience, no scientific
references at hand)
*: as in: "delete is half-way down", "Exit in File is at bottom"

E.g. filemanagers: If showing a folder on a read-only device, I'd
prefer to see "Cut" and "Delete" grayed out to them being removed
entirely.

I've long ago seen a window manager, that would gray out e.g. the
"minimize" item when the window indicates it doesn't want to be
iconfied, but one could click it anyway, and the window would then
be force-minimized (ditto for close, maximize, size). I liked it.
Even if the action is not forceable, a popup/the statusbar could
inform why this action is disabled at the moment ("readonly filesystem",
"nothing approriate in clipboard", "Too few foos to snarl", and the
infamous "you need $self PRO PLUS© to use this feature", ...)

In a nutshell: a grayed out item should visually indicate a dead-end
which isn't always dead. If it were always so, I'd agree that removing
it is the better choice, of course. (for some appropriate definition
of "always", that is)
 
M

Martin Gregorie

I don't share this opinion completely.

If I see a grayed out menu-item, then I know: The feature would be
right here, but the program considers it inappropriate at the moment.
Yes, I agree with that and use it the3 same way.

However, I'm talking about role-based security preventing users with a
given role from EVER doing some things, which is a bit different.
Omitting the item from their menu will not cause item jumping because
they will never ever see that item and, IMO, that's preferable to having
them always see a grayed out item.
If I do not see a certain menu-item I expected to see, I damn the
designers for probably having moved it somewhere else, and go for
searching it through all the menues.
Agreed. That used to cause me to swear loudly each time a new version of
MS Office was released. Since I've seen the light and moved to OpenOffice
that problem has largely vanished. The OO menu structures seem a lot more
persistent across releases than the MS Office menus.
In a nutshell: a grayed out item should visually indicate a dead-end
which isn't always dead. If it were always so, I'd agree that removing
it is the better choice, of course. (for some appropriate definition of
"always", that is)
Exactly so.
 
M

Martin Gregorie

On Tue, 10 Feb 2009 15:46:00 +0000, Martin Gregorie wrote:

Following up.

I combined the models into one class and did the same with the
corresponding JDBC layer. The latter kept its superclass since that is a
useful place to put half a dozen common methods that are also used by the
CLI programs. They retail their own JDBC layer classes since there's no
application-level commonality between them or between them and the GUI
JDBC layer.

The refactoring was straight forward and had the benefit of smoking out
cruft in the form of three or four duplicated methods and some bad method
names.

The system is running well.

Thanks again for a most useful discussion and helpful advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top