Constructor Vs Initializer
In standard Solidity, a constructor is a special function that runs only once during contract deployment to set initial values. However, for proxy contracts, the proxy's constructor cannot initialize the implementation's state because the implementation code is executed in the proxy's context.
Therefore, upgradeable contracts use an initializer function instead of a constructor. This initializer must be designed to be called only once to prevent re-initialization attacks.
Developers often use a boolean flag or a modifier to enforce this one-time execution rule. Understanding the difference between these two patterns is critical for deploying secure upgradeable contracts.
Misunderstanding this distinction is a common source of bugs in proxy-based DeFi protocols.