/Domain_CodeChallenge

Domain Code Challenge

Primary LanguageSwift

CodeChallenge for Domain

by Dmitrii Zverev. 3 June 2018

Given Instructions:

  • Acquire property models from the following endpoint

  • Display a control on the top of the screen to switch between buy and rent. This selection must persist between launches.

  • Display a label on the top of the screen to display the number of properties marked as favourite.

  • Display properties on screen with the following UI elements: Favourite button, Image, description text.

  • The properties (at least 20) must be displayed in a column when the device trait collection horizontal size class is Compact. The properties must be displayed in a 2 column layout when the device trait collection horizontal size class is Regular.

  • The favourites must be persisted securely between launches.

Given Expectations:

  • The code written by yourself must be Swift, Objective-C libraries are fine.

  • This should represent code you would be proud to ship as part of the Domain team. Don't try and get too fancy and impress us with an obscure technique/library. There will be plenty of time to discuss those after you complete the challenge.

  • Please refrain from the use of storyboards or xib files for the purposes of this exercise.

  • Layout code must use Autolayout where appropriate. DSL libraries like SnapKit are acceptable.

  • The code must be written to support iOS9+ and all the devices that includes. Assets must be optimised for each device scale. You can get high resolution or vector graphics from The Noun Project or any source your prefer.

  • Some examples of the use of size classes must be included.

  • You are expected to include unit tests where appropriate. You can use XCTest or any other testing framework you prefer.

  • You are expected to include Git history and follow the same Git methodology and process as if you were working with others.

  • Your project should build with the newest version of Xcode available at the time of your submission.

  • Include a brief description of your design goals and any tradeoffs or compromises you made in your README file.

Personal challenges:

I haven't written an app without storyboard or XIBs for ages so I decided, as an additional challenge, to not to use 3rd part libs or Pods (except Autolayout one):

  • Using Codable structs was fun and good practice, however, I still think that for the API requests the best solution is combination Alamorife + SwiftyJSON. It gives you full control of creating objects/structs (especially using optional initialisations) and literally 100% crush free code.
  • Although I used my own UIImageView subclass with image loading and caching methods, I'd recommend the Kingfisher as an amazing and totally covering all possible image loading scenarios tool.

In this challenge, I demonstrated that I know how to use:

  • structs
  • lazy variables
  • optional
  • Codable (including snake_case to camelCase converting)
  • class extensions and sub-classes
  • Threads
  • URL Sessions
  • Error throwing Enums
  • Creating UI without Storyboard/Xib
  • Avoiding Massive View Controllers
  • writing code without single warning
  • closures
  • escaping
  • tuples
  • Saving/loading offline data
  • Caching
  • .. and much more

About Unit testing: To display that I know what unit tests are and how to write them, I implemented some examples including the Asynchronous URL Connection test.