Re: High Cohesion Cakes

2006-08-27 Thread bwaters

Sounds like you've got it Sonic.

They are going to be dependent, it's just a matter of code smells.
Which is worse
- hidden dependencies in Model (associations).
- clutter in your Controller ($uses)

Pick one and go with it. (don't pick both)

Bryan


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: High Cohesion Cakes

2006-08-27 Thread Sonic Baker
Hi Bryan,

Thanks for your reply. You've put my mind somewhat at rest. At least now I know I'm not going way off track.

Cheers,

Sonic

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Re: High Cohesion Cakes

2006-08-27 Thread bwaters

No Problem.

My 0.2 cents says go with associations because you can use persistmodel
= true for a perfomance boost.

Plus it makes more sense to me to keep the data relationships in the
model since anything very useful with the database will be very
dependent on the relationships and the structure of the database.

The other side is if you want a component that is truly re-usable in
another application you need to keep it independent.
-ie maybe your shopping cart stores id's and types (one of which might
be the string product) and it's your controller that sticks in a
shoppingcart_type = product and then later looks it up using the
Product model


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: High Cohesion Cakes

2006-08-27 Thread Sonic Baker
Thanks for your 2 cents, it's worth way more in my currency ;-)

I agree on just using the associations in the model. Not only will this
keep model related code in the model, it'll also make it clearer how
each model object is associated and through which routes. I'll keep the
$uses array for those situations when it is really needed.

Cheers,

Sonic

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---


Re: High Cohesion Cakes

2006-08-25 Thread MJ Ray

Sonic Baker [EMAIL PROTECTED] wrote: [...]
 When this Model is a mapping of a relational database we end up with a lot
 of ModelA-ModelB-ModelC etc...
 To me this suggests high coupling between objects and I can't seem to stop
 myself ending up with such a design. So my question is, what's the best way
 to go about a high cohesive design with cake.

Do your model objects actually know anything about the internal 
structure of the other objects beyond being Model objects?

Generally, mine only know that they are associated with some other 
objects, which seems sort of unavoidable when representing a relational 
database.  The model methods and so on are the ones named in AppModel, 
so other Model objects only know that it's a Model, really.  I doubt 
that's high coupling, as each model can change without requiring changes 
in the other, as long as it still has an id. It's only if the model goes 
away or changes name that a change is *required* although performance 
may make changes *desirable*.

So, for high cohesion, use the AppModel methods and add other ones 
sparingly (and probably only use them from its Controller, which seems 
often unavoidably coupled to the Model).

Have I misunderstood?

Best wishes,
-- 
MJ Ray [EMAIL PROTECTED]  www.ttllp.co.uk  +44-870-4321-9-10
Web, localisation, koha, databases, GNU/Linux and statistics.
Registered in England and Wales, partnership number OC303457

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: High Cohesion Cakes

2006-08-25 Thread AD7six

Hi Sonic Baker,

caveatI am assuming this is regarding inter-model links rather than
controller-model links./caveat

ModelA-ModelB-ModelC doesn´t imply coupling to me, as your are just
using the relationships to navigate to the relavent objects. The
objects themselves are free to change or be enhanced, irgo low
coupling. If you prefered you could declare each class you want to use
in the $uses array for each controller. If the relationship between
ModelA and ModelB was removed, the code would stop working - is it this
sort of problem that is a concern? That sort of change would, however,
also indicate a rather fundamental change to the application.

I don´t fully understand what you mean by high cohesion objects. The
reason I don´t understand is that the models, don´t have any
dependencies except typically on the database (unless you code
something in yourself) and to my mind that makes them pretty cohesive -
they do one thing (provide an interface to a model) and that´s it.

If /I/ have misunderstood what you mean, please set me straight.

Cheers,

AD7six


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: High Cohesion Cakes

2006-08-25 Thread Sonic Baker
Hi guys,

Thank you for responding to my mail. First of all, yes, I'm talking
about inter-model links rather than controller-model links. I suppose
it's the idea of the relationships that has me confused. I'm trying to
design in such a way that each object is as independent as possible.
I've been reading as much as possible (maybe too much) about good
design lately and of course a good portion of this material has related
to Java without mention of any databases. I'm therefore wondering how
possible it is to have objects which are independent to each other when
they all act on the same database.

For example:
The good old shopping cart scenario:
If I want to add a product to the cart from inside the Cart model, I
may have a method called addItemToCart() which might include a call to
$this-CartItems-save($details);
If I want to list the details of the items from the CartsController's
view action, I might have a method in the Cart model called
getProductDetails($product_id) which might include a call to
$this-CartItems-Products-find($product_id).

It seems to me that these objects need each other to operate because
their models are related (which is unavoidable). So either my
understanding of low coupling / high cohesion is all messed up, or it's
just hard to do when there's a relational database involved.

If my understanding is correct, then using the $uses array from the
controller will make things look tidier from the controller and allow
you to use unrelated models but doesn't take away the dependencies
between model objects.

Does what I'm saying make any sense?

Cheers,

Sonic

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake PHP group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---