-
28 January 2009Behind the scenes
So what's going on lately? I've been quite busy the last few weeks on the infamous refactoring I was talking about on the forums now and then without seemingly getting anywhere ;)
I feel chatty today so warning... here follows a long boring post about the joys of programming web sites.When I started the Reviewing the Kanji website I was learning php and like every self respecting programmer would do after many years of hardcore C and assembler programming, guess what I did ? Of course I stuck to php4 instead of moving to php5, I completely forgot about OO practices, was oblivious to such concepts as "decoupling", "domain logic", "data model" etc etc. And just plain wrote a real monster of flat files and would-be classes that were really just a collection of code that was starting to repeat itself. Whew! ^_^
Funny thing is that I had the exact same experience with Javascript last couple years. I wrote some really nasty javascript for at least a year, and then discovered that *gasp* you can write decent object oriented code in Javascript. I started relearning seemingly everything I had learned about programming before.
Fast forward to about a year ago. I put up an Alpha version of Trinity and then development slowed down to almost a halt. I realized I couldn't work on the site like this anymore. I didn't have the heart to add any new features because I knew the more I added to it, the more unwieldy it became.. and eventually the more difficult it would be to clean up the mess.
Last year I spent a while looking at different php frameworks such as CakePhp, CodeIgniter, Zend... but I kept coming back to Symfony.
Introducing the "Core framework" :
At its heart this framework is a very simplified version of Symfony. It is basically all the core features of Symfony's MVC, the front controller, actions components, helpers and templates, the ability to extend the core classes, to have multiple applications under one root project folder; a solid error and exception handling with error 404 and 500 pages.
The url routing system is where I started becoming more practical and instead of cherry picking functions I've imported the whole routing class as is.
Where I departed from Symfony is for the database access. I wanted something simpler and I liked the fluent interface of Zend Database and Zend Select, but because of the huge number of include files, I ended up rewriting the Database and Select objects.
I thought this was interesting... using existing documentation as a design documentation for writing your own code. Many times I wondered, shouldn'tt I stop this whole fiasco and just use the damned framework as it is? But in retrospect I have learned a LOT about Php while dissecting Symfony and Zend, so I think it was well worth it. I discovered many functions in Php that I had no idea even existed.
An interesting aspect of using another framework as a design document was that for example, should I decide later to move on to the real Zend Database and Zend Select, in theory at least, the transition should be easy, because the function calls are identical.
So here I am, finally... rewriting THE ENTIRE website code in an MVC architecture.
As of writing I am about 40% done. I've been working mostly on the sign in/sign out, register, edit account, update password pages, and the static pages (learn more, about, ...). I've intentionally kept the actual site functionality for the second phase to "warm up" so to speak to the MVC logic before attempting to design classes for the most critical part of the site. Thankfully doing the sign in/sign out procedure, the email confirmations, password update etc exposed many little holes that were still unplugged in the Core framework and it feels now almost complete.
The screenshot shows the "live documentation" as I call it. I honestly can't read anything out of phpdoc generated documentation, so while I've gotten used to documenting in the code with phpdoc, I hand edit the documentation with basic html code to cover the main points of the framework, and document methods of classes as I add them. The documentation itself is the first app I wrote with the framework and so it is itself at the code level both a test and a demonstration of the use of the helpers and other features of the framework.
I'm hoping to push the refactored site online before the end of February, but it may take up to the end of March, I don't know... the Study page and the Flashcard Review page are going to be the most challenging to rewrite. The code itself is fairly simple but I'll have to redesign those classes very carefully. If done well, I may be able to add Google Gears someday for offline support.
Cheers
By Month
- Oct 2024 (1)
- Sep 2024 (1)
- Jun 2024 (2)
- May 2024 (4)
- Apr 2024 (3)
- Mar 2024 (1)
- Feb 2024 (1)
- Dec 2023 (1)
- Nov 2023 (2)
- Oct 2023 (2)
- Apr 2023 (2)
- Mar 2023 (2)
- Feb 2023 (1)
- Jan 2023 (2)
- Dec 2022 (1)
- Nov 2022 (2)
- Oct 2022 (3)
- Sep 2022 (1)
- May 2022 (4)
- Apr 2022 (1)
- Feb 2022 (2)
- Jan 2022 (2)
- Dec 2021 (4)
- Nov 2021 (2)
- Oct 2021 (2)
- Sep 2021 (2)
- Aug 2021 (1)
- Apr 2021 (2)
- Feb 2021 (3)
- Jan 2021 (3)
- Dec 2020 (1)
- Nov 2020 (1)
- May 2020 (1)
- Apr 2020 (1)
- Jan 2020 (1)
- Oct 2019 (1)
- Sep 2019 (1)
- Aug 2019 (4)
- Jul 2019 (3)
- Jun 2019 (1)
- May 2019 (1)
- Mar 2019 (2)
- Jan 2019 (1)
- Nov 2018 (3)
- Oct 2018 (8)
- Sep 2018 (4)
- Aug 2018 (3)
- Jul 2018 (1)
- Jun 2018 (4)
- May 2018 (1)
- Apr 2018 (1)
- Mar 2018 (1)
- Jan 2018 (1)
- Dec 2017 (6)
- Nov 2017 (4)
- Oct 2017 (4)
- Sep 2017 (5)
- Aug 2017 (5)
- Jun 2017 (3)
- May 2017 (2)
- Apr 2017 (3)
- Mar 2017 (7)
- Feb 2017 (10)
- Jan 2017 (11)
- Dec 2016 (6)
- Nov 2016 (5)
- Oct 2016 (6)
- Sep 2016 (7)
- Aug 2016 (3)
- May 2016 (1)
- Mar 2016 (2)
- Jan 2016 (1)
- Dec 2015 (3)
- Nov 2015 (1)
- Oct 2015 (1)
- Sep 2015 (7)
- Jul 2015 (2)
- Jun 2015 (1)
- May 2015 (5)
- Apr 2015 (4)
- Mar 2015 (5)
- Feb 2015 (4)
- Jan 2015 (5)
- Dec 2014 (4)
- Nov 2014 (3)
- Oct 2014 (2)
- Jun 2014 (1)
- Apr 2014 (2)
- Mar 2014 (4)
- Feb 2014 (3)
- Jan 2014 (4)
- Dec 2013 (2)
- Oct 2013 (1)
- Sep 2013 (1)
- Jun 2013 (4)
- May 2013 (1)
- Mar 2013 (1)
- Jan 2013 (2)
- Oct 2012 (2)
- Aug 2012 (1)
- Jul 2012 (2)
- Jun 2012 (2)
- May 2012 (1)
- Mar 2012 (2)
- May 2011 (1)
- Apr 2011 (4)
- Mar 2011 (3)
- Feb 2011 (2)
- Jan 2011 (2)
- Dec 2010 (8)
- Nov 2010 (8)
- Oct 2010 (3)
- Sep 2010 (3)
- Aug 2010 (1)
- Jul 2010 (2)
- Jun 2010 (5)
- May 2010 (1)
- Apr 2010 (3)
- Mar 2010 (4)
- Feb 2010 (2)
- Jan 2010 (1)
- Dec 2009 (5)
- Nov 2009 (5)
- Oct 2009 (1)
- Aug 2009 (1)
- May 2009 (5)
- Apr 2009 (2)
- Mar 2009 (1)
- Feb 2009 (2)
- Jan 2009 (2)
- Nov 2008 (1)
- Oct 2008 (1)
- Sep 2008 (1)
- May 2008 (2)
- Apr 2008 (1)
- Feb 2008 (6)
- Jan 2008 (5)
- Dec 2007 (6)
- Oct 2007 (1)
- Sep 2007 (2)
- Aug 2007 (3)
- Jun 2007 (1)
- May 2007 (5)
- Apr 2007 (1)
- Mar 2007 (2)
- Feb 2007 (1)
- Jan 2007 (4)
- Dec 2006 (3)
- Aug 2006 (1)
- Jun 2006 (3)
- Apr 2006 (6)
- Mar 2006 (8)
- Feb 2006 (1)
- Jan 2006 (4)
- Nov 2005 (1)
- Oct 2005 (4)
- Sep 2005 (1)
- Aug 2005 (11)