• Post Reply Bookmark Topic Watch Topic
  • New Topic

Design critique of my application  RSS feed

 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a use case where I have to retrieve data from the datastore, write the fetched data to file and finally do some processing in my main class.

I have the folder structure as,



My dao package has an interface and implementation class for JDBC related code. xxutil package contains properties code. In xmain package I have the call the DAO concrete implementation and also the file operation code. I am thinking of moving the file operation code to DAO layer; will it be a good choice?

Main class code looks like:



How would you improve the code? Where is this lacking considering maintainibility? I don't think the exception handling is upto the mark. Please let me know your thoughts.

I have not pasted the data access layer and properties code, tell me if I should. Mods, please move this if this not the suitable forum.


 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahsan Bagwan wrote:I have a use case where I have to retrieve data from the datastore, write the fetched data to file and finally do some processing in my main class.


Looking at your source package, it looks good. Yet I don't know what kind of classes you will have in your util package.

For DAO package clearly does the DAO stuff (fetch data). If such (modified or not) data need to write back to database then do this here too. However, you are output to file so I suggest you have a IO package instead.

Writing to file may just be a single method (like what you got already), then consider it in the util package.


Sometimes over designing an app may make it harder to maintain. The key is understand what functions/methods you "must" have then choose the appropriate package.
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great insights shared, particulary about utility methods and IO package. Thanks a ton. I'm really happy I can rely on the community here for any technical help.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what sort of experience you have, but if you were to ask me, I would not structure an application by hand but rather use a build tool like Apache Maven to create the project structure for me. Later I would create the packages and put the respective layers in each of those packages.

All the data upon which your application depends on should be written in the DAO layer so that it is maintainable in one single place. Segregating responsibilities and organizing source code in respective packages is just one of the task. The important thing in OO design is to think how your objects interact with each other.

This approach of asking for critique is certainly a healthy way to learn. I appreciate your efforts!
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Joe for your response. I will look into Maven -- having heard much about it -- but at the moment I have to run this project from a batch file. I am soon going to tinker with buid tools.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!