Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor BoolType #43

Open
mindplay-dk opened this issue Nov 13, 2018 · 0 comments
Open

Refactor BoolType #43

mindplay-dk opened this issue Nov 13, 2018 · 0 comments

Comments

@mindplay-dk
Copy link
Owner

BoolType supports a public factory-method get() and implements a fly-weight pattern, which seems to imply you could use this to generate a custom BoolType instance, on the fly, for a specific column.

That doesn't work in practice - the column factory-methods in Table only accept a class-name string, which means that all types must be registered up front.

Perhaps that's not a bad thing - explicitly defining types up front has the expected performance characteristics and avoids implementing a fly-weight pattern and/or manually registering types under some other name besides the class-name.

Suggestion:

Remove get get() factory-method, and make the BoolType constructor public.

Keep the default true, false arguments as-is.

This will make it easy to extend BoolType into a custom BoolType, which is in fact already possible with e.g.:

class MySQLBoolType extends BoolType
{
    public function __construct()
    {
        parent::__construct("1", "0");
    }
}

Lets remove the confusing/misleading factory-method though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant