TAG | best practice
One of our websites is really really old and not really up-to-date in terms of technology, best practices and SEO friendliness as it happens. A weird thing I noticed is that a particular type of page was tracked in Google Analytics correctly but with a different URL than it actually had. So I went to find out what happened..
The pre-releases of Symfony2 come faster and faster now. Each contains an update documentation that briefly describes the major changes and advises what to do when updating. Not too long ago I was in a similar situation. Me and a colleague were releasing an internal software toolkit based on symfony 1.4 and we wrote about 10 update guides.
As there are similarities I thought I’d share a bit of what we’ve learned.
I just recently had an import job running that was pulling about 100.000 records from an XML source and pushing those into a database table. As the project this was for is a Symfony2 pet project of mine the technology used is Doctrine 2.0.
As Doctrine 2.0 has switched from the Active Record pattern to the Unit of Work pattern it is no longer necessary to fire one INSERT query per record saved. Instead you can create and persist as many objects as you wish and flush them to the database all at once.
There are however a few caveats you should know about.
When coding with Symfony2 and Doctrine 2.0 though I often get the feeling of not knowing what to do with this freedom and I already heard voices of fellow symfonians to wish a bit of that old magic and restriction of symfony 1 back. Bluntly put: if a framework doesn’t decide anything for you – where’s the benefit?
If you have a history of seeing a rant where none is indended you can stop reading here.
When creating a new Bundle for Symfony2 I think it is quite common to desire a custom configuration space that provides a default configuration but allows the user to override or add values in his application.
In Symfony2 this configuration will probably also include the definition of services provided to the application or bundle code by the dependency injection container.
There is already a lot of information about this online but still I struggled to achieve what I wanted.
So I created an example bundle to demonstrate one possible solution.
It is best practices that you want to apply to all projects you work on. Of course it is. This sounds only natural.
But it is the definition of the term that decides whether your work will be applicable or not at all.
Usually the answer is a misconfiguration but sometimes of course they found one of the bugs I involuntarily put in the code.
In these cases I have to get down at the code level and try to fix it. This is how I usually do it.
An just to make sure there are no misunderstandings: I am not about to question TDD!
I am merely asking for help to find my way to do it properly..