So I have decided to go dive into every class so I have a comprehensive understanding of the inventory mechanism especially the DragItem
class, but I have difficulty understanding about CalculateTakeBack
method and its returns, what does it really do? What is takeBackNumber
and why should be compared to MaxAcceptable
inside the method, for what condition this method supposedly to handle? Thank you very much, I’m really really curious about this. @sampattuzzi
This mechanism was surprisingly hard to get right and look a lot of iteration. The idea is that if you drop a stack onto a slot with a limited capacity, you need to figure out how much the source is going to “take back”. Does that help frame the method for you?
Thank you for responding Sam, that was a tremendous solid summary of what the method really does, and I can dive in more and understand a lot inside the method.
But I think why did I feel so hard to get my head around this because IMHO, the variable name is quite less self-explanatory (or pardon me if it’s just me being a dunderhead to interpret things in such a wrong way ).
And, I just want to confirm something, is that the reason why did you use MaxAcceptable
to return an integer instead of return a Boolean and name the method IsAcceptable
because you wanna give some kind of flexibility to make the slot itself has its own capacity, so it will take back the candidate number of items to its source if it doesn’t fit the destination slot’s capacity?
I am a bit confused with MaxAcceptable before because the actual implementation always returns int.MaxValue
or 0.
That as a variable name wouldn’t personally jump out to me either, I’d more likely think of it in terms of a “slot overflow” or remainder value, and name and then route it accordingly.
Makes sense now it is explained, I guess we just approach things from a different direction sometimes and just wanted to say you’re not alone on this one
I don’t claim to come up with the best names! It’s amazing how hard it can be to find a good name for these abstract concepts. I think SlotOverflow would be a much better name. And yes, that’s why we have a MaxAcceptable return int.
This topic was automatically closed after 7 hours. New replies are no longer allowed.