Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49761 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53257 invoked from network); 17 Sep 2010 19:13:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2010 19:13:33 -0000 Authentication-Results: pb1.pair.com header.from=ralph@smashlabs.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ralph@smashlabs.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain smashlabs.com from 67.15.58.61 cause and error) X-PHP-List-Original-Sender: ralph@smashlabs.com X-Host-Fingerprint: 67.15.58.61 openrce.org Linux 2.6 Received: from [67.15.58.61] ([67.15.58.61:44485] helo=users.smashlabs.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/73-30333-9DDB39C4 for ; Fri, 17 Sep 2010 15:13:30 -0400 Received: (qmail 14212 invoked from network); 17 Sep 2010 14:13:17 -0500 Received: from ip174-70-101-166.no.no.cox.net (HELO ralph-macbook.local) (174.70.101.166) by smashlabs.com with (AES256-SHA encrypted) SMTP; 17 Sep 2010 14:13:17 -0500 Message-ID: <4C93BDD6.50702@smashlabs.com> Date: Fri, 17 Sep 2010 14:13:26 -0500 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666 MIME-Version: 1.0 To: Jonathan Bond-Caron CC: 'PHP internals' References: <12df042bd98b449afa15c788b9083e51@localhost> <000001cb569a$232aa220$697fe660$@com> In-Reply-To: <000001cb569a$232aa220$697fe660$@com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] On how a little knowledge is completely useless. From: ralph@smashlabs.com (Ralph Schindler) Inline response: On 9/17/10 1:57 PM, Jonathan Bond-Caron wrote: > On Fri Sep 17 01:06 PM, Guilherme Blanco wrote: >> >> Another good example is to map your persistence data into your >> Entities. Doctrine 2 implements this and I think that way you can >> compare easily with the PHP code alternative. I'd like to ask you to >> compate the same Entity mapped through Annotations emulator and using >> raw PHP code: >> CmsUser using Annotations: >> http://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/ >> M >> odels/CMS/CmsUser.php >> CmsUser using PHP code: >> http://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/ >> O RM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php >> > > You're basically bundling (M: Model, data& configuration, C: Control, business logic / code) into a single class while the MVC pattern is all about separating M,V and C. Jonathan, I think you are misinterpreting this code. There is no Controller (Front controller, or parameter mapping from $_POST or $_GET) nor View responsibilities (echo) here. These are all Model concerns: how is data persisted, how is it mapped to the persistence layer, how are entities created and how are their dependencies injected, etc. By using doctrine, you are adopting & subscribing to Doctrines philosophy of how tool based modeling should work. The code doesnt run without doctrine in the mix anyway (you'd have their entity manager in play at all times). How they (the Doctrine project) decide to manage mappings is up to them, and you'd be free to either consume their ORM framework, or not. It is both a development time and production time tool. > What's wrong with a simple configuration file? Caching the parsed config in shared memory? There is nothing wrong with that, but that is only a single approach. Alot of times, developers want a close relationship between the metadata and the code it is about. That means not in separate files, but inside the same file. This is why projects like *Hibernate are so popular in enterprise software. No one wants to develop an ORM, they just want a way to persist their objects.. and a little penalty in performance is a sound trade-off. > One important flaw rarely mentioned with annotations config: your code now depends on framework X to read the annotations instead of a simple configuration file (.xml, .ini., ...) Doctrine, Symphony DI, even ZF.. and include to that the non PHP solutions.. none of these are frameworks you can adpot in less than 5 minutes. It takes some investment of time to understand their philosophy and also decide how it best fits into your personal code toolkit. That means that you'd have understood how said framework plans and does use these annotations. > Sorry if I might sound harsh but configuration through annotations is terrible. > You'll find many .net or java developers that agree, I'd say it's 50-50 if not more 70-30. > > Does this discussion still belong in internals? We could argue about this for months, java astronauts don't even agree how annotations are useful: > http://www.javaworld.com/community/node/2613 Arguments like this will always exist. But that's less the point. The point is is that there are many developers that exists that have taken the time to adopt a persistence framework like *Hibernate, and no one can argue that they do not get their job done, and annotations have certainly helped them get there and create maintainable code. -ralph