Re: Should I coerce a DBIC schema from HashRef?

[email protected] (Bill Moseley)
Newsgroups perl.moose
Message-ID <CAKhN_m65sLhvVLu0REUp5AZDZzyo22Ur8ML95Lyh6F75LmP_Yg@mail.gmail.com>
Hey John,

On Tue, Sep 4, 2012 at 11:22 AM, John Napiorkowski <[email protected]>wrote:

> I've done this a lot in the past, as well as a few other approaches.  In
> the end I've come to the conclusion that although off the top it seems like
> a nice interface, it doesn't grow old well and can be confusing to people
> trying to read your code.  I now tend to think that a consuming class
> should only build its objects when and if it needs some way to influence
> how they are built.  Otherwise over the long term you end up with a
> confusing interface with a lot of stuff completely unrelated to the actual
> functioning of the class.  And it harder to test correctly.
>

So, instead of consuming a role that has a schema attribute AND attributes
to support a _build_schema, use a separate class that builds a schema, and
then constructs the original class and returns that?


I'm not sure what a better approach could be, but lately I've been taking
> the idea of having dedicated builder classes.  I know that sounds heavy
> handed, but at least it has the upside that my concerns are more carefully
> separated.



Are you returning an instance of the original class or an instance of the
builder (sub) class?   Do you have a simple example of your builder?



Thanks,



-- 
Bill Moseley
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.