maingroon
maingroon

Reputation: 21

How to determine why method return some value

How I can to determine why I get specifically this value from method? (without debugger, changing code or duplicate them)

Ok, now I explain the meaning of my question. I have big project with many relations and settings and I want to know when expecting result filtered or changed and became not suitable. The main aim is know which of the filters or method filtered expected result.

Of course I checked Annotations and Reflection API but in my case it isn't suitable because have too much cases and arguments.

Thank you for any advice!

Upvotes: 0

Views: 68

Answers (1)

chubbsondubs
chubbsondubs

Reputation: 38857

So it sounds like you need to return an object that describes the decisions made by a filter or method. Something that can summarize decisions in some way. For example:

values = [ 'foo', 'bar', 'bang' ]
constraint = { it == 'foo' }

Result r = filter.apply( values, constraint )
r.value() == [ 'foo' ]
r.input == [ values, constraint ]

Something along those lines. Without much detail provided it's hard to be more clear than that, but Result would be an object that captures not just the output (ie value()), but also the conditions in which it was called. You can make it more complex by combining Results -> Results1 ... ResultsN for composite filters for example. But I don't really understand what you are doing at any level of detail to elaborate. But the idea is that you could envision a graph of results objects that trace the complex logic applied as a filter on a dataset, and interrogate where things dropped out.

Upvotes: 1

Related Questions