GoodData

Domain-Driven Development with Context::Singleton

Why domain-driven development ?

How to measure software quality

Explain DDD - Bounded context

Explain DDD - domain language

Explain DDD - domain event

Explain DDD - tests

DDD with Context::Singleton

Example - event listener

        trigger 'project::id' => sub {
            logger->mdc->set (PROJECT_ID => $_[0])
        }

Example - project backup using remote storage

        contrive 'backup::project' => (
            dep => [ qw[ project::id backup::driver ] ],
        );

        contrive 'backup::driver' => (
            class => 'Backup::Storage',
            dep => [ 'backup::storage::username', 'backup::storage::password' ],
        );

        proclaim 'Backup::Storage' => 'Backup::Storage::S3::AWS';

Example - ... timtowdi

        contrive 'net-amazon-s3-access-key' => (
            dep => [ 'backup::storage::username' ],
        );
        contrive 'net-amazon-s3-sercet-key' => (
            dep => [ 'backup::storage::password' ],
        );
        contrive 'net-amazon-s3' => (
            class => 'Net::Amazon::S3',
            dep => {
                aws_access_key => 'net-amazon-s3-access-key',
                aws_secret_key => 'net-amazon-s3-sercet-key',
            },
        )

Example - tests

        proclaim 'net-amazon-s3-access-key'    => 'Dummy';
        proclaim 'net-amazon-s3-secret-key'    => 'Dummy';
        proclaim 'net-amazon-s3-bucket'        => 'dummy-bucket';
        proclaim 'net-amazon-s3-bucket-region' => 'ca-central-1';
        proclaim 'net-amazon-s3-object'        => 'some/object';
        proclaim 'net-amazon-s3-expire-in'     => 7_200;
        proclaim 'now'                         => '2010-01-01 12:36:54';

        ok deduce ('net-amazon-s3-object-signed-uri'), ...;

Example - API versioninig

        contrive "parser/v1.0" => ( dep => [ "vnd.v1.0+json" ],  ... )
        contrive "parser/v2.0" => ( dep => [ "vnd.v2.0+json" ],  ... )

        contrive "user::login" => (
            dep => [ "parser/v1.0" ],
            as => sub { $_[0]->{login} },
        );

        contrive "user::login" => (
            dep => [ "parser/v2.0" ],
            as => sub { $_[0]->{user}{login_name} },
        );

        proclaim $request->{content_type} => 1;
        deduce "authorize::user";

Example - API versioning

        contrive "builder/v1.0" ...;
        contrive "builder/v2.0" ...;

        contrive "outout/user/v1.0" => (
            dep => [ "builder/v1.0", "user::login", "user::password" ],
            as => sub {
                $_[0]->build ({
                    login => $_[1],
                    password => $_[1],
                });
            },
        );
        contrive "outout/user/v2.0" => (
            dep => [ "builder/v2.0", "user::login", "user::password" ],
            as => sub {
                $_[0]->build ({ user => {
                    login_name => $_[1],
                    password => $_[1],
                }});
            },
        );

Books