Wordpress - How to pass parameters to admin_notices?

I think a better implementation would be a "message" class e.g.:

class WPSE_224485_Message {
    private $_message;

    function __construct( $message ) {
        $this->_message = $message;

        add_action( 'admin_notices', array( $this, 'render' ) );
    }

    function render() {
        printf( '<div class="updated">%s</div>', $this->_message );
    }
}

This allows you to instantiate the message at any time prior to rendering:

if ( $done ) {
    new WPSE_224485_Message( "$name has been upgraded." );
}