Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Type safe objects, or just String[]?  RSS feed

 
Colin Yates
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

Are you guys (+ girls ) just passing String[] back and forth or do you have a Type safe object, i.e. a value object call Record, or Row with a getName, getLocation etc.

My initial reaction was to have a type safe object, but I cannot really justify it.

What are you lot doing?

Thanks,

Col
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Colin,

In the interface I used String[] of course, because that was required.

In my Data layer I had a Record class that wrapped around the String data.
In my Business layer I had a Contractor class (my assignment was Bodgitt&Scarper), which indeed featured methods like getName, getLocation etc.

Frans.
 
Colin Yates
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And may I ask what was your "justification"? The examiners didn't mark you down for this?

It is my natural instinct to do this, but I cannot justify why
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also thought it is just good practice. I didn't even occur to me that I would have to justify this.

If you feel that you must, you can probably connect it with the 'must' that your code should be readable for junior programmers.

Frans.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!