<commit_before>package io.caster.mockito;

public class UserRegistration {

    private Database database;

    public UserRegistration(Database database) {
        this.database = database;
    }

    public void registerNewUser(String emailAddress) throws UserAlreadyRegisteredException {
        if (database.hasUser(emailAddress)) {
            throw new UserAlreadyRegisteredException();
        }

        database.addUser(emailAddress);
    }
}<commit_msg>update UserRegistration to have two constructors<commit_after>package io.caster.mockito;

public class UserRegistration {

    private Database database;

    /* this does not use Dependency Injection;
     *     - this class is tied to SimpleDatabase implementation
     *     - no other implementation of a Database can be provided, even during unit testing
     */
    public UserRegistration() {
        this.database = new SimpleDatabase();
    }

    /* this uses Dependency Injection;
     *     - the database is given to this method
     *     - this method doesn't have to worry about fetching the database reference
     *     - alternative database implementations can be provided
     */
    public UserRegistration(Database database) {
        this.database = database;
    }

    public void registerNewUser(String emailAddress) throws UserAlreadyRegisteredException {
        if (database.hasUser(emailAddress)) {
            throw new UserAlreadyRegisteredException();
        }

        database.addUser(emailAddress);
    }
}
{'fraction_non_alphanumeric': 0.06569343065693431, 'fraction_numerical': 0.0, 'mean_word_length': 2.906735751295337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2400553', 'n_tokens_mistral': 368, 'n_tokens_neox': 347, 'n_words': 114}