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

implementing Data interface with 8 methods?

 
Robert Aragon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The interface, Data, has 8 methods that must be implemented. I don't think it wise for a class to implement all 8 methods, too large of a class. So then I figure, create 8 classes, each implements only 1 method and creates method stubs for the other 7.

Anyone doing it this way? Maybe I cannot see the picture slapping me in the face here?

Results in code? 8 classes with 1 implemented method and 7 stub methods.
 
Thomas Paul Bigbee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert

The requirements state

Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:

package suncertify.db;
public interface DBMain {....

In my opinion, and this is just my opinion, the best way to do this is in one class, if you have eight classes with one implemented method and seven stubs you end up with forty-nine stubs, beside the fact that you would have to have another class to manage all of this. The requirements also state that you have to create a document that explains your design decisions, I can't imagine what the grader would ponder when reading the decision regarding the creation of eight extra classes with forty-nine stubs vs the class being too long. Remember also, that "javadoc style comments must be used for each element of the public interface of each class" to provide javadocs for all public methods (the stubs would have to be public) so you would end up with forty-nine extra javadoc comments, with each one saying this is a stub. I don't know but better safe than sorry.

Hope this helps
Tom
 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,

As Tom, rightly pointed out - you would end up with redundancy. I just wanted to caution you, that the JUNIOR Programmers might it find hard to follow. Keep it simple and just concentrate on the MUSTs.
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As pointed otu above, this is a bad idea; don't do it.

If you feel that your class would become too large, find some lower level functionality that you could move into a helper class. E.g. make a class that handles reading from and writing to the file.

Frans.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Robert,

Rather than having 8 classes, you might want to look at whether the Data class has to provide two or more sets of functions that can be grouped together. For example, we have the locking functionality which you might be able to separate from other functionality.

Then you might end up with relatively few extra classes, but each of them will be smaller than the overly large single class you are concerned about. Your Data class would presumably act as a Facade to these other classes (speaking of which, a quick search in this forum using the word Facade (or even Fa´┐Żade) will turn up quite a few discussions about this).

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic