• 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

An abstract Data class

 
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 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

 
Ranch Hand
Posts: 489
2
Spring Java 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
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser 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: 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 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: 3648
16
Mac OS X Firefox Browser 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: 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 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: 3648
16
Mac OS X Firefox Browser 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.
 
It runs on an internal combustion engine. This ad does not:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic