wood burning stoves 2.0*
The moose likes JDBC and the fly likes SQL Antipatterns: MVC and Common Pitfalls in DB application development Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Antipatterns: MVC and Common Pitfalls in DB application development" Watch "SQL Antipatterns: MVC and Common Pitfalls in DB application development" New topic
Author

SQL Antipatterns: MVC and Common Pitfalls in DB application development

Sunil Tiwari
Ranch Hand

Joined: Sep 19, 2006
Posts: 49

Hi Bill,

Though these are few open ended question, but still would like to ask.

1) How can SQL Antipatterns help in MVC architecture?

and

2) What are the common pitfalls in DB application development, using Java?

Thanks
Sunil


~ Neil (SCJP)
Bill Karwin
author
Ranch Hand

Joined: Aug 02, 2010
Posts: 32
Sunil Tiwari wrote:1) How can SQL Antipatterns help in MVC architecture?

I do have a chapter titled Magic Beans in my book, about the MVC architecture. The MVC antipattern I see most commonly is for application development frameworks such as Ruby on Rails (and its imitators) to simplify MVC by making the Model an instance of the Active Record data access component. Martin Fowler describes Active Record (http://martinfowler.com/eaaCatalog/activeRecord.html), but he also describes several other data access patterns. Unfortunately, frameworks that try to simplify application development push the idea that all you need is Active Record. Of course most applications in the real world are more complex, and you have to encapsulate that complexity somewhere. So users of these frameworks end up putting a lot of their domain logic into their Controller classes, which leads to fat controllers, code duplication, and difficulty in unit testing.

Sunil Tiwari wrote:2) What are the common pitfalls in DB application development, using Java?

I have standard advice for Java developers:
  • 90% of the issues you will face are related to your CLASSPATH.
  • Of the remaining problems that are not due to CLASSPATH, 90% of those are related to your classloader.

  • This is kind of a glib answer, but I think it's not far from being true. In Java, the biggest hurdle that faces every developer (edit: every developer who uses JDBC, that is) is to try to understand how to load a JDBC driver and get a connection to the database. It's probably the first time a Java developer uses the reflection API (perhaps the only time).

    This isn't the most advanced or complex issue, but it's the most common one, because every developer has to learn to connect to the database first, before doing anything further. And let's face it, there's quite a steep learning curve to understanding the steps of connecting to a database.


    Bill Karwin is the author of SQL Antipatterns: Avoiding the Pitfalls of Database Programming
    Sunil Tiwari
    Ranch Hand

    Joined: Sep 19, 2006
    Posts: 49

    Thanks Bill! Looking forward to read more !
    Gian Franco
    blacksmith
    Ranch Hand

    Joined: Dec 16, 2003
    Posts: 977
    Bill Karwin wrote:...unfortunately, frameworks that try to simplify application development push the idea that all you need is Active Record. Of course most applications in the real world are more complex, and you have to encapsulate that complexity somewhere. So users of these frameworks end up putting a lot of their domain logic into their Controller classes, which leads to fat controllers, code duplication, and difficulty in unit testing.


    ...this is good to hear from someone else Although these frameworks
    have their advantages the remaining 20% is quite tough sometimes...


    "Eppur si muove!"
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: SQL Antipatterns: MVC and Common Pitfalls in DB application development