Denis Brandi
May 19, 2021

--

Hi Kyn, thanks for reading the article!

The first approach is the correct one.

The job of the repository is isolate and encapsulate persistence logic.

Also whenever you come across this scenario, where you have 2 sequential invocations of the same dependency:

```

val result = dependency.getSomething()

dependency.saveSomething(result)

```

It means you should just have a single function inside `dependency` which will take care of both actions, because you are basically leaking private implementation details.

Hope this helps!

--

--