To be honest.. writing unit tests in iOS is a myth. Usually iOS developers work for small startups, which source money from investors. It is important for those investors to create a product as soon as possible. Manuall tests or application stability? Who cares… It is our obligation as a professional developers we need to change this approach and teach our clients that development process consists of two inseparable elements -code & tests. If you want to learn more about this approach please check the book “The Software Craftsman: Professionalism, Pragmatism, Pride” (Robert C. Martin Series).
In this blogpost you…
Dependency inversion is the last letter of SOLID therm. Last position doesn’t mean less important than the other, in my opinion this principle is the most important software design pattern.
The general idea of this principle is as simple as it is important:
High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features.
In simple words — we shouldn’t use class name in any function and variable declaration. Instead of this, we should use protocols or abstract class.
Based on this idea, Robert C. Martin’s definition of the Dependency…
Every time when i start a new project there is the same question. How to implement a network layer? To use external libraries like Moya, Alamofire etc. or to write it from the scratch.
My answer for this question is — Use pure Swift without any third-party libraries. It’s a super simple to implement protocol-oriented layer, type safe with enum to configure endpoints and fully testable, of course. In these few points you will learn how to write protocol oriented networking layer that you can customise.
Before you start, it’s important to understand
URLSessionand its constituent classes. In general
iOS developer 💻📲