A good book (IMHO) to have a look at is PHP 5, Objects, Patterns and
Practice by Matt Zandstra (Apress) which explains ORM and MVC very well
ORM is basically the mapping of relational database data to objects. The
programmer does not give a damn how the data is stored all they need to
do is to instruct the data persistence layer to save an object instance
or load an object instance, whether that data is cached in a file, read
from a single table or read from multiple tables is irrelevant.
Cake's models are all about the reading, writing and verification of
data which is absolutely fine as this is very well documented and there
seems little point in taking data from a table, converting it from an
array into an object then passing that object to a view to be displayed
when all the view needs is the data to be displayed.
So to me, Cake's current ORM does have a layer missing that other
frameworks have. Zandstra's book calls this the Domain Model and it's
purpose is to read and write Objects from/to the database instead of
arrays. Other systems are tied in to a form of the ActiveRecord pattern
which is a decent enough Domain model and this is a direction I would
like to see Cake head in ... but not at the expense of what it already
has !!!
Steve
On 07/06/12 02:46, bs28723 wrote:
Thanks John. I am familiar with the mythical man month - good stuff!
You, Michael and Steve, got me to re-look at what I was really trying
to ask. I think my questions are really more about "really"
understanding MVC and ORM than cake. Cake is just the code that
implements MVC. While I understand what MVC is and does. I can define
it, and I can write simple applications using it. (fat model, skinny
controller) - I am not confident in all my architecture decisions and
able explain all my choices. I feel like I am still guessing, testing,
and reworking things all the time. To me, there is a big difference
between good code architecture and well written code. right now, I am
trying to make sure that I am putting the code in the right spot. It
may be crappy code, but at least it is in the model or controller
where it belongs. Maybe some day I can fix the crappy code. But I
want to avoid putting great code in the wrong place and end up with a
crappy system. I am not sure that I am explaining this any better, but
my knowledge gap is the MVC architecture. The data model is probably
good for now. I am sure someone could improve it, I don't claim to be
perfect, it will probably grow and change over time anyway. But it is
some of the MVC expertise that I am looking to learn.
An analogy that I can came up with is, that I think I am walking in
terms of MVC and Cake, and I want to start jogging or running. But
maybe, I am really still crawling and I need to keep working, and
coding, and testing, and reworking, to learn to walk, before I can
run. I think I am a fast learner and I have learned everything that I
can get my hands on, but I need more. I feel like a young Jedi
wanting to learn more and more, so I can become a Master sooner. Or
maybe it is because I am 53, I have been designing projects and the
last real programming I did was on an Unix System V device driver 20
years ago and this ORM stuff is a little Greek. Not to mention that
all these young kids are picking this up in seconds, and I just want
to keep up. LOL
John, you should be very proud of the system you built below. I spent
5 years doing system architecture for AT&T, helping people design
architectures like the one you describe below. For us it was standard,
but a lot of people probably don't understand the capability or the
complexity behind a scalable DB architecture with clustered servers
with masters and slaves. This is a great testament to you and your
team, and to Cake that it can handle this large project.
Thanks again to you, Michael & Steve. I think I am going to try to
learn more about MVC and ORB. Hopefully, I can find some things to
help be learn to run, but if not, I will just keep writing coded,
learning, rewriting and learn it over time.
Bill
On 6/6/2012 11:41 AM, John Hardy [via CakePHP] wrote:
A computer architect should just look at what cake does.
It bootstraps request into and MVC architecture. It has a built in
ORM, and some injection points to customize and manipulate data
throughout the request.
Cake is not gonna make you or break you, if your site it built
shitty, it's not because of the framework.
It can handle a large infrastructure. You've already searched, there
are no best practices for cake, it's not needed, it's MVC, ORM etc.
It's computer science and software engineering.
My site serves over 1 Million pages a day, over 600k in videos.
I have over 90 models shared between two domains ( admin and site )
Hundreds of controllers, hundreds of views.
I load balance between 8 16gb nodes.
My database architecture is horizontally scaled between 1 master, 3
slaves, 1 session server, and 1 data warehouse server.
I run a cluster of two memcached servers.
Do I have shitty code in my site, you're damn right I do. But its
getting the job done, and keeping food on peoples tables.
I can always go back with a better strategy to handle it later. but
there is much more good code in there too.
You suffer from second system effect. Read the mythical man month. it
will help you.
On Jun 6, 2012, at 8:37 AM, Steve Found wrote:
Yes, I have the eBook of this that I bought from Apress. I believe
it is for cake 1.3 ?
Although well worthy of a read, I felt there was a lot of wheel
re-invention going on. For example, they implement their own tree
handling code for categories when there is already a perfectly
satisfactory TreeBehavior class in Cake and they did not really
explain why they felt the need to do this. They also concentrate a
lot on the use of elements.
To talk about the original question, the way cake works IMHO is to
distribute logic between all three of Behavior, Component and Helper
classes with behaviors extending models, Components extending
controllers and Helpers extending views. The best analogy I can
think of for these is the C++ multiple inheritance concept where
functions are added to the classes to give them more methods. For
example a model with both Tree and Containable behaviours is both of
those things in addition to being a model.
To have a concept, say for example you wanted an edit box that
plugged into junit's autocompletion, you may well write a plugin
that contained all three of behaviours, components and helpers to
achieve what you want.
Good examples of this can be found in the CakeDC github repository
and I think this is a good a repository as any to see good Cake
coding practises.
https://github.com/CakeDC
Hope this is of some help,
Steve (Ratty)
On 06/06/12 03:28, bs28723 wrote:
anyone familiar with this book?
Practical CakePHP Projects (Expert's Voice in Web
Development) by Richard Miller, John Omokore and Kai Chan
(Dec 4, 2008)
or other books that provide good examples of the
Fat Model, Skinny controller Concept?
On Sunday, June 3, 2012 9:04:26 AM UTC-4, ibejohn818 wrote:
Fat model, skinny controller.
Separation of presentation and data
A couple Core concepts in building a mote maintainable app.
However nothing is ever 100 perfect for all situations, learn
from writing your own shitty code and do not get caught in the
spiral of over engineering. Keep it simple and clever.
On Jun 2, 2012 11:18 AM, "bs28723" wrote:
I am probably looking for something that does not exist
online, but only
in a few folks heads. :-) But maybe some parts of this
exists. You
never know unless you ask......
I am quickly learning a lot about MVC architecture and
CakePHP over the
last couple months. The cookbook, lots of trial and error,
and this
group are helping me learn - so thanks! But, I am finding
myself using
simple examples to learn or implement something. Then as
it scales,
realize that I should have done this with a helper,
behavior or
component. And now, I have to go back and redesign this,
to do it
correctly. Great that I am learning, but this is delaying
my project. Sigh.
So, I am looking for more advanced examples, tutorials, or
best
practices to "hopefully" allow me to skip over some of the
basic
learning curve and get right to an architecture that will
support a
medium to large site with lots of capabilities.
Am I asking for too much? :-)
Any suggestions on where to get this advanced information
or education I
am looking for?
Thanks,
bill
------------------------------------------------------------------------
View this message in context: Looking for MVC & CakePHP
Best practice doc, examples for Med to large sites
<http://cakephp.1045679.n5.nabble.com/Looking-for-MVC-CakePHP-Best-practice-doc-examples-for-Med-to-large-sites-tp5708484.html>
Sent from the CakePHP mailing list archive
<http://cakephp.1045679.n5.nabble.com/> at Nabble.com
<http://Nabble.com>.
--
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org <http://tv.cakephp.org/>
Check out the new CakePHP Questions site http://ask.cakephp.org
<http://ask.cakephp.org/> and help others with their CakePHP
related questions.
To unsubscribe from this group, send email to
[hidden email] </user/SendEmail.jtp?type=node&node=5708597&i=0> For
more options, visit this group at
http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org <http://tv.cakephp.org/>
Check out the new CakePHP Questions site http://ask.cakephp.org
<http://ask.cakephp.org/> and help others with their CakePHP related
questions.
To unsubscribe from this group, send email to
[hidden email] </user/SendEmail.jtp?type=node&node=5708597&i=1> For
more options, visit this group at
http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and
help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[hidden email] </user/SendEmail.jtp?type=node&node=5708597&i=2> For
more options, visit this group at http://groups.google.com/group/cake-php
------------------------------------------------------------------------
If you reply to this email, your message will be added to the
discussion below:
http://cakephp.1045679.n5.nabble.com/Looking-for-MVC-CakePHP-Best-practice-doc-examples-for-Med-to-large-sites-tp5708484p5708597.html
To start a new topic under CakePHP, email [hidden email]
</user/SendEmail.jtp?type=node&node=5708606&i=0>
To unsubscribe from CakePHP, click here.
NAML
<http://cakephp.1045679.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
------------------------------------------------------------------------
View this message in context: Re: Looking for MVC & CakePHP Best
practice doc, examples for Med to large sites
<http://cakephp.1045679.n5.nabble.com/Looking-for-MVC-CakePHP-Best-practice-doc-examples-for-Med-to-large-sites-tp5708484p5708606.html>
Sent from the CakePHP mailing list archive
<http://cakephp.1045679.n5.nabble.com/> at Nabble.com.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and
help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this
group at http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php