• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface Pattern for Database abstraction

 
Steve Granton
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm busy working on the design of the project and was wondering if people could comment on my design for Database abstraction.
I'm thinking of implementing three interfaces, DatabaseIf, FieldIf and RecordIf. These interfaces will be implemented by the Data, FieldInfo and DataInfo classes respectively. This provides a layer of abstraction/indirection for the Database services to avoid a tight coupling. Thus, the Data, FieldInfo and DataInfo classes could be swapped for other classes implementing the interfaces and the rest of the application would not need to change.
I think this is a strong design principal but I'm worried as I will need to change some of the method signatures in the db classes to return instances of the interface rather than the class as before.
Will I be penalised for changing the method signatures of the db classes? Has anyone else implemented this sort of design? Should these interfaces be part of the db package or should they be in a separate package?
Cheers,
Steve
[ February 10, 2002: Message edited by: Steve Granton ]
 
Enrico Mannarino
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,
Take a look at this article if you haven’t seen it before.
http://www.javaworld.com/javaworld/jw-05-1999/jw-05-networked.html
I just used an interface for the Data class!
/Enrico
 
Steve Granton
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Enrico
That article looks the business. I might have to change my design slightly.
Cheers,
Steve
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic