Main


April 23, 2007

Getting Real? Why is Spec a Dirty Word?

Over the last few months, I've spent a bit of time researching various development methodologies and have seen a lot of different approaches when it comes to the software development life cycle. After attending this year's SDExpo, I can say that I had a lot of exposure to some agile approaches and am eager to start incorporating some of these lightweight methodologies. I also happened to pickup (download) the book "Getting Real" from 37 Signals, and have to say it's a great book and offers some great advice.

One thing I don't quite get is the idea that you should *never* write a functional spec.
From the 37 Signals blog post (Feb 2005):

Step 1: Don’t write a functional specifications document
Don’t write a functional specifications document. Why? Well, there’s nothing functional about a functional specifications document.

Functional specifications documents lead to an illusion of agreement. A bunch of people agreeing on paragraphs of text is not real agreement. Everyone is reading the same thing, but they’re often thinking something different. This inevitably comes out in the future when it’s too late. “Wait, that’s not what I had in mind…” “Huh? That’s not how we described it.” “Yes it was and we all agreed on it — you even signed off on it.” You know the drill.

Functional specifications document are “yes documents.” They’re political. They’re all about getting to “yes” and we think the goal up front should be getting to “no.” Functional specs lead to scope creep from the very start. There’s very little cost in saying “yeah, ok, let’s add that” to a Word document.


While I do agree that the point is to build functional software, not perfect specs. There are a great number of situations where the type of product you are building, the size of the team, or the type of organization demands a more structured (and documented) approach to building software. One particular comment on this post caught my eye, and I have to say it summarizes my feeling on this whole debate... to spec, or not to spec? That is the question.

Comment from One of several steves:

I'm highly suspicious of absolutist statements when it comes to software design and development. Always write a functional spec. Never write a functional spec. Both are equally dogmatic and equally full of pitfalls.

A "story" is never going to give developers enough to go on if you're building a web-based app that has to interface with a multitude of exterior systems, legacy databases, etc. Interface design isn't going to help them much, either. Good database diagrams would. Good technical requirements document would. But the "story" and the wireframes and comps aren't going to help them much. And, like it or not, sometimes we do have to make the interface accomodate what's going on in the backend, or else spend a ridiculous amount of money to get legacy technology to behave the ideal way, instead of a reasonable amount of money to get it behave in an acceptable way.

The key takeway is to have the right criteria drive the design and development, and use whatever tools needed to best communicate that. Call them whatever works (as Geoff correctly points out, a BRD by any other name still smells as sweet).

Flexibility and using the available tools to get the job done effectively is paramount. Dogmatic approaches get in the way. "Don't write a functional specifications document" is frankly just as stupid as "Always write a functional spec." Sometimes it makes sense not to; sometimes it doesn't. Dogmatic rules don't encourage that kind of flexibility.

March 23, 2007

SDExpo 2007: Day in Review (3/23/07)

My SDExpo adventure came to a close today. Overall, this year's sessions were really great and I thoroughly enjoyed the conference. I picked up a lot of great information related to Agile methodologies (Scrum, Crystal Clear, Lean) and plan on incorporating them into my studies (and eventually my practice).

Here's a summary of the last few sessions I attended:

Developing Rich Domain Models

Chris Richardson, consultant and author of the book Pojos in Action, discussed how to implement a domain model using POJOs (Plain Old Java Objects). I read Chris' book late last year and overall was very satisified with it. In fact, I would highly recommend this book to anybody who wants to get an intro to peristence (Hibernate, JDO, Ibatis), Spring, and find out how to model their presentation and business tiers. Definitely fantastic! The session today covered many of the topcs from the book, and it was good to have this knowledge reinforced.

Benefits of the Build: A Case Study in Continuous Integration

Kirk Knoernschild, gave a great intro talk on the benefits of implementing continous integration. Here's some more info:

Agile processes such as XP and RUP advocate continuous integration, where shorter iterations produce an incremental and functional growth of the system. The fundamental component of any continuous integration (CI) strategy is an automated and repeatable build. In addition to ensuring your application is always in a functional state, a robust build strategy enables a number of other important lifecycle activities.

War Stories: Fighter Jets and Agile Development at Lockheed Martin

Michael Zwicker, an Agile architect at Lockhead Martin gave a fantastic talk on how Agile methodologies were implemented at his company. This gives a shot in the arm to anybody who is hesistant about trying to go Agile. If it can work at Lockhead, a traditionally waterfall-heavy company, it can work in yours to. Other topics included key value expected and realized, barriers to initially implementing agile and how they were overcome, barriers to further agile adoption, and the value of training and agile tooling.

Michael also recommend an Agile tool that managed the project backlog: VersionOne

Highlights of the day

* After lunch I decided to walk outside for a little bit. I discovered a trail right beside the conference center called the San Tomas Aquino Creek Trail, and had a relaxing 45 minute walk.

* I discovered that the Hyatt right beside the convention center has a "Virtual Concierge" (I'm not kidding). Check out the link.

March 22, 2007

SDExpo 2007: Day in Review (3/22/07)

Today was another information-packed day! I have to say that the sessions on agile methodologies turned out to be really great. Here are some of the highlights of the more interesting sessions I attended:

Transitioning to Agile: A Guide to Good Practices in Context

Michael Cohn, from Mountain Goat Software, gave an excellent presentation on how to introduce an agile process into a company. Michael dispensed some great tips on building teams, picking the right project for making the transition, and dealing with resistance. You can download the presentation and a related PDF on his website:

Transitioning to Agile: A Guide to Good Practices in Context

Introducing An Agile Process to an Organization

One particualr topic that Michael discussed really got my attention. While dealing with resistance and change, there is a popular model that can be used: CDE (Container, Differences, Transforming Exchanges). From the seminar

Self organization (CDE Model)
Container
A boundary within which self-organization occurs (company, project, team, city)
Differences
There must be differences among the "agent" acting in our system
Technical knowledge, domain knowledge, education, experience, power, gender
Transforming Exchanges
Agents in the system interact and exchange resources
Information, money, energy (vision)

I'm fascinated with the topic of change and system models, so I dug a little deeper and found some references to a new field called HSD (Human System Dynamics). The Human System Dynamics FAQ says:

Human systems dynamics (HSD) is an emerging field of research and practice that applies principles of complexity, nonlinear dynamics, and chaos theory to the study of groups of humans as they live and work responsibly in teams, organizations, and communities.

Google turned up a related paper on HSD and CDE titled: After the Dance with Whole-Scale Change(WSC) PDF. I plan on researching this further.

Scrum: A Five Letter Word Geeks to Need Learn

Michael Vizdos, a certified Scum trainer, gave an informative overview of Scrum. Prior to the session I had only briefly heard about Scrum, and by the end of the talk I felt that I had taken away quite a bit to think about. According to Wikipedia, Scrum is:

"... intended (for) use is for management of software development projects, and it has been successfully used to "wrap" Extreme Programming and other development methodologies. However, it can theoretically be applied to any context where a group of people need to work together to achieve a common goal – such as setting up a small school, scientific research projects or planning a wedding."

When asked how Scrum differs from other Agile methodologies like XP, Lean, Crystal and others, here was the explanation:

- Scrum is more of a project management methodology, not software development. Scrum does not dictate how software is constructed.

- Scrum is a great into methodology. Once roles are defined and teams are built, many companies pickup some other methodologies (like Crystal Clear)

- Scrum is also used in other domains (sales, marketing, and program management)

There is also a more detailed process flow for Scrum in the Scrum (development) article on Wikipedia. Here are the highlights from that article:

"Scrum assumes that the software development process is complicated and unpredictable and treats it as a controlled black box instead of a theoretical, fully defined process. This is one of the biggest differences between Scrum and the Waterfall and Spiral methodologies, which view the software development process as a fully defined process. Most problems encountered when using these older, formal types of methodologies are :

* Requirements are not fully understood at the beginning of the process.
* Requirements change during the process.
* The process becomes unpredictable when new tools and technologies are used.

Another characteristic of Scrum is that the software development process isn’t treated as a linear process, unlike the Waterfall, Spiral and Iterative methodologies. In a lot of cases this linear process consists of the following four activities: Analysis, Design, Implementation and Testing. Scrum, however, doesn't prescribe a sequence in which the activities must be implemented. A project can start with any activity, and can change between activities at any time. "

Core Models and Patterns of Web 2.0 - What They Mean to Architects

The final highlight of the day was the informal "Birds of a Feather" gathering at the end of the day by the poolside at the Hyatt. James Ward, Flex evangelist for Adobe, lead a discussion with a group of about 15 people focusing on patterns and trends of the Web 2.0 phenonemon. Discussions focused on security, identity, trust, multi-platform architectures (ESB, MVC, RIA). Overall, it was a great chit-chat and lots of fun.

March 21, 2007

SDExpo 2007: Day in Review (3/21/07)

This year's SDExpo West (Software Development Expo) conference was hosted at the Santa Clara Convention center in Santa Clara, California. The convention center is not far from San Fransisco and is located near the heart of "Silicon Valley".

Overall, the day turned out to be fun and very informative! The SDExpo conference focuses on many areas of the software development sector: Java/C++/.Net, Web 2.0, process and people management, the business of software, testing, development methodologies, architecture and everything in between.

My main focus for this conference is on People, Process & Methods. But, I did attend some more techy presentation and picked up some great information. Here are some of the more interesting things I learned:

Combining Flex and Ajax to Overcome Browser Limitations

James Ward, a technical evangelist from Adobe Systems, gave an informative and compelling talk on the benefits of mixing Flex (Flash) and Ajax. I haven't dug into Flex as of yet, but did learn a bit about it from this article a couple months ago:

How and Why AJAX, Not Java, Became the Favored Technology for RIAs
http://ajaxworldmagazine.com/read/333329.htm

Here is a description of Flex from this article:

"Flex is a way to develop Flash applications by programming. It includes a declarative XML language called MXML for laying out user interfaces, and a programming language called ActionScript, which is a superset of ECMAScript (that is, standardized JavaScript), with extra features like optional static type checking....... Flex applications compile directly into SWFs (Flash binaries), which are then Just-In-Time (JIT) compiled by the Flash runtime, for extra speed."

James demonstrated quite a few visually impressive "Web 2.0"/RIA (Rich Internet Applications) that showcase what the next generation of web applications are starting to look like. Gone are the days of boring static HTML pages, tons of page reloading, and user boredom. Technologies like Flash, Flex, and Ajax are beginning to make web applications like like traditional desktop programs (and better in many cases).

Two particular things that interested me where the announcement of Adobe's Apollo desktop engine, which allows web developers to create rich web applications and run them on the desktop (Windows and Mac, and Linux is forthcoming). And, an interesting benchmark application, that illustrates the different technologies that are used to transmit information between client and server. XML, SOAP, JSON, and a new binary protocol from Flash that appears to be significantly faster than the rest.

Crystal Clear: A Human Powered Methodology for Small Teams

Alistair Cockburn (Pronounced Co-Burn, the Scottish way) gave a great lecture on the Crystal family of development methodologies. I've just started my journey looking into Agile development (XP, Agile, Lean, Scrum, Crystal) and I have to say that the Crystal approach looks very promising. Per Wikipedia:

Crystal Clear is a member of the Crystal family of methodologies as described by Alistair Cockburn and is considered an example of an agile or lightweight methodology.

Crystal Clear can be applied to teams of up to 6 or 8 colocated developers working on systems that are not life-critical. The Crystal family of methodologies focus on efficiency and habitablity as components of project safety.

Crystal Clear focuses on people, not processes or artifacts.

Crystal Clear contains the following properties (the first three are required):

* Frequent Delivery of Usable Code to Users (required)
* Reflective Improvement (required)
* Osmotic Communication Preferably by Being Co-Located (required)
* Personal Safety
* Focus
* Easy Access to Expert Users
* Automated Tests, Configuration Management, and Frequent Integration

Key Note: Why Software Sucks

David Platt gave an enjoyable, comedic, and sobering lecture on the topic of his book of the same name:

Why Software Sucks.... and what you can do about it

From David's website, here is an overview:

A Book for Anyone Who Uses a Computer Today … and Just Wants to Scream!

Today’s software sucks. There’s no other good way to say it. It’s unsafe, allowing criminal programs to creep through the Internet wires into our very bedrooms. It’s unreliable, crashing when we need it most, wiping out hours or days of work with no way to get it back. And it’s hard to use, requiring large amounts of head-banging to figure out the simplest operations.

It’s no secret that software sucks. You know that from personal experience, whether you use computers for work or for personal tasks. In this book, programming insider David Platt explains why that’s the case and, more importantly, why it doesn’t have to be that way. And he explains it in plain, jargon-free English that's a joy to read, using real-world examples with which you're already familiar. In the end, he suggests what you, as a typical user, without a technical background, can do about this sad state of our software—how you, as an informed consumer, don’t have to take the abuse that bad software dishes out.

December 16, 2006

Mind Mapping and the Software Development Life Cycle



  I've recently started looking into how mind mapping is used in the software/system development life cycle. One of my passions (and profession) is software design and development. Since I started mind mapping a few years ago, I've been slowly introducing mind maps at my current job.

I began using mind maps (courtesy of Mindjet's MindManager Pro) to help streamline the process of researching new technologies and products. I discovered that this technique was much more efficient than trying to use traditional bookmarks (or del.icio.us for that matter), or knowledge managers (like General Knowledge Base or DevonThink). And, I could quickly share with others, without needing to create a separate document to summarize my findings.

Over time I increased my usage of mind maps to encompass capturing meeting notes, product requirements, and technical design discussions. Although I wouldn't typically use mind mapping techniques during any whiteboard sessions, I would capture meeting notes afterwards and convert to a mind map. When sharing maps with others, I would upload to our intranet in both MindManager format and export as HTML for people who hadn't yet downloaded the mind map viewer.

As a whole, I would say the feedback and general acceptance of using mind maps for our projects has been very positive. On numerous occasions, team members would still be consulting the maps even months after a meeting had taken place. And, I personally think that reviewing the mind maps after a tradional meeting/whiteboard session can really improve communication and recall of the information later on.

I became curious as to how other individuals and organizations are using mind maps in their development process. After reading Chuck Frey's excellent Mind Mapping Survey, I discovered that a large percentage of the survey respondents (500 people in total) are using mind mapping for project planning (52%) and business process mapping (30%). And, of the people that listed their mind map use as "other" (9%), there was mention of documenting software requirements, and software development and modeling.

I decided to start Googling on this topic and came up with some interesting results. The following are some links and resources related to the use of mind maps in various phases of the SDLC (Software Development Life Cycle).

Investigation/Feasibility/Planning

Mind-mapping tools are finding a home in corporate IT
http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=112247

Using mind mapping software for web research
http://mindmapping.typepad.com/the_mind_mapping_software/2006/10/using_mind_mapp.html

Turning systems models into projects
(Related to ORM - Outcome Relationship Model)
http://duffill.blogs.com/beyond_crayons/2006/07/turning_systems.html

Funnel timeline: A visual approach to project planning
http://mindmapping.typepad.com/the_mind_mapping_software/2006/12/funnel_timeline.html

Project estimating - Mindmaps are a tool in the armory
http://www.mind-mapping.org/mindmapping-for-project-management/project-estimating-with-mindmaps.html

How to use mind mapping software for project management
http://www.innovationtools.com/Articles/ArticleDetails.asp?a=148

Mind Mapping and Project Management
http://www.mindmappingstrategies.com/project-management.aspx

Mind maps provide a view for collaboration
http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=112247


Analysis

Agile Modeling with Mind Map and UML (StickyMinds Article)
http://www.stickyminds.com/testandevaluation.asp?Function=edetail&ObjectId=11861&ObjectType=ART

Utilizing Mind Maps for Essential Use Case Specification
PPT (PowerPoint)
HTML

MindManager for Software Development: Part 2 - Requirements Gathering
http://mindjetlabs.com/cs/blogs/synergist/archive/2006/11/07/MindManager-for-Software-Development_3A00_-Part-2-_2D00_-Requirements-Gathering.aspx


Design

Sharp Development - Mind Mapping for OOAD (Object-Oriented Analysis and Design)
http://www.sharpdevelopment.com/MindMapping/MindMappingForOOAD/MindMappingForOOAD.htm

Agile Modeling with Mind Map and UML
PDF
HTML

UML Modeling Tool - JUDE
(Convert Mind Maps to UML)
http://jude.change-vision.com/jude-web/product/professional.html#mindmap_convert


Coding

Generative Programming with MindManager and XSLT
http://blog.mindjet.com/2005/12/generative-programming-with-mindmanager-and-xslt


Testing

Mind Maps Foster Thorough Test Design
http://www.infoq.com/news/2006/11/test-design-mind-map
Original Article

Mind Mapping for Test Planning
http://www.sharpdevelopment.com/MindMapping/MindMappingForTestPlanning/MindMappingForTestPlanning.htm


Implementation/Integration

MindManager for Software Development: Part 1 - Help Authoring
http://mindjetlabs.com/cs/blogs/synergist/archive/2006/10/07/MindManager-for-Software-Development_3A00_-Part-1-_2D00_-Help-Authoring.aspx


In the near future, as mind mapping becomes more mainstream, I can imagine that various mind mapping techniques and products will be used to streamline the software development process. Personally, I think it would be a great use of time to come up with a set of common mind map templates for use in software development projects. Something along the lines of ReadySet, or Steve McConnell's Software Project Survival Guide templates. This sounds like a great pet project for 2007.

In the meantime, I'd be interested in hearing any feedback on how individuals or organizations are currently using mind maps in their development process.

November 07, 2006

CVSHistory - A Great Addition to ViewCVS/ViewVC

I just found out about a great project called CVSHistory at http://jamwt.com/CVSHistory/. This application (written in Python) provides a web-interface for listing/searching a CVS history file, and can either be used in stand-alone mode, or integrates with ViewVC (formerly called ViewCVS).

The most compelling feature to me is the ability to get history entries as an RSS feed. I've been using ViewVC (business and personal) for a number of years. But, switched to FishEye at work for my last major project. The FishEye product is great, and honestly my main motivation for making the switch was RSS feed export. Unfortunately, I can't justify purchasing a FishEye license for my personal projects. But, now that I have CVSHistory in conjunction with ViewVC, this gives me exactly what I need.

April 28, 2006

Removing the login prompt from the Eclipse Koders plugin

Koders.com is a search engine for open source code. I've been aware of this service for sometime and find it very useful on occasion to locate different code snippets. I know that they started offering plugins for various IDEs and figured that I'd give the Eclipse plugin a shot.

My first impression of the plugin was fairly good. At first glance the plugin appears to be really just launching the koders.com site inside Eclipse using the embedded browser. However, I feel there is some use in this since you don't have to change context and switch outside of Eclipse. Plus, the SmartSearch feature seems like it could be useful since it offers real-time code recommendation from within the editor.

Today, I needed to start and stop Eclipse a number of times and quickly noticed the good points of the plugin fade away. Each time Eclipse starts, the Koders plugin requires that you either login or register.

Although I technically could hit Later every time I start Eclipse, I *really* don't want to do this. In fact, I question why Koders needs my information in the first place. If having this login gives access to features you would not have otherwise, then this registration should be entirely optional. The website does not require you to login, so why should the plugin? Just as I was ready to completely perform an uninstall, I decided to see if I could shut off this login prompt under the plugin preferences. Unfortunately, this was not the case. So I decided to peak at the plugin .jar file and found a quick n' dirty way to prevent the login prompt from popping up.

There is a class called LoginForm inside the EclipsePlugin.jar file. Simply remove this from the .jar and no more login prompt. Follow these steps and you're good to go:



1) Install the koders.com Eclipse plugin either manually or through the update site. I've tested with version 0.9 beta 2.

2) Restart Eclipse and you should have a directory called com.koders.eclipse.searchplugin_0.9.0 under your plugins folder.

