EvgenyKarkan/EKAlgorithms

Implement algorithms both using highest Cocoa API and our "white-boxed" implementations.

stanislaw opened this issue · 6 comments

The changed proposed #14 is good but only partially - it is good to know that Apple's reverseObjectEnumerator does its job - and as of Apple recommends to "use highest API possible" - it would be a better choice than to implement it by hands, but I think it would still be great to have both variant of methods to be kept in EKAlgorithms.

What I suggest is to keep both methods side by side, the only trick is again to invent a good convention to handle this:

My initial thought was something like:

+ (NSArray *)reversedArrayWithArray:(NSArray *)arrayToReverse
+ (NSArray *)native_reversedArrayWithArray:(NSArray *)arrayToReverse

or

+ (NSArray *)reversedArrayWithArray:(NSArray *)arrayToReverse
+ (NSArray *)CocoaImplementation_reversedArrayWithArray:(NSArray *)arrayToReverse

But I personally dislike using underscores in method names that is why I also thought about something like

+ (NSArray *)reversedArrayWithArray:(NSArray *)arrayToReverse
+ (NSArray *)reversedArrayWithArrayImplementedByCocoa:(NSArray *)arrayToReverse

For now I think that "CocoaImplementation_reversedArrayWithArray" is the best naming convention to be used for methods showing usage of highest-level of API suggested by Cocoa.

Let me know what you think.


Here are more examples we could write using Cocoa API:

Index of maximum element: [array valueForKeyPath:@"@max.integerValue"]
Binary search from awesome objc.io Issue n7, Binary Search.

Absolutely agreed with you!
As i mentioned on Important note on READ.me - the main idea is not to re-use Cocoa APIs for CS algo-stuff.
I think the more interesting way is to implement CS stuff by the "hard" way.
So we thus can understand - what is under the hood of algo is? IMHO
The naming conventions provided by you - is OK for me. :)

PS
If you don't mind - all the code that you will provide, I will "uncrustify" with my settings.
The main aim is - code style/conventions consistency. ok?

Sorry, what is "crustify"? Whatever it is, I don't mind - just show me how it should be done. ;)

Ok just a few seconds ..

https://github.com/benoitsan/BBUncrustifyPlugin-Xcode

This is a highly configured solution to style/format your code with just one button press.
Must have. IMHO

And this is the MacOSX app.
https://github.com/ryanmaxwell/UncrustifyX
It helps to configure .config file with visible results.

[С точностью до странных и вроде бы пока нерешённых проблем с индентацией ;)] I am happily closing this.