# Defining services as actor vs struct

**URL:** <https://forums.kodeco.com/t/defining-services-as-actor-vs-struct/202026>\
**Category:** Real-World iOS by Tutorials\
**Created:** [February 1, 2024, 8:14pm UTC](https://forums.kodeco.com/t/defining-services-as-actor-vs-struct/202026 "2024-02-01T20:14:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![beeeph](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/beeeph/32/109692_2.png) [@beeeph](https://forums.kodeco.com/u/beeeph)\
**Post date:** [February 1, 2024, 8:14pm UTC](https://forums.kodeco.com/t/defining-services-as-actor-vs-struct/202026/1 "2024-02-01T20:14:15Z")

</div>

Why do some code chapters (.e.g. 10) define the `FetchAnimalsService` and `AnimalStoreService` as actors, and other chapters (e.g. 5) define them as structs?

For example, in the chapter 5 folder, I found this commit replacing `actor` with `struct`.

> <https://github.com/kodecocodes/rwi-materials/commit/0fa01b4190c5e403d0ac31f31528b2e523ee35de>

I understand what an `actor` is, and how it’s used to prevent multiple threads from accessing data, but these service types don’t seem like they need to protect any data, so I’m curious why you would ever want to define them as actors. Thanks!

---

<div class="post-metadata">

**Author:** ![renan.dias](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/renan.dias/32/108649_2.png) [@renan.dias](https://forums.kodeco.com/u/renan.dias)\
**Post date:** [February 9, 2024, 12:24am UTC](https://forums.kodeco.com/t/defining-services-as-actor-vs-struct/202026/2 "2024-02-09T00:24:34Z")

</div>

Hi @beeeph

Actors were used more as a educational point here. To exemplify how they could be used in this context. But in this specific application, like you said, they’re not protecting any data so they’re not needed.
