Fixes wildcard resolving for non-existing paths (issue #814) #815

Merged
merged 1 commit into from Apr 15, 2012

Projects

None yet

2 participants

@HenningJ
Quicksilver OS X member

Return original string instead of nil if path can't be found during wildcard resolving. Fixes issue #814.

Btw. this is a good example why unit tests are great:
There were unit tests in place for all the intended behavior I knew about. For every change I made, I could just run the unit tests to make sure that I didn't break anything of that.
And to fix the bug, I just added a (failing) test representing the bug. And once the test passed, I knew I had fixed the bug. Without breaking anything else. :-)

@pjrobertson
Quicksilver OS X member

Should the new method be declared in the header, and is there a reason at all for the new method? Is it required to have a method that returns nil for some reason and one that returns the original string?

@HenningJ
Quicksilver OS X member

Should the new method be declared in the header

It's a internal/private method, therefore it should not be declared in the public interface/header file. It could be declared in a private category in the implementation file. But since its implementation appears before the first (and only) time it's used, it doesn't need to have a @interface definition. I'm not sure what's the convention here.

and is there a reason at all for the new method? Is it required to have a method that returns nil for some reason and one that returns the original string?

The subStringByResolvingWildcardsInPath recursively calls itself over and over and returns nil on one of its stopping conditions. It could also all be kept in one method and return the original string instead of nil. But I felt this way was easier and probably faster (you'd have to do lots of string comparisons, which are way more expensive than checks against nil). The method that's just a starting point for another recursive method is a pretty common pattern.
I hope that clears it up. :-)

@pjrobertson
Quicksilver OS X member
@pjrobertson pjrobertson merged commit 74c0bb2 into quicksilver:master Apr 15, 2012
@pjrobertson
Quicksilver OS X member

Merged, pushed to release.

Looking through it a bit more, I understand the reason for 2 methods now, seems clearer :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment