• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

On 486 - Best answers can be incomplete?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A partial class diagram of a college course management application is shown in Figure http://certify.torolab.ibm.com/figures/test486F22.gif
studentInstructor. A student knows all of the instructors he is registered with. Similarly, an instructor also knows all the students who are registered with him. A new requirement is
added which specifies that an instructor can also be a student for some courses. What is the BEST partial application redesign shown in the Figure?
a) Design 'A'
b) Design 'B'
c) Design 'C'
d) Design 'D'
e) Design 'E'

I have read responses to the following on JavaRanch.
The consesus is that C is correct, although lacking, since a student may want to get a list of instructors OR a list of students (since they may be an instructor themselves.)
Does everyone agree with this? My biggest problem with choice C is that it wasnt clear to me how the student could get each of these.
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Johanna,
As you would have gone through the archives of this forum, you would have discovered that this application is based on Role pattern.
The new requirement specifies that a instructor can be a student and a student can be a instructor.This implies that a Candidate can play 2 roles, i.e Instructor and Student.Hence we have a class diagram as shown by Figure C.
Also, any Candidate (who could be a Student or an Instructor) would want to know the other registered Candidates, as per the original requirement.Hence the Role class defines a method, getRegisteredCandidates() : Candidate[] , which will be implemented by its subclasses to get the registered candidates for a particular instance of Student or Instructor.
Let us try to implement this Role pattern to make things would become clearer.
-- Sandeep
SCJP2, OCSD (Oracle JDeveloper), OCED(Oracle Internet Platform)
 
Judy Herilla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I said in my post, I did go through the responses in the archives, and the concept is still not clear to me.
A student may want to get either a list of instructors or a list of students. By calling getRegisteredCandidates() I assume they are getting a list of instructors?
It seems like info is missing from this design which would differentiate between the two requests.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Johanna,
The original requirement is of the student knowing about all his registered instructors and instructors knowing about all his registered students.
The question doesn't mention about student knowing about other registered students.If this is a requirement, then we will require an association between Student and Instructor too.
-- Sandeep
 
Judy Herilla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I gues I was reading to much into this...but the new requirement is that a student can be and instructor. Therefore, I thought a student, may want to know their students.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Johanna,
As per the new requirement instructors could be students for some courses.However, that doesnot change the original requirement of student knowing about instructors and instructors knowing about students.This means the student instance still needs to know only about its instructors; similarly instructor instance still needs to know only about its students.
If students have to know about other students, or instructors about other instructors, then we will require a different class diagram.
One solution would be to have an association between Student and Instructor, in Design C as mentioned in my earlier post.But this could become very clumsy.I believe you will need to implement a new operation/method for the association and also have a boolean attribute in these classes to know for example, an instructor is a student for some other course or not.If yes, the newly defined operation would add it in the Student list of a given instance.
I guess the easier way to go about it will be to follow Design A approach.It shows, one Candidate,(who could be a Student or an Instructor) to hold other Student or Instructor instances.In this case if a candidate is a Student for Course A and Instructor for Course B, then both the boolean attributes for the candidate would be set to true, and ofcourse the array would hold the Candidate irrespective of whether the Candidate is a Student or an Insructor.
Is this is what you were trying to accomplish ?
-- Sandeep
[This message has been edited by Desai Sandeep (edited August 28, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic