Object Types Question

Object Types Question

Old forum URL: forums.lhotka.net/forums/t/1657.aspx


wjcomeaux posted on Wednesday, November 01, 2006

When you create an object of type EditableSwitchable is it ever necessary to also have an EditableRoot and EditableChild object also? Or is simply having the EditableSwitchable enough and you then create them as whichever you need?

Working with a code generator I am trying to  derive as many objects from the metadata as possible and I am wondering if I should go ahead and create all 3 types or just create the EditableSwitchable.

Thanks,

Will

Bayu replied on Wednesday, November 01, 2006

It is the whole intent of the EditableSwitchable to avoid having to implement a separate EditableRoot and EditableChild.

There are only few use cases for EditableSwitchables, as far as I know the only time you opt for this one is when you have a lot of common code in the EditableRoot and EditableChild otherwise.

But since you have a codegen .... I would suggest to refrain from EditableSwitchables unless you really have a compelling case where you need them.

Btw: what are you currently working with? Dollard's stuff or did you get too addicted to CodeSmith? ;-)

Bayu

guyroch replied on Wednesday, November 01, 2006

Bayu is right in that the intent of a Switchable object is just that, to be able to either instantiate it as a root here and as a child there, etc...

But beware.  I can certainly understand was you would want to create _all_ of your objects as swtichable objects, but a switchable object is in most cases a sign of bad design.

I think you should nail down your object's responsibility and then create (generate) the appropriate root or child objects as required.  You should, at least IMHO, put the breaks on using nothing but switchable objects.

Anyway, that is my 2 cents :(

Michael Hildner replied on Wednesday, November 01, 2006

Sorry to jump in here, but this brings up something I've wondered about since using CSLA.

I've never used a switchable object, and the mantra is it's usually bad design to do so. But it's included in the framework, so I guess there are valid reasons to use a switchable object? Can anyone give an example of when it's a good idea to use a switchable object?

Thanks,

Mike

wjcomeaux replied on Wednesday, November 01, 2006

Thanks guys.

I will remove my generation for EditableSwitchable and simply generate the Parent and Child objects.

This clarifies a lot.

And yes, I am addicted to CodeSmith now. I am currently working a master template to generate a bulk of my business objects and all of my stored procedures.

 

Will

fabiousa7 replied on Wednesday, November 01, 2006

Will,

EditableSwitchable is a class type for objects that are times root and times child of another object or collection.

If you create your objects as EditableSwitchable you dont have to do the other two, but having all objects as editableSwitchable will make them do a lot of extra work and expose it to possible miss-usage by the UI.

Fabio

 

 

Copyright (c) Marimer LLC