Marius' coworker is a big fan of the façade pattern. Not the software engineering façade, but more the old Wild West town movie set façade. And Although his tenure has long since expired, his elaborate implementations still persist to this day.

Submitted for your approval is this recently uncovered "self-service password change" page. For nearly eighteen months, users had no way of changing passwords on their own; most would simply keep the password they had, while a select few would contact tech support to do it. It took quite a few support tickets to realize that the problem didn't exist between the keyboard and the chair, and it took development just as long to believe that there was a bug. Eventually, Marius was assigned to "fix" it, and he's pretty sure that it took less time to develop the actual code than its façade.

<script type="text/javascript">

    var strong = /^[a-zA-Z\d\W_]*(?=[a-zA-Z\d\W_]{6,})
               (((?=[a-zA-Z\d\W_]*[A-Z])(?=[a-zA-Z\d\W_]*[\d]))
               |((?=[a-zA-Z\d\W_]*[A-Z])(?=[a-zA-Z\d\W_]*[\W_]))
               |((?=[a-zA-Z\d\W_]*[\d])(?=[a-zA-Z\d\W_]*[\W_])))
               [a-zA-Z\d\W_]*$/;

    while (true) {
        var password = prompt("Enter password", "");
        if (password == null) {
            alert("Error: Unable to read password, Refresh the page to try again!");
            break;
        }
        else if (password.length < 7)
            alert("Password must be longer than " + (password.length + 1) + " characters");
        else if (!strong.test(password))
            alert("You must enter a stronger passoword, make sure you enter a strong password");
        else
            alert(GenerateRandomError(password));
        }

    function GenerateRandomError(password) {
        var error = Math.floor(Math.random() * 1)
        
        switch (error) {
        case 0:
            return InvalidCharInPosError(password);
        default:
        }
    }

    function GetPosString(position) {
        switch (position) {
        case 0:
            return "1st";
        case 1:
            return "2nd";
        case 2:
            return "3rd"
        default:
            return (position + 1) + "th";
        }

    }

    function InvalidCharInPosError(password) {
        var pos = Math.floor(Math.random() * password.length);
        return "The character \'" + password.substr(pos, 1) 
           + "\' is not supported in the " + GetPosString(pos) + "position";
    }
</script>
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!