Summary

This chapter wraps up our exploration of Protocol Oriented Programming, value types, and reference types. In the previous two chapters, you saw some theoretical situations that explain the power of these features in Swift. This chapter tied it all together by applying your newfound knowledge to the HelloContacts app we were working on before.

You now know how you can bump the quality and future-proof an existing application by implementing protocols and switching to using a struct instead of a class. In order to implement protocols, we had to improve our application by making sure that our ViewController didn't contain too many functionalities. This in itself was a huge improvement that we were able to take to the next level with a protocol.

Refactoring from classes to structs isn't always easy; the two aren't interchangeable as we saw when we changed HCContact from a class to a struct. The main difference we encountered was due to how structs handled mutability. Adapting our code for this wasn't too complex, and it made our intent clearer than it was when we used classes.

Now that we have explored some of the best practices of Swift and applied them to an existing app, it's time to deep dive into Core Data. The next chapters will outline how Core Data works and how you can take advantage of it in your own applications. If all this value type and Protocol Oriented Programming talk has made your brain spin, don't worry. Take some time to review this chapter and to experiment. The best way to learn these principles is by practicing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.223.168