3) Shutdown Eclipse. Now you have access to EclipsePlugin.jar. You can either do this manually, or run this .bat file to remove the class.

@echo off

REM This was only tested under WinXP, use at your own risk. I'm not responsible
REM if anything "funky" happens ;)
REM Change the following directory to match your eclipse home and plugin directory

cd c:\eclipse3.1\plugins\com.koders.eclipse.searchplugin_0.9.0
copy EclipsePlugin.jar EclipsePlugin.jar.bak
mkdir tmp
copy EclipsePlugin.jar tmp
cd tmp
jar -xvf EclipsePlugin.jar
del com\kodeshare\ui\LoginForm.class
jar -cvf EclipsePlugin.jar .
cd ..
move tmp\EclipsePlugin.jar .
rmdir /S /Q tmp

4) Restart Eclipse and you should no longer see the login prompt.

Happy Koding!

February 24, 2006

Essential Eclipse Plugins

I've been using Eclipse now for a few years (Since version 2.1), and one of its best features is the great selection of plugins. The de-facto sight for getting the latest and greatest plugins is at http://eclipse-plugins.2y.net/. This site has really helped me find a great selection.

The following list is only a *fraction* of the plugins available, but these are ones that I consistently use on a day-to-day basis and find increndibly valuable. But, just like most things... Beauty is in the eye of the beholder... so I may have missed some obvious/popular plugins. I'd be interested in finding out what other popular plugins are out there, and what other developers like best. All of these plugins I've listed are not targeted for a specific development environment. They are equally applicable for Java, Perl, or C (or others).

Logging


Name: Log4E
Website Url: http://log4e.jayefem.de/
Eclipse Update URL: http://log4e.jayefem.de/update
Product Version: 1.1.6
Price: Free / Professional Version = 5,5 Euro (~ $6.54 USD)
Description:

This plugin helps automate creating Log4J logger declarations, insertions, and modifications.


Name: Log4Eclipse
Website URL: http://www.sourceforge.net/projects/log4eclipse/
Eclipse Update URL: N/A
Product Version:
Price: Free
Description:

This plugin is a chainsaw-compatible network listener for Log4* SocketAppender streams. This plugin is very similar to another free plugin called Ganymede, available at http://sourceforge.net/projects/ganymede/. I just recently started evaluating Log4Eclipse when I upgraded to Eclipse 3.1, and I'm very happy with it so far. I'm going to give it a try for a little while longer before I decide to permanently switch from Ganymede.


XML Editing


Name: XML Buddy
Website URL: http://www.xmlbudy.com
Eclipse Update URL: N/A
Product Version:
Price: Free / Professional Version = $35.00 USD
Description:

This plugin supports a number of features including support for DTD, XML Schema, and XSLT.


Database


Name: Eclipse DBExplorer
Website URL: http://www.diligent-it.com
Eclipse Update URL: N/A
Product Version: 2.2
Price: Free / Professional Version = $35.00 USD
Description:

This plugin supports a database browser, HTML export, SQL Runner, and interface for executing SQL queries.

Configuration Management

Name: Eclipse Ant Explorer
Website URL: http://www.yworks.com/en/products_antexplorer_about.htm
Eclipse Update URL: http://www.yworks.com/eclipse/update
Product Version: 1.0.1
Price: Free
Description:

This plugin supports a graphical visualization of ant scripts.

October 12, 2005

Getting XMLSpy to support EXSLT dynamic functions

Recently I have been using XSLT to transform XML from one format to the other. I use Xalan (for Java) in the application itself, but often develop and debug with XMLSpy. I needed a way for XSLT to dynamically evaluate and select a given string, and found no easy way to do this other than the EXSLT dyn extentions.

After implementing the evalute() function, I quickly discovered that neither the default XMLSpy XSLT engine, nor MSXML recognize it. So, after a few fruitless attempts I finally decided to use the same engine that I'm using in the Java application. I simply needed to go under Tools -> Options -> XSL, then select External XSL Transformation Program.

Input:

java -cp XALAN_PATH\xalan.jar org.apache.xalan.xslt.Process -in %1 -xsl %3 -out %2

Now everything transforms as expected!

September 20, 2005

Real Rhapsody uses SQLite for its database

By shear coincidence this evening, I discovered that Real Rhapsody is using SQLite for it's local cache. After some brief inspection, it looks like this db is used to store playlists, user credentials, radio stations, and info about music that was imported from local disk. I thought this was pretty cool since I'm a big SQLite fan and it's good to see its use in such a widely used application.

For whatever reason, Rhapsody was taking much longer than usual to load. I decided to load up File Monitor from www.sysinternals.com to see if anything interesting came up. As it turns out, I noticed quite a few READ attempts for "C:\Documents and Settings\username\Application Data\Real\Rhapsody\local.seb". This peeked my curiousity, so I loaded up my hex editor and found that the file header contained:

** This file contains an SQLite 2.1 database **

I've done a bit of SQLite development in the past, so I happened to have the CLI, ODBC driver, and graphical browser already installed. I loaded up Visio to create a database diagram, but the SQLite ODBC driver had problems. So I quickly exported this to an Access database so I could see the table layout.

August 13, 2005

Persistence Strategies: DAO (Data Access Objects) and ORM (Object-Relational Mapping) - Part 2

Article 2: DAO - Data Access Objects

Some time has passed since my first posting. My investigation on persistence originally focused on DAOs. I was looking for a relatively simple way to persist data, without a full-blown persistence solution (like Hibernate, OJB, or iBatis). Before I get too far ahead, a definition of DAOs are needed.

Data Access Objects (DAOs) are a design pattern, popularized by Java, that essentially separates your presentation code from your persistence layer. Or, the code that is responsible for reading/writing your objects to and from disk/database/memory. DAOs provide a layer of abstraction for basic CRUD (Create, Read/Retrieve, Update, and Delete) operations.

After some experimenting, I quickly discovered 2 key points:


1) DAOs work great by themselves for simple requirements: 1 object = 1 table

2) DAOs and other persistence solutions are by no means mutually exclusive. In fact, they really should be used in conjunction wherever possible.


On the first point, let's use the example of having both Customer and Order objects. In this scenario, the relationship between Customer and Order is 1 to many, m:n (A given customer can have multiple orders). And, to make things more complex, this association can be made bidirectional. Meaning, that the Order object may need to make a reference to the Customer (possibly via a getCustomer() method).

While experimenting, I discovered a great (and free) online DAO generator (http://titaniclinux.net/daogen/). DAOs are a great candidate for automatic generation since there is a great deal of replication between each implementation. In this case, DAOgen essentially prompts you to provide a table name and corresponding columns, along with a class name and corresponding properties. When it is done, your class and DAO will be generated for you. In the case of Customer, the following methods were generated for the DAO:

delete() deleteAll() load() loadAll() searchMatching() create()
All CRUD methods are here and the SQL queries are dynamically generated and placed inside the DAO implementation. This system works great when dealing with single objects. But, in the Customer->Order relationship, some manual coding is needed in the Customer DAO to instantiate a Order DAO and load all Orders for the given Customer. This is certainly doable, but probably does not scale well for a more complex system. Especially one that has a deep object graph, and is hierarchical in nature.

On the second point, the key thing to keep in mind is that DAOs are really solving a different problem than persistence, or ORM (object relational mapping) itself. DAOs are really one strategy for implementing a generic data access layer. While ORM, is strictly responsible for mapping your objects to your database (directly to tables themselves or SQL mapping). Together, both the DAL (Data Access Layer) and ORM form a total persistence framework.

While researching DAOs, I've put together a list of good sites on the topic. Along with some links that focus on general design patterns, best practices, business object, and data transfer objects. I posted this info on the iBatis mailing list the other week. This has now been incorporate into their Wiki, under "Where can I get more information about Data Access Objects". Here is the original list, along with some additional links.

DAO Resources

iBatis DAO http://www.onjava.com/pub/a/onjava/2005/08/10/ibatisdao.html
Data Access Object (DAO) J2EE Pattern http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

Transfer Object (DTO) J2EE Pattern
http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html

Protecting the Domain Model
http://www.theserverside.com/news/thread.tss?thread_id=34278#172661

Pattern Problem
http://forum.java.sun.com/thread.jspa?threadID=569418&tstart=225

General Design with BO's, DTO's and DAO's
http://forum.java.sun.com/thread.jspa?threadID=582832&tstart=134

Using BeanUtils to avoid duplication between DTOs and BOs
http://www.javaranch.com/newsletter/July2003/TouringTheCommonsPart1.html

DAO Generator
http://titaniclinux.net/daogen/

FireStorm DAO Code Generator
http://www.codefutures.com/

DAO Examples
http://daoexamples.sourceforge.net/

One big Service class or several small classes?
http://www.theserverside.com/news/thread.tss?thread_id=23705

Custom-Grained Data Transfer Objects
http://www.practicalsoftwarearchitect.com/articles/customgrained/customgrained.html

Dynamically generate DTOs with DynaBeans
http://www.javaranch.com/newsletter/200404/Commons_Part3.html


The final article will focus on some popular open source persistence frameworks.

April 25, 2005

Persistence Strategies: DAO (Data Access Objects) and ORM (Object-Relational Mapping) - Part 1

Article 1: Overview

I've been working on some recent projects, both personal and professional, where the topic of object persistence has come up. As I've learned over the last few months, while this is certainaly a common problem and there are no shortage of solutions out there, this can be a challenging area. While researching different solutions, I've focused both on generic design patterns and best practices, as well as language/platform specific implementations. My area of interest has really focused on solutions for both Perl and Java. However, there are far more (and more mature) options out there for Java at the moment.

Generically speaking, data/object persistence essentially boils down to one of two categories:

  • You need a way to persist, or store, your business objects for retrieval at a later time. Top->Down: Applies to new projects where you aren't constrained by a legacy schema.
  • You need a way to take an existing database schema, and provide a high-level OO domain model (business objects). Bottom->Up: Existing projects where you must map between your database tables and your business objects. Typically a 1:1 mapping between your table and class.

As with most people, my perstistence requirements fall into category 2. One of the challenges is in the scenario where there are many tables and there is a hierarchical relationship between objects. As a very generic example, lets say you have 4 objects.

Objects A, B, C, D

Where A can have 1 or more B, B can have 1 or more C, and C can have one or more D. While this 1 to many (m:n) relationship may not be that uncommon, the challenge is database load and performance. If you instantiate object A, you more than likely would not want a cascaded load where all objects are loaded. This is particualy true if your collections have tens of thousands of rows. This is where the decision to use best patterns and practices to roll your own solution, and choosing an existing perstistence framework becomes much easier. Solutions such as IBatis and Hibernate support lazy loading and caching, which address these issues.

Before I get into the topic of perstistence frameworks, I've done some investigation on DAO (Data Access Objects) and will publish this next. While DAO is not a full fledged perstistence solution, it does provide a clean way to seperate your business objects from your data retrieval mechanism (i.e. Removes SQL from your code). Over the next few weeks I plan on posting my findings as I make progress. My hope is that some of my findings may be helpful to people who have just started research similar to this.

November 12, 2004

Adding navigator filters to Eclipse 2.x

For the last year or so, I've been using Eclipse as my IDE. One limitation that I've noticed with Eclipse 2.1 is the inability to customize file extention filters. These filters are important because every time you checkout files from the CVS repository a new CVS subdirectory is created. And, each time you recompile, there will be dozens of *.o object files.

Since you can't customize the filters anywhere in the UI, you'll have to define the filters manually. To do this, you'll need to do the following:

1. cd to %eclipse_root%\plugins\org.eclipse.ui_2.x.x

2. Edit the file plugin.xml

3. Search for "<filter" and you should find the filter definition for the pattern ".*"

4. After this definition, add your own filters. For example:

     <filter
          selected="false"
          pattern="CVS*">
    </filter>
    <filter
          selected="false"
          pattern="*.o">
    </filter>

5. Restart Eclipse, then open the Navigator view. If it's not already open, go to Window -> Show View -> Navigator. Click on the Down Arrow/Menu, then Filters. You should see:


Select your new filters and you're ready to go!

Continue reading "Adding navigator filters to Eclipse 2.x" »