Re: MVC - The right way

From: Fredrik Bertilsson (fredrik_bertilsson_at_passagen.se)
Date: 09/13/04


Date: 12 Sep 2004 22:48:55 -0700

aweston@connectfree.co.uk (Tony Weston) wrote in message > I Haven't yet looked in depth at your framework. If you have anything
> at all related to the database (field name, tablename, connection
> string, etc) anywhere in the component class, then I would not
> consider this MVC....

Butler's data-aware components do know about table and column names,
but not connection strings.

> Imagine you have two components, a combobox with a list of countries,
> and a jtable, with also a list of countries. In your framework, to
> build these two components, would you need to duplicate the code that
> makes the JDBC calls in both components?

In Butler, these components are RecordListCombo and RecordListTable.
None of them have code for making JDBC calls. Both components listens
for a RecordList to be assigned to them from other components (like
QueryController).

> What about other components
> that need to access country name... Similar SQL calls?....

Not at all.

> What
> happens if new business requirements mean the database changes so that
> country names are now stored in a different database table?.... Mass
> refactoring of all country name referencing components maybe?

A change like this will most likely mean mass refactoring a lot of the
business logic in any case. The database structure implements a lot of
business logic, and changing it will by definition lead to changes in
the application code. Please give me an example of how a change like
this will look like. You have a table named "country" with a column
"name". To what table would you like to move the column "name", and
what relation do this table has to "country". The only possible change
without changing the business logic, is to move to a table with the
same primary key as "country". If you move to a table with a different
primary key, it might be possible for a country to have multiple
names, and you will have to change a lot in your client anyway.

> A better idea might be to externalize said JDBC calls into a new
> class,

All JDBC calls in Butler is externalized into the class JDBCDriver.

> the 'countriesModel' which would perform the job of retrieving
> the list of countries from the database for what ever class wanted to
> make use of its services ie, both the combobox, and the jtable will,
> instead, create an instance of countriesModel, and call
> getCountryNames() to get a list of countries to populate themselves.

If you have business logic on your application server, will you use
this model objects too, or will you have to create other objects for
handling countries. When I try to imagine your application I see
methods like "getCountryName" in a lot of places. Adding a new
property/attribute to country will force you to change a lot of
classes.

> This way, should the database change (the name of the countries, be
> retrieved from a new file for example)

If you are using a database for storing countries, you are not
retrieving countries from files at all.

/Fredrik



Relevant Pages

  • Re: How to properly link the tables?
    ... Year Country Datacategory VariableName VariableValue ... Thanks very much on your previous reply enabling a entire view in database ... table is devided up by time/country/company category, ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Basic application design
    ... Database is in one country where the internet is excellent. ... If we go for an ASP net based solution, then the server hosting ... Web Service running on ASP.Net. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How can I organize my database?
    ... I am trying to design a database in order to store information on as many ... Depending on the organisation, this ... number of country offices can vary greatly in number. ... number of district offices can vary in number. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: How to properly link the tables?
    ... Year Country Datacategory VariableName VariableValue ... Thanks very much on your previous reply enabling a entire view in database ... table is devided up by time/country/company category, ...
    (microsoft.public.access.tablesdbdesign)
  • Need to aggregate t-test stats
    ... My main goal is to "bless" a new database such ... "name" lengths for each country. ... them would have high p-values (seems like a great way to ... statistics obtained from all the different tests and compare ...
    (sci.stat.math)