Choose many Spring contexts over a single context
This is a short introduction to splitting up your bean definitions from one single Spring application context, to many application contexts. That is, from one XML file to many XML files. The general idea is to have one single primary application context, usually titled applicationContext.xml, and then many other application contexts with are named what they contain.
Example
For example, a single web project might contain the following contexts.
- applicationContext.xml
- applicationContext-dao.xml
- applicationContext-dao-datasource.xml
- applicationContext-ldap.xml
- applicationContext-aspects.xml
- applicationContext-web.xml
Breakdown
In this example, your DAO definitions, transaction managers, and DAO or integration interceptors are defined in applicationContext-dao.xml. We have further broken the DAO application context to a dao-datasource which contains our data sources. LDAP configuration, beans, and DAOs are in their own applicationContext-ldap.xml.
Benefits
Why so many? There have been a few benefits so far.
Responsibility
The Single Responsibility Principal is widely accepted and states that
… every object should have a single responsibility, and that all its services should be narrowly aligned with that responsibility.states that every object should have a single responsibility, and that all its services should be narrowly aligned with that responsibility.
The same holds true for XML contexts. The general ides is to make our contexts more robust and to be able to isolate a context’s tasks and capabilities. And clearly, working with a smaller XML file is easier than working with one enormous file. It is easier to maintain and easier to read.
Testing
When I wrote my tests for LDAP, I had my LDAP configuration in applicationContext.xml, but then every time I ran an LDAP test, I would get the WebApplicationContext, which would import applicationContext-hibernate, which would connect to the database. Tests took forever and needless resources were used. Now I just get applicationContext-ldap.xml which only contains LDAP configurations, so no needless resources are loaded and tests remain quick.
Inclusion and Exclusion
Finally, its really easy to comment out a line like
<import resource="applicationContext-aspects.xml"/>
and quickly have all my aspects, which for me only write logs, disabled. Or easy to add a line like
<import resource="applicationContext-dao-mock.xml"/>
which overrides all of your DAO implementations with mock DAOs. This would be for testing.
Does anyone else use multiple application context files? See any other benefits? Or problems?
List of Version Control Web Sites
I recently needed to find a web site that offered version control services. I was having server issues and needed to find a reliable place to keep my code. Below is a list of sites that I found and some info about each one. Please add comments if you like or dislike any of these.
Note: The “cost” list below only shows the basic packages. Visit the sites for other plan details.
FREE – Version Control Hosts/Hosting
| Cost Per Month |
Disk Space |
Number of Repos |
Number of users |
Version Control Options |
SSL | |
|---|---|---|---|---|---|---|
| beanstalkapp.com | free | 100mb | 1 | 3 | SVN | no |
| unfuddle.com | free | 200mb | unlimited | 2 | git, SVN | |
| projectlocker.com | free | 500mb | unlimited | 5 | git, SVN | no |
| bitbucket.org | free | 500mb | 1 | ? | mercurial | yes |
| xp-dev.com | free | 500mb | unlimited | unlimited | SVN | no |
Cost – Version Control Hosts/Hosting (Basic Packages)
| Cost Per Month |
Disk Space |
Number of Repos |
Number of users |
Version Control Options |
Other Tools Available |
|
|---|---|---|---|---|---|---|
| assembla.com | $3 per project + $3 per gig |
pay per gb | 1 | pay per user | SVN, git, mercurial | ? |
| svnrepository.com | $3.95 | 500mb | 1 | unlimited | SVN, git, mercurial | trac, redmine |
| hosted-projects.com | $7 | 100mb | unlimited | unlimited | SVN | trac, WebDAV |
| wush.net | $6.5 | 1gb | 1 | unlimited | SVN | Trac, Bugzilla, FogBugz, WebDAV, WebSVN |
| cvsdude.com | $6 | 250mb | 2 | 5 | SVN | ? |
| beanstalkapp.com | $15 | 3gb | 10 | 5 | SVN | basecmap, campfire, fogbuz |
| svnsite.com | $5 | 400mb | 1 | 4 | SVN | |
| unfuddle.com | $9 | 512mb | unlimited | 10 | git, SVN | |
| codespaces.com | $3 | 500mb | unlimited | 2 | SVN | ? |
| projectlocker.com | $2.08 | 2.5gb | unlimited | 2 | git, SVN | Trac |
| GitHub.com | $7 | 600mb | 5 | 1 | git | ? |
| bitbucket.org | $5 | 500mb | 5 | 1 | mercurial | ? |
| xp-dev.com | $3.3 ($40 a year) | 2000mb | unlimited | unlimited | SVN | ? |
PHP Framework Comparison
Yes this is yet another PHP Framework comparison. A few months back I was trying to decide which PHP framework to use on a project. I wanted to use a currently popular framework because that way I would get the best support from the devoted contributors and users. Choosing a popular or active project is important when dealing with open source tools.
From my research I found that cakePHP, Zend Framework, and codeIgniter are currently the most popular PHP frameworks. Below are my notes and thoughts about of each framework.
Some of this will only make since if you are familiar with MVC frameworks, if you are not read this first http://en.wikipedia.org/wiki/Model-view-controller
cakePHP
Google results
- 4.75 million (term: cakephp)
Books
- Beginning CakePHP Novice Professional
- Practical CakePHP Projects
- CakePHP Application Development Step by step
Mailing List/Forum Activity
- Mailing list is a google group: http://groups.google.com/group/cake-php?pli=1
- seems to very active with around 2k posts a month. More details here http://groups.google.com/group/cake-php/about
Pros
- CoC type development
- Has a scaffolding option that allows you to test your basic database and model design without having to create a single view.
- Model relationship management. CakePHP has built in functionality to automatically load arrays of related model entities based on your model and database design. These are stored in model propeties named $belongsTo, $hasMany, and $belongsToAndHasMany. You can even control if cakePHP should load the related models, in case there is instance you don’t them.
- Automated code creation with bake script. The bake script generates controller methods, models, and even views. You can then edit them to learn more about how to use cake correctly.
- Focus is to keep the controllers light by having most of the functionality in the model or in something called a behavior which could be seen as a simple service layer
Cons
- I find the layout of the actual cakephp.org site confusing. For example the main menu has two items that at first glance I have no idea what they mean Bakery and Forge.
- Very array based. Which not really a bad thing most PHP frameworks and applications are array based. When possible I would rather use objects instead of arrays. Defined methods and properties can make coding a lot easier.
Notes
- Can be used by a novice or veteran PHP developer. Very similar to CodeIgniter. Very different from ZendFramework.
Zend Framework
Google results
- 4.63 million google results – (term: “zend framework”)
Books
- Zend Framework In Action
- Architects Guide to Programming Zend Framework
- Zend Framework Official Programmer Reference
- Beginning Zend Framework
- Pro Zend Framework CMS Building
Mailing List/Forum Activity
- Moderately active. Couldn’t tell exactly how active because the archive does not show dates
- http://framework.zend.com/wiki/display/ZFDEV/Mailing+Lists
Pros
- requires PHP 5.1.4 or newer. To me this is a pro because it forces you to use PHP5 which is more object oriented. Some may see this as a con.
- can pick and choose which features you want to use. A more open development path. Which is good for experienced developers.
Cons
- Doesn’t seem to follow CoC as much as cakePHP or CI
too much “just because” configuration.
Notes
- More for a veteran PHP developer. Very different from CakePHP and
CodeIgniter
I would definitely buy a book to help evaluate this framework fully.
CodeIgniter
Google results
- 714k google results – (term: codeigniter)
Books
- Professional CodeIgniter
- Practical CodeIgniter Projects Building
- Creating Microsite Manager with CodeIgniter
Mailing List/Forum Activity
- Very active.
http://codeigniter.com/forums/
Pros
- the manual/tutorial is excellent
- concise framework that allows u to get started very quickly
Cons
- Did not come with .htaccess file (problem for people new to apache)
- A lot of duplication in the controllers. A controller heavy framework
Notes
- Can be used be a novice or veteran PHP developer. Very similar to CakePHP. Very different than Zend Framework.











