Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

My design is based on an assumption: the database has only one datafile. What if it is wrong?

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Data class is for one table, that's for sure, because the operation is based on records.

Well, one database can only contain one table, that's ridiculous .

So suppose the database has two tables, then we need two files at least, and we need two distinct Data classes (make sure one Data class corresponding to each file) . Then we need an DAOManager to pick up which Data class (now DAO) to use in RoomServices or CustomerServices. DAOManager must be singleton, that's for sure. But Data class can be more than one, as long as no Data class share the same datafile. DAOManager act as a Factory, so called it DAOFactory.

This design overthrows my previous design since this new assumption makes sense. I chopped off the DataAccessor, and introduced DAOFactory. So it will be easy to add a new table (file) into my design, all changes will be encapsulated in DAOFactory.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have often argued against a singleton for the Data class simply because I don't feel that a single table per database is a good design decision.

One alternative is that recommended by Phil Maquet - he recommended having an effective singleton per table - search for "Multiton" in this forum to see more of his design.

I will say though, that many people pass with a singleton design. One of the Agile principles is "Simplicity--the art of maximizing the amount of work not done--is essential". This is often described various ways, but the reasoning behind it is simple: work that is not needed right now is often wasted work. In concrete terms, imagine if you spend the next 6 months developing a wonderful system where you can have as many databases as you like, with as many tables in each database as you like, all accessible through the Data interface. Then just as you are nearing completion, the business owners choose to put all the data in an Oracle database. That 6 months is now wasted work. This holds true quite often in real life as well: the further you go beyond scope, the more likely that your enhancements will be wasted.
 
Jianping Wang
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

It's great to have you here!!!

It's really challenging to take SCJD. The assignment must meeting all "must requirements" and must not over-complicated (The simplicity you mentioned).
All the troubles come out from this line saying something about enhancements.

Your user interface should be designed with the expectation of future functionality enhancements, and it should establish a framework that will support this with minimal disruption to the users when this occurs.


None knows what this "future functionality enhancements" would be. May be it implies adding a customer file for the billing step of booking transaction, or may be it just means another button for cancelling a booking.

Simplicity is really not simple. It requires accurant understanding of requirements and a little bit of gambling: chopping off those parts that might be must requirements and at same time might be enhancements out of scope.

No one wants to fail the exam. So actually this incentive influnces my design.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jianping,

I have 2 acronyms for you: KISS and YAGNI. The last one we use quiet often during development, certainly if requests starts with: "But what you gonna do if sometime ..."

Kind regards,
Roel
 
Jianping Wang
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,
That's funny!!!

Now the design is completed. I gonna begin coding and testing.

Thanks for all your advices. Without them my design was doomed to fail.

Best Regards,

Jianping Wang
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic