• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An abstract Data class

 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

when i'm writing my choices.txt I was wondering about the Data class: is it allowed to be abstract? or should it be a concrete class? instructions don't tell anything about it and for the record: data would implement all methods from sun's interface.

Regards,
Roel

 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

In my assignament was especifield "Your data acess must be called....." for me it's mean concrete class !!!
Let's wait another rancherss
Regardssss
 
K. Tsang
Bartender
Posts: 3404
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Concrete class man cos you need to implement those interface (Sun provide or your own). Eventually if you use a service layer you can delegate those search, create etc methods to the Data class.
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi K. Tsang,

I noticed you past the scjd assignment, congrats

Of course i would have the abstract data class, and a concrete RoomData class for example. and i would use the RoomData class to delegate my service methods to. But if at sun they try to create an instance of Data, it would fail because it's abstract.

But you had a singleton Data, so your constructor of Data should be marked private and so they cannot create an instance of your Data class, so it seems it may be an abstract class. but i won't change it now anymore, to close to the finish line

Kind regards,
Roel
 
K. Tsang
Bartender
Posts: 3404
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abstract class and singleton class are 2 different things I think. Singleton must have a getInstance() method meaning you can create it or have an instance of it. Abstract class you can't even have an instance.

So what methods you have in your Data class if you also have a RoomData concrete class. If RoomData simply overrides Data class methods.... I don't see you need the extra RoomData class.
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi K. Tsang,

I was a bit unclear in my explanation. I meant if a program is used to test automatically your program and program contains coding like this

This program will not compile when Data is abstract class, but also not compile when you have a singleton, because Data.getInstance() should be invoked to get an instance.

The reason why i would make my data abstract and have a concrete RoomData has to do with making the Data a generic data access class which could be used to handle a file with rooms (through the RoomData, which has a speific check for eg. magic cookie and in future maybe also some other specific implementations of Data methods), but could also handle easily a file with customers (through a new concrete CustomerData class extending from Data). So it would become very easy to handle a similar file as the database file with hotel rooms

Kind regards,
Roel
 
K. Tsang
Bartender
Posts: 3404
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel, I see your point why you want to make Data class abstract. In that case go for it, just mention it in your choices.txt document.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic