Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

extending the database class

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have instructions in my assignment that reads


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



but the class I extended is becoming too-much lengthy, 168 lines and I haven't even implemented single method given by the Sun's interface

since I know from my previous experience it'll soo become hard to manage if I have class much long(say 300 lines) what are the options I have, can I exetnd the Data.java class and provide added functionality, I don't understand what exctly they mean by data-access, is it the class which provides database connection or something else?

some of you suggested in this forum to extend the interface provided by sun , add additional methods required and then extend that interface to provide concrete class, is it going to violate the instructions given in my assignment?B&S 2.1.1
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vaibhav,

I think the requirement means that the data class must implement all the methods provided by the interface, but that doesn't mean ALL the code has to be in the data class, for example you could create additional classes for reading the file, locking mechanism etc and call from the data class.

The only reason to extend the interface or implement another interface is if you need to provide additional methods.

Regards,
Jason
 
Ranch Hand
Posts: 489
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason

Im my opinion...I dont see any problem to have a classe with moore than 500 lines of code...since it have a good organization !
JavaCod Conventions say the "files longer that 2000 lines are cumbersome"....that might be so long.....but 300 lines is very small too.....so you can have your avarage.
 
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 vaibhav,

First of all: could you edit your first post and place the line you copied from the instructions.html between quote-tags (instead of code-tags), it will increase readibility of that line (and this thread).

Secondly you could create (if you want) a DBAccess class which accesses your database file and reads/writes records. Your Data class will have an instance of this class and the read (and other) method(s) of your Data class are just delegated to the DBAccess instance. As long as your Data class implements the given interface (directly or via an own created interface), it will be

And a final remark: my Data class counted 760 lines and 90% of them were code lines. I used only javadoc comments on the private methods, the public methods inherited the javadoc comments from the interface via {@inheritDoc}. And my own created interface counted in total 12 methods (including the ones inherited from the given interface) and 339 lines, so a whole lot of javadoc comments

Kind regards,
Roel
 
vaibhav mishra
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jason


The only reason to extend the interface or implement another interface is if you need to provide additional methods.


this is the reason I want to do it.


@Fernando


I dont see any problem to have a classe with moore than 500 lines of code.



I agree with you but I am quoting this from my own experience, which was a long time ago and code was really ugly(maybe I am more matured now), maybe now I can manage a whole lot , thanks for pointing javadoc convention

@Roel


could you edit your first post and place the line you copied from the instructions.html between quote-tags (instead of code-tags), it will increase readibility of that line (and this thread).


done


Secondly you could create (if you want) a DBAccess class which accesses your database file and reads/writes records. Your Data class will have an instance of this class and the read (and other) method(s) of your Data class are just delegated to the DBAccess instance. As long as your Data class implements the given interface (directly or via an own created interface), it will be



I'was asking the same thing , thanks for answering, I'll do that.
 
    Bookmark Topic Watch Topic
  • New Topic