Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: Class Contractor?

 
Fabio Kimura
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I'm working on B&S assignment, and I am confused: Do I have to create a Contractor class or not? I mean, do I have to create a class to represent the contractors, encapsulating atrributes like name, location, specialties, size, rate, owner, etc. as a Value Object?
If I do, then why the heck the database interface returns a String array instead of an Object or a Contractor in the read method? Also, the create record method has a String array as parameter.

I am very confused, because SUN's SL285 course project has the database interface already returning Value Objects or array of Value Objects (like a Customer class, with name, address, SSN, etc.).

Thanks in advance,

Kimura
[ January 20, 2005: Message edited by: Fabio Kimura ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can edit your original topic title by using the icon like a paper and pencil. And the other text of course.
[ January 20, 2005: Message edited by: Barry Gaunt ]
 
Daniel Simpson
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fabio Kimura:
Hello!
I'm working on B&S assignment, and I am confused: Do I have to create a Contractor class or not? I mean, do I have to create a class to represent the contractors, encapsulating atrributes like name, location, specialties, size, rate, owner, etc. as a Value Object?
If I do, then why the heck the database interface returns a String array instead of an Object or a Contractor in the read method? Also, the create record method has a String array as parameter.

I am very confused, because SUN's SL285 course project has the database interface already returning Value Objects or array of Value Objects (like a Customer class, with name, address, SSN, etc.).

Thanks in advance,

Kimura

[ January 20, 2005: Message edited by: Fabio Kimura ]


I created a Contractor class but I did that because I decided to cache my records. It made reading a heck of a lot easier IMHO
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fabio Kimura:
Hello!
I'm working on B&S assignment, and I am confused: Do I have to create a Contractor class or not? I mean, do I have to create a class to represent the contractors, encapsulating atrributes like name, location, specialties, size, rate, owner, etc. as a Value Object?
If I do, then why the heck the database interface returns a String array instead of an Object or a Contractor in the read method? Also, the create record method has a String array as parameter.

I am very confused, because SUN's SL285 course project has the database interface already returning Value Objects or array of Value Objects (like a Customer class, with name, address, SSN, etc.).

Thanks in advance,

Kimura

[ January 20, 2005: Message edited by: Fabio Kimura ]


You can't modify the interface provided with your assignment. It returns an array of Strings, so you must use those. You can wrap that data in a Value Object (DTO) at any step along the way. I do it after the data arrives at my client. You could also just use the array of Strings and never build a DTO. It's up to you, I use the DTO because I wan't to implement the Comparable interface between data objects so I could sort them and I wanted to provide methods for determining if they were bookable.
 
Vincent Hernandez
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing you gotta keep in mind is that the interface Sun provides is supposed to abstract. That is, it won't be bound to a particular application. If they supplied an interface with Contract arguments and/or return value types, that wouldn't keep the interface as abstract.

With regard to using a Contractor class or not, I sure do. I provide also for a constructor, Contractor(String[]), which converts the string array to a contractor, and a toStringArray method, which outputs the Contractor object to a String[] object.

Why use it? Because it makes things clearer to understand if you wrap that information into a Value Object. I use the Contractor objects within my Data class code. When you read in a String[], convert it using the constructor i mentioned. When you gotta return a String[], call toStringArray.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11888
203
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fabio,

I am very confused, because SUN's SL285 course project has the database interface already returning Value Objects or array of Value Objects (like a Customer class, with name, address, SSN, etc.).


Courses and books cannot give away a solution to the certification assignment. The creators of the courses and books have to create subtle (and sometimes non-subtle ) differences to ensure that candidates for the real certification really do the work.

So you may find that there are several areas where the real Sun Certification assignment differs from the coursework you did. However there should be nothing in the assignment that was not covered in the course. You just have to adapt the course information to fit your assignment.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic