Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design Thoughts + Can I change the Data Class

 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JavaRanch, I have read some of the design decisions made by others and really appreciate you sharing those with others and also for taking your time to answer others� questions.
I have a new thought on the overall design, but it requires some of the methods to be removed from the Data Class.
For example:
I want to create 5 Interfaces: Database, DataManager, LockManager, SearchEngine and Connection. There will be 1 Database instance, which will have 1 instance of Data (DataManager), 1 instance of LockManager and instances of SearchEngine will be created locally for each search request. In fact, Database will implement all other three interfaces and delegate the job to each of them on request. In this picture, Data will not have find(), criteriaFind(), lock and unlock, instead they will be moved to the LockManager and SearchEngine. Its job is to just manage consistent and solid persistency. Is it okay to move these methods?.
Database will create a connection object for each request and the client will use that to talk to the database, Connection act as an adapter between the client and the database, whereas the Database itself is a delegator as well as a sequencer. In this fashion, the modify method of the Database can get the lock for the record from the LockManager before it delegates the request to the Data.
And another concern, even in local mode, I do not see why client can not have multiple threads doing the job (as in the case of MDI), if not right now, but in the future , application may have to be scaled to handle MDI) and hence the data access need to be thread-safe even in the local mode. Please verify.
This design may be an overkill, but I feel that its simplicity is no less than other solutions being discussed around in the JavaRanch. It is a simple �delegation-of-role� implementation. I will appreciate any suggestions/comments on my design.
Thanks,
-Rajesh
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it okay to move these methods?.

It is ok to do anything you want as long as you can defend yourself on your design.txt document and also in the essay exam.
application may have to be scaled to handle MDI) and hence the data access need to be thread-safe even in the local mode. Please verify.

While a cool enhancement, it is beyond the scope of the assignment, and also they want you to make it not this way to show you can do two versions, one with locks one with out, which demonstrate your ability to handle Interfaces successfully to create a client that doesn't need to know the back end.
If you are going to remove methods, then I suggest extending the Data class to remove them, rather than the delete key, in the nice class that Sun has provided for you
Mark
 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark- Thanks for replying me. You are the only one, who responds to messages, may be you are the only one who understands the design almost.
======================================
If you are going to remove methods, then I suggest extending the Data class to remove them, rather than the
delete key, in the nice class that Sun has provided for you
=================================================
Sun claims that these classes are designed and programmed by a college student. So, why should it stop us from redefining the classes ?.
-=================
Thanks for replying me,
so nice of you.
-Rajesh
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, why should it stop us from redefining the classes ?

Nothing is stopping you. It is a matter of how well you can defend such modifications.
Mark
 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark.
Rajesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic