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

about Room

 
Ramya Ramalingam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I choose to create Room class as DTO with all public fields without get/set methods(loke Roel!).

I created a default costructor which intialize to default values.And another constructor takes String[].

Also created separate util class with methods toString(Room) ,toRoom(String[])... something like that to convert Room objects.

But after finishing my project,I realize I never used the method toRoom,bec I directly created through
Room(String[]) or assigned value directly like room.customerId=12345678 after creating with default
costructor.Then what's the use of toRoom method?

Now I want to know that have I created Room class properly?

Thanks,
Ramya.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just used 2 static methods in an utility class to convert between String[] and Room object (and in the other way).

btw: i would expect that your constructor with String[], uses this toRoom method. Otherwise you have the same logic twice.
 
Ramya Ramalingam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

In my Room(String[]) constructor,I assign array values to the member variables of Room class and return the object.
Did you use only one constructor?
or did you call the toRoom utility inside Room(String[]) constructor?

Thanks,
Ramya.
 
Ramya Ramalingam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops Sorry!I didn't understand your reply.You said you use toRoom.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be completely clear: I didn't define an own constructor in my Room (so only the default no-arg constructor will be present). Conversions between the String[] and Room always occurs with 2 static methods (in a utility class)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic