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

B&S - Contractor

 
Shannon Sims
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I need to retain the record number for each contractor. Since it doesn't seem to belong to the Contractor class, should I have another class which the Contractor extends from so I can retain this record number? Or perhaps...add a contractorID to my Contractor class and set it using the recordNumber? Would Sun count points off for this? I need this record number so that I can update the database. Any suggestions?

Thank you in advance for your help!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shannon,

Record number is not something that is part of a Contractor, but it is something that is part of a ContractorRecord. Have you considered whether changing what your ValueObject is representing will make your representation / implemenation easier?

Regards, Andrew
 
Lara McCarver
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The B&S requirements I have do not expicitly state that there is any type of "Contractor" class. Many of the methods in the DBMain interface take a String[] as an argument, or return a String[], so you can't change them to return a Contractor.

You could add a class that calls the methods in Data, but has its own methods which use a Contractor object instead of a String[], and which return a Contractor object instead of a String[]. In that case, you can put anything you want in your Contractor object, but one obvious choice is to include both the String[] and the record id.

Or are you asking whether one of the fields in the String[] arrays which are passed in / returned by DBMain can include the record number (passed in String form, of course). I guess it is possible that this meets the requirements, but I personally do not think it passes a strict test. For example, here is the Sun-provided description of the read() method:

// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] read(int recNo) throws RecordNotFoundException;


I would not consider the record number to be a record value.
 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,
Could you please elaborate what you mean by ContractorRecord? I have this same assignment BS 2.2.3.
Thanks,
Tom
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tom,

Somewhere within Shannon's solution to the assignment, the String[] data returned from the Data class' methods appear to be wrapped within a Contractor class (at least that is my take on the original post). This is the Value Object pattern, also known as the Data Transfer Obect pattern.

Shannon was asking about what to do with the record number, which doesn't really belong to a Contractor (it is an internal number within the B&S system - it means nothing to the Contractor themselves). So in keeping with Shannon's attempt to wrap the data, I suggested an alternate value object: a ContractorRecord.

Now instead of trying to model what is a Contractor (which doesnt have a record number), we are modelling a database record (which does have a record number).

This might meet Shannon's requirements.

As Lara mentioned though, having a Contractor class (or a ContractorRecord class) is not a requirement of the assignment. So you may not need it.

Does this answer your question?

[I have a tendency to answer questions asked, whether they are required for the assignment or not. I still haven't worked out if this is a good thing or a bad thing ]

Regards, Andrew
 
Shannon Sims
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Sorry for the delayed response...was on vacation for a week. My application is designed to pass the contractor object around, however in order to update the database, I needed to maintain the record number. Ah, yes renaming contractor to contractorRecord would make more sense. I was so dead set on a Contractor class that I didn't even consider changing it. Thanks Andrew!!!

Thanks for everyones reply.
 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if we have a Contractor with name, location etc. And then the ContractorRecord with the recNo how do we tie them together? Does the Contractor object have a ContractorRecord object?


Thanks,
Tom
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tom

I would expect that you would either create a ContractorRecord on it's own (discarding the Contractor class), or incorporate the Contractor within the ContractorRecord class:OrOrSo that shows three out of my two possible solutions

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