Tugulab Blog.

Expose Init Parameters and Dependencies in Swift and iOS Please

The init parameters and the dependencies should be accessible from the outside. Even if from the outside you don’t need them.
author avatar

clacla

There is one simple concept to follow when developing Swift or iOS code. The init parameters and the dependencies should be accessible from the outside. Even if from the outside you don’t need them.

It’s good etiquette because it gives transparency. It’s good practice because it makes the component you created more scalable. It makes sense because it makes code easier to test.

When creating your future entity store the init parameter as a property with the same access control level of the entity itself. If your entity is public make it public. If internal keep it internal.

One last thing. Please be consistent in the codebase. Don’t go for one logic in one place and a different one in another. Consistency makes understanding your codebase much easier. Especially when there are many team members.