5 things I learned this week #2

Coming in a bit late due to some travels to New York and then to India over the last couple of days but here we are:

  1. Basic Unit Testing and the use of the XCTest library to assert critical methods from simple projects we had previously built within the University of Washington iOS Certificate. To deepen my understanding of Unit Testing, I have also started the Ray Wenderlich dedicated tutorial which goes further with the use of stubs, mock objects, UI testing and performance testing. A new programming skill from which I just started to scratch the surface!
  2. Better/easier Serialization is coming for Swift, and will provide a way to encode struct and enums and a type safe solution to serialize to external formats like JSON and plist. No more if let dict = json["myDict"], let val = dict["myVal"] or -worst- nested conditional unwrapping. It will also removed the need for dedicated framework such as SwiftyJSON.
  3. Using inout parameters to manipulate external variables (external from the scope of the function). The variables are passed by reference, and therefore sustained any modification applied by the function. See Apple’s documentation for full details.
  4. Using protocols to handle networking calls and subsequent results (with dependency injection) not only make the code more readable but also allows for better testing. Great article from Natacha The Robot!
  5. Method dispatch, 3 primary methods (direct, table, and message) and all of them are supported by Swift. If you ever wondered what’s really behind the static, dynamic, @objc, final, or @inline keywords and about overall code performance, I found this article from Raizlabs extremely well written. It details how Swift handles dispatching for value types, classes, protocols and NSObjects while also highlighting what matters in how we write code (use of extensions or of reference value for instance).
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s