---
# System prepended metadata

title: Lifecycles

---

# Lifecycles


1. Strongly typed machines

    1. Context - We can have strongly typed machines linked to the transitions of a specific entity. 
    1. Pros
        1. We will have strongly typed events, context, well-defined structure, options, actions, guards etc. 
        1. We will largely know whether the machine works at compile time (links to the above point)
    1. Cons
        1. We end up being tied to a specific implementation
        1. Specific events events need to be sent. That defeats the purpose of a generic lifecycle service and generic transitions / API call for transitions.
         
1. Loosely typed machines

    1. Context - we use lifecycle service that creates a generic machine implementation. We inject the required dependencies in the service and then call them in the machine options definition.
    1. Pros
        1. One definition used across the application
        2. Generic approach to serialization / deserialization
        3. Code is not scattered around
    3. Cons
        1. Explosion of dependencies - all service dependencies need to end up here
        2. Code branching for each machine type - a lot of if/else or switch statements (there is no 'generic machine')
        3. All events will need to have the same signature
        4. The service will end up being a composite of all machines in Cherrytwist