- Is closure a design pattern?
- Which of the design pattern is used to detect and update the state of an object on change?
Is closure a design pattern?
A closure is a function that has a reference to the outer function that has already been finished executing. For example, there are functions, and this example is a very typical one for explaining what a closure is. In this example, the inner function is wrapped by the outer function that takes an argument, x.
Which of the design pattern is used to detect and update the state of an object on change?
State design pattern is used when an Object changes its behavior based on its internal state. If we have to change behavior of an object based on its state, we can have a state variable in the Object and use if-else condition block to perform different actions based on the state.