Why is it a bad idea to write configuration data in code?

前端 未结 10 2163
陌清茗
陌清茗 2020-12-05 23:46

Real-life case (from caff) to exemplify the short question subject:

$CONFIG{\'owner\'} = q{Peter Palfrader};
$CONFIG{\'email\'} = q{peter@palfrader.org};
$CO         


        
10条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 00:35

    My main problem with configuration in many small scripts I write, is that they often contain login data (username and password or auth-token) to a service I use. Then later, when the scripts gets bigger, I start versioning it and want to upload it on github.

    So before every commit I need to replace my configuration with some dummy values.

    $CONFIG{'user'} = 'username';
    $CONFIG{'password'} = '123456';
    

    Also you have to be careful, that those values did not eventually slip into your commit history at some point. This can get very annoying. When you went through this one or two times, you will never again try to put configuration into code.

提交回复
热议问题