Cakers’ Review: AFNetworking

AFNetworking
Summary
  • AFNetworking is a lightweight, open-source networking library that simplifies complex HTTP requests in mobile development, saving significant time and effort.
  • The library is robust and community-supported, meaning bugs are rare and updates are actively maintained by many contributors.
  • Cheesecake Labs uses AFNetworking across multiple projects, implementing it either directly or through an abstraction layer, reducing thousands of lines of code to just a handful.
  • Developers struggling with networking challenges who have not yet adopted AFNetworking are likely wasting valuable time and resources.

“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.

Screen Shot 2015-02-12 at 14.28.43
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.

FAQ

What is AFNetworking?

AFNetworking is an open-source external library designed to simplify HTTP networking operations in mobile development. It is lightweight, easy to use, and widely accepted by the developer community, with many contributors actively maintaining and improving it.

Why should developers consider using AFNetworking instead of rewriting their networking code?

Rewriting networking code from scratch is time-consuming, error-prone, and often results in new bugs. AFNetworking provides a robust, well-tested solution that can reduce thousands of lines of code to just a handful, saving significant time and effort without sacrificing efficiency.

How is AFNetworking being used at Cheesecake Labs?

Cheesecake Labs uses AFNetworking in two projects. In one project, the library's functions are imported and used directly throughout the codebase. In the other, an intermediate abstraction layer is built on top of AFNetworking to provide a more organized and cleaner usage of its core functions.

Is AFNetworking reliable and safe to use in production projects?

Yes, AFNetworking is considered reliable and safe. Because it is open-source and maintained by a large community, bugs are quickly identified and addressed, making it a stable choice for handling complex HTTP requests in mobile applications.

Who should consider adopting AFNetworking?

Any developer or team dealing with HTTP requests in mobile development who has not yet used AFNetworking should consider adopting it. If you are experiencing networking challenges or spending excessive time on related code, using AFNetworking is likely a more efficient and practical solution.

About the author.

Giovannu Carús
Giovannu Carús

Giovanni writes content at Cheesecake Labs, top mobile app development company in Brazil. He enjoys creative actions by writing and expressing messages.