• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reflection to do class auditing  RSS feed

 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of the interview I was asked - "how can you use reflection to do class audit".
By auditing,I guess they mean what has changed in the current version of the class with the previous version of the same class.
I think his intention was more to understand as to how code repository system works (which can show the difference between any 2 versions of class). I am not sure if this understanding is correct .Any advice?

Regards,
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem is that you aren't quite sure what the interviewer meant by the word "audit"? That's my problem too, I'm not sure what it might mean. So my advice is, next time you don't quite understand what the interviewer means, ask for clarification.
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
To my understanding, an audit on a class means what has been changed on a given version to previous one. I did not ask this explicitly to interviewer as this question seemed very obvious to me. However looking at typical reflection usage , I am trying to understand as to how it can be used for class audit and hence reaching to forum.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nitinram agarwal wrote:Hi,
To my understanding, an audit on a class means what has been changed on a given version to previous one. I did not ask this explicitly to interviewer as this question seemed very obvious to me. However looking at typical reflection usage , I am trying to understand as to how it can be used for class audit and hence reaching to forum.


If you're using that definition of class auditing, and if you know the basics of what reflection does, I would think the answer would be obvious. Since reflection lets us examine a class's definition at runtime, we would use reflection to find out a class's fields and methods now, and then later, when the class has changed, we would use reflection to find out a class's fields and methods again and then we could compare the two snapshots.

But really, you're asking the forum what answer an interviewer was looking for when A) We don't know anything about this interviewer or what he was looking for and B) We don't even know for sure what question he was really asking.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nitinram agarwal wrote:To my understanding, an audit on a class means what has been changed on a given version to previous one.

At the risk of sounding facetious, my question to him would be: What makes you think that you would need to "audit" a class at all?

Reflection is a facility offered by the Java language, but it's not pretty; and I go a long way to avoid it if I can. The mere requirement of an audit suggests to me that someone is using the language for something it wasn't really designed for.

However, I'm not the interviewee...

Winston
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that I should have asked him clearly about what he meant. The question did not seem very obvious to typical usage of reflection which I did and I was wondering as to how with a single instance of object , you will do class audit. For auditing it is a must to have current and previous snapshot.. please consider the issue closed.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!