nixzhu / Proposer

Make permission request easier.
MIT License
854 stars 46 forks source link

Async #6

Closed kostiakoval closed 8 years ago

kostiakoval commented 9 years ago

Clean Async code

pigeon-archive commented 9 years ago

What's the purpose of this?

kostiakoval commented 9 years ago

Clean code. I didn't want to include extra lib like Async So made this simple API

pigeon-archive commented 9 years ago

I would advise against using syntax-slimming wrappers that add no extra functionality because clean code is not exclusively about syntax styling. You'll come to realise (sooner or later) that clean code is not only about how easy it is to read, but also how clear it is for you and other developers to understand (and extract what is being achieved).

kostiakoval commented 9 years ago

I agree, but getting familiar with 1 line of code is very easy. GCD API looks very bad in swift

pigeon-archive commented 9 years ago

Maybe for you, but for existing (and new) contributors, they will have to adopt your syntax-slimmer (for consistency) when they need to interact with the GCD API. If your only concern is syntax, consider using NSOperation (as that's an Apple API that wraps GCD plus adds more functionality).

At the end of the day, I am just sharing knowledge. What you do with it is entirely up to you. My team and I tend to avoid small syntax wrappers because they simply create ambiguity and increase the amount of dependencies for no good reason.

kostiakoval commented 9 years ago

Thanks for sharing your thoughts. NSOperation adds much more complexity, I wound't use it here

For me it's all about tradeoffs - Learning curve vs Using benefits. It takes 1 min to learn the GCD.main API but it makes code much cleaner and it also clear what it does. For me benefits are bigger that .

That's just my opinion :)

pigeon-archive commented 9 years ago

I agree that NSOperation adds a lot more complexity, but it also offers cleaner syntax. I think we should stick with dispatch_async(dispatch_get_main_queue()), but it's not my place to say. Hopefully @nixzhu has something to say.