AFNetworking is presented as a robust, lightweight, open-source library that simplifies complex HTTP request operations in mobile development.
Cheesecake Labs uses AFNetworking in two projects with different approaches: directly importing its functions in one, and building an intermediate abstraction layer in the other.
Using the library reportedly reduced code drastically (e.g., 15,000 lines down to a few) while avoiding bugs, thanks to active community collaboration.
The post argues that rewriting projects from scratch is often avoidable when reliable, widely-used libraries like AFNetworking are available.
“Choose AFNetworking for your next project, or migrate over your existing projects—you’ll be happy you did!”
One of the most discussed points in software companies, between their managers and coworkers is about the question “rewrite the program or not rewrite it?”.
Many would argue that starting over is shooting yourself in the foot, because, after all, it would be a declaration that you screwed up and you couldn’t bear the errors from the past rather than understanding where you made mistakes. It would be like giving up, a moral weakness and a strategic bankruptcy. Worse: it’s going to be the same software with more and different bugs!
In Cheesecake Labs we deal a lot with HTTP requests, one of the most complex and unreliable parts of mobile development, and it’s really time-consuming to test every refactoring and commit in each new project. Every now and then, rewriting can’t be avoided at all.
However, would we go through lots of re-coding, if we had something that was widely used and worked wonderfully? What if there were an external library that made fairly complex networking operations possible, being extremely lightweight and easy to use? That is AFNetworking, which covers a great deal of our job. It’s robust, with a good acceptance of the community and it’s an open-source project, which means that everyone can (and does actively) collaborate to create a better framework. HTTP requests can be easily set up with this library, saving a great deal of time and energy, without losing efficiency in the process. It’s safe to say that strange bugs won’t be appearing if you make use of AFNetworking, as there are many people involved in the library’s updates.
Yes, it’s just like that!
We are currently working with AFNetworking in two projects. Although we use it for extremely similar functions, we’ve built slightly different structures: in the first project, we use the library’s code directly, explicitly importing parts (functions) and using them throughout our codebase; in the second one, we create an intermediate layer that provides a more organized and abstract usage of the core AFNetworking functions.
It’s really a miracle: 15,000 lines turning into half a dozen. It won’t look messy, ugly or with a ton of errors — that you’d probably do if you were (re)writing from zero. When you see something like AFNetworking, it is a turning point on networking programming. So, if you are experiencing troubles in that area and yet you never used this library, you are probably wasting your time.
share this article
FAQ
What is AFNetworking?
AFNetworking is an external, open-source library that makes fairly complex networking operations possible, being extremely lightweight and easy to use. It's robust, has good acceptance of the community, and everyone can actively collaborate to create a better framework.
Why use AFNetworking instead of rewriting code from scratch?
Rewriting code is time-consuming and can result in the same software with more and different bugs. AFNetworking is widely used and works wonderfully, allowing HTTP requests to be easily set up, saving a great deal of time and energy without losing efficiency. It can turn 15,000 lines into half a dozen.
How is AFNetworking being used in current projects?
AFNetworking is currently used in two projects with slightly different structures: in the first project, the library's code is used directly, explicitly importing parts (functions) and using them throughout the codebase; in the second, an intermediate layer is created that provides a more organized and abstract usage of the core AFNetworking functions.
Are bugs a concern when using AFNetworking?
It's safe to say that strange bugs won't be appearing if you make use of AFNetworking, as there are many people involved in the library's updates.
Who should consider using AFNetworking?
Anyone experiencing troubles with HTTP requests in mobile development who has never used this library is probably wasting their time. AFNetworking is recommended for new projects or for migrating existing projects.
Giovanni writes content at Cheesecake Labs, top mobile app development company in Brazil. He enjoys creative actions by writing and expressing messages.