Jump to content

  • Log In with Google      Sign In   
  • Create Account

Textbook question about OOD with odd answer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Captacha   Members   -  Reputation: 141

Like
0Likes
Like

Posted 05 April 2013 - 09:34 AM

I'm currently taking a AP programming course, and since I know most of the material already, I sometimes assist my teacher. The class is studying Object Oriented Progamming and Design in Java. My teacher and I were reviewing questions from the textbook which the class was working on, when we spotted answer that looked suspicious. I don't have the question with me right now, but it was something like this:

 

"What relationship tends to indicate a dependency?

a) IS_A

b) HAS_A

c) KNOWS_ABOUT

answer: c"

 

I was a bit confused about this answer beacuse I have never heard of a KNOWS_ABOUT relationship before this. I am aware of the IS_A and HAS_A relationships from the programming book I read when I first started programming. Have you ever heard about the KNOWS_ABOUT relationship, and are we wrong?



Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9598

Like
3Likes
Like

Posted 05 April 2013 - 09:42 AM

That seems like the right answer. Think of it this way, if your code uses a class in a package as a function parameter, you should import the package. The import tells your code about the package, so your code depends on that package and it "knows about" the package. You can't depend on a class if you don't know about it. If you don't store objects of that class type, you don't have a "has a" relationship, and if you don't inherit from that class you don't have an "is a" relationship.

#3 Ravyne   GDNet+   -  Reputation: 7409

Like
0Likes
Like

Posted 05 April 2013 - 10:09 AM

The answer seems right, as SiCrane explained well. I think the confusion is less about "knows about" and more about what "dependency" means.

 

That said, I don't think I've ever heard the "knows about" relationship described as such, certainly not formally. Out of fairness I'd discount the question unless the course material has explicitly talked about it in those terms, otherwise many students might reasonably assume it to be a red herring. Even then, the question is far from perfect -- both a) and b) take on a dependency as well, and you can only arrive at the right answer by eliminating a) and b) as having gone "too far". Personally, I'm left wanting d) All of the above as a satisfactory answer, but that contradicts that just c) is an adequate answer on its own. If I were the one teaching, I'd probably just eliminate that question.



#4 Anthony Serrano   Members   -  Reputation: 1192

Like
2Likes
Like

Posted 05 April 2013 - 05:41 PM

The thing is that "is a" and "has a" are subsets of "knows about"; however, "knows about" also includes other types of relationships beyond just "is a" and "has a". For example, if object A has a method that acts upon an unrelated object B (like, say, a bullet dealing damage to an enemy, or an enemy tracking the player's movement), then it has to know about object B even though neither "has a" nor "is a" applies.

#5 Paradigm Shifter   Crossbones+   -  Reputation: 5374

Like
0Likes
Like

Posted 05 April 2013 - 05:44 PM

Supersets, not subsets ;) +1 anyways


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#6 Hodgman   Moderators   -  Reputation: 30388

Like
3Likes
Like

Posted 05 April 2013 - 09:21 PM

I'd answer that as 'all of the above'...
"is a" and "has a" are both instances of "knows about", as are "operates on"/"passed as argument"/"makes use of" etc...
All of these are dependencies, which in my eyes is synonymous with 'knowing about'.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS