Search code examples
architecturesoftware-designsystem-design

Is there no alternative to life cycle methods paradigm?


I am not sure whether this is the correct medium to ask this question. But I have noticed a pattern in almost all different ecosystems, be it web,mobile....

We always have lifecycle methods in the framework or libraries like in android, react, vue, angular, flutter, web components.... Is this the only way to make frameworks or there are other ways/paradigms as well?


Solution

  • As soon as you create any sort of object/component at runtime / in memory, you are effectively having a lifecycle. Because memory is not infinite it needs to be managed, so declaring and using memory (creating objects, etc) is a fundamental necessity. Conceptualizing this as a lifecycle therefore just seems to work - memory (objects, components, etc) are declared, and used, and at some point destroyed. Frameworks simply harness this and expose events/methods/etc that allow you to work with objects more efficiently.

    Related to this, perhaps, is the idea of a transaction, or request/response. I'm thinking here of requests to a web server (and thus to whatever application runtime ends up handling the request), or queries to a database. In those situations the word "lifecycle" can be used to describe everything that happens from the moment a request comes in, until the response is completed.

    To not have a lifecycle would probably mean that the underlying nature of computing was different.

    The only alternative I can think of, where you might not have a "lifecycle", is a procedural language, where you dealt with instructions, but not with objects.