This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I continue the question postings of Ram Dhan Yadav K here. I am very confused about this question. Please offer your answer and understanding here. Thanks. Q) A partial class diagram of a college course management application is shown in the exhibit. A student knows all of the instructors with whom s/he is registered with. Similarly, an instructor also knows all students who are registered with him/her. A new requirement is added which specifies that an instructor can also be a student for some ourses. What is the BEST partial application redesign shown in the Figure as linked. Single Select: a) Design 'A' b) Design 'B' c) Design 'C' d) Design 'D' e) Design 'E'
Hi Tang, In C, the Student and instructor are subclasses of Role. This is the best way of usage of inheritance. Now a Candidate is associated to Role and that Role can be either student or Instructor or both from the association shown. Hope this helps!
Ram Dhan Yadav (SCJP, SCWCD, SCJA-I, IBM EC(483))
"We are what we repeatedly do. Excellence, then, is not an act, but a habit."
I believe the answer is design (E). Because of polymophism and inheritance. And what I mean by that is that both the Student and the Instructor are subtypes of the base class Candidate... Therefore Student or Instructor "is a" Candidate. But also keep in mind the question states a "student knows his/her instructors" and a "instructor knows his/her students" and now an instructor can be a student. So we need an array or collection to store this information for each student-instructor(s) and instructor-students(s). But since Instructor and Student are Candidates the Array can be of type Candidate(SuperType). So, Now we can can store those instructors that are also students. So in my opinion I believe design (E) is the BEST partial application redesign.
The partial class diagram indicates that a student can list his registered instructors and instructor can list his registered students.The new requirement indicates that instructor able to register for other courses, that means Instructor able to list his registered students and registered instructors. Is it correct, if yes how design 'C' & 'E' satify the above requirement. Please correct me if anything goes wrong.
Joined: Mar 19, 2002
I just wanted to elaborate more on why I chose design (E) instead of (C) or design (D) which is basically the same as (E). I chose design (E) because it shows shared-aggregation(unfilled diamond) and design (D) does not. The reason being is that the composite-whole(Role class) has an operation(getRegisteredCandidate()) that propagates to the aggregate element(Candidate class) and also because of shared-aggregation the aggregate-element(Candidate and any subtypes) does not have to depend on the composite-whole(Role class) for creation or deletion. And also the Candidate class can be referenced elsewhere in the design. If there is anybody else with a different opinion or an alternate solution, please advise. craig j.
I just about went along with craig on this. But "e" can not be correct. The role class does not identify any one. It also does not allow for multi roles. You are either a instructor or a student not both. C appears to be right. It has a base candidate class that identifies the individual and has the ablitie to have many roles (arrays of students or instructors for each role).
Joined: Jan 30, 2002
Hi cj jack, can you please exaplain me, how design 'E' get the list of registered instructors for Instructor candiate, because instuctor can be register for other courses also, he wants to know what other instructors he registered. Can you also please exaplain me what wrong with design 'A'. Thanks in Advance. CCR
Joined: Mar 19, 2002
After searching the forum for this particular question, I have come to the conclusion that design (E) may not be the best answer. I now can see why design (C) would be the better design, finally. This is one of the harder questions for me to answer. But hey, my original answer at least sounded good. craig