
Refactoring BloggX

And Tadaaa I finish the refactoring of BloggX, a java GPL component:
Blogg-X is a cross platform (OS X, Windows XP, #Linux) content management tool for websites based on the #Joomla! CMS. Blogg-X runs locally on your computer as a desktop application. Utilizing built in WYSIWYG and HTML source editors you can post rich content on your #Joomla! site without the use of the web browser.
Refactoring is a technique for restructuring an existing code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a ‘refactoring’) does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it’s less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring
And I want to show here some results achieved, The author has done a great job, and I have tried to bring my #Java expertise to help him bring new functionnalities faster. Moreover a JAVA break just for fun (but hehe I already do Java at work 🙂 ) was needed after being so frustrated with PHP…
But let me be a little more technical, below are some numbers create with a tool of IBM: Structural Analysis for #Java: Structural Analysis for JavaTM (SA4J) is a technology that analyzes structural dependencies of Java applications in order to measure their stability. It detects structural "anti-patterns" (suspicious design elements) and provides dependency web browsing for detailed exploration of anti-patterns in the dependency web. SA4J also enables "what if" analysis in order to assess the impact of change on the functionality of the application; and it offers guidelines for package re-factoring.
Before: BloggX 2.11 | After BloggX refactoring | Remarks | |||||||||||||||||||||||||||||||||||||||||||||||||
Summary | The overall stability of the system is 69% . There are 24 objects, forming a total of 139 relationships. The typical object in this system immediately depends on 5.79 objects. On average, the modification of one object potentially affects 7.2 other objects. | The overall stability of the system is 87% . There are 82 objects, forming a total of 292 relationships. The typical object in this system immediately depends on 3.56 objects. On average, the modification of one object potentially affects 10.3 other objects. | Highly stable systems are typically above 90%. Yes the system before was 69% but it was containing methods of 700 lines… | ||||||||||||||||||||||||||||||||||||||||||||||||
Statistics |
|
| Explosion of number of Objects and relationship: BloggX is an ambitious project and functionnalities has to be distributed… | ||||||||||||||||||||||||||||||||||||||||||||||||
Structural patterns |
|
| Al lot better after all changes i’ve made 🙂 but not perfect 😉 A lot of cleaned interface are still missing. | ||||||||||||||||||||||||||||||||||||||||||||||||
Exploring relationship | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||
Distance graph | ![]() | ![]() | The distance is a calculated value, that describes the encapsulation of a certain package While a distance of "0" means a "perfect" encapsulation, 1 stands for a complete lack of encapsulation. A lot of the code is below the medium line now, but still too high | ||||||||||||||||||||||||||||||||||||||||||||||||
As side effect, I correct some bugs by removing duplicated code and non obvious by better localizing responsabilities. Now the author will need time to understand all changes I’ve done, but overall It will be easier to maintain BloggX
One of the best book about Refactoring, which has change my life of developer in 2002 is
![]() | Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts 464 pages Publisher: Addison-Wesley Professional; 1st edition (June 28, 1999) ISBN: 0201485672 |
Martin Fowler also explain why and how you can convince your manager you have to invest daily refactoring time.