Tuesday, September 07, 2010

Five (more) tips for speeding up Eclipse PDT

In a previous blog post written by Zviki Cohen, five simple tips were suggested to help Eclipse PHP Development Tools (PDT) users speeding up their development environment . I want to share five more tricks that can dramatically improve your experience with Eclipse and PDT. Not only these tips help speeding up performance but also make your PHP source code more controlled.

1. Exclude non-source-code folders and manage wisely your project buildpath - Buildpath is a set of paths indicating what folders should be scanned (built) by Eclipse. If the project Buildpath includes its root (for example) then all folders that include images, javascript , style sheets and other non-source related files are listed to the scanner. Although theoretically most of these files are not actually scanned since non-PHP content types files are skipped, Eclipse keeps track on changes and make some redundant operations on these folders that may contain thousands of irrelevant files, hence perform bad .

2. Setup project include path - to optimize the include/require statements path resolving it is more than useful to make sure that the project include path settings are set correctly. Representing the actual include path is a key to make things work smoothly.

3. External libraries are not part of your code, don't keep it under your project resources - this is a classic project configuration mistake. Make sure that frameworks and external libraries are not included under your project sources, instead link it to your project as a library. Eclipse can relate to these ("static"/"read-only") frameworks differently than your ("dynamic"/"writeable") code which is under constant development. Frameworks should be scanned once and not be part of your project source code.

4. Split your project into sub-projects and modules - it makes sense you separate your core business, services, client side interface, tests and other modules into different projects that have different natures and make the components more flexible and easy to be re-used and maintained by others. Often, I see PHP projects that include dozens of thousands of flat hierarchy source code that is hard to maintain and configure.

5. Share your project configuration files with your team. Configure your project once and make sure all team members follow the same conventions and management rules. These files are located under your project root (the dot files) and can be shared in your source code repository.

To summarize things "Mastering your development environment is as important as mastering your source code" - this concept is sometimes forgotten by scripting language developer who are used to a flat hierarchy source code. Although I consider this as a major strength of scripting languages it doesn't mean that project management should be flat...