Sign in to follow this  
Followers 0
captacha

Textbook question about OOD with odd answer

5 posts in this topic

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?

0

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites
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.
2

Share this post


Link to post
Share on other sites
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'.
3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0