|
Powered by
|
|
Section: All | News & Politics | Geek Stuff | Devel | Non-existent Life | Random | Food! | Life |
Fri, June 6, 2003
IlohaBlog: Monster class...
I've begun a complete rewrite of IlohaBlog. In the current iteration of the software, I solved most of the difficult problems, namely, the template system, the static output structure, archiving system, and database schema. However, the code behind it turned out to be spaghetti code with dozens of functions spread out across multiple include files all working on more global variables than I could keep track of. Some of the functionality was separated out to these functions, while large portions of the features were implemented in actual PHP files.
Show Rest of Post
The purpose of this rewrite is to reorganize the code and to use a more object oriented approach. Instead of relying on global variables, all functions that work on a common set of data are put inside one class. Also, all feature implementations would be handled by functions in such classes, to achieve a higher degree of separation between design and logic.
The problem is, the "blog" class is turning out to be a monster, and I can't seem to find a way to break it up. At this point, I've moved all the functions I had in the old system to a single "blog" class, and as things stand now, that class has more functions than I feel like counting, and over 1200 lines of code. About a third of them are miscellaneous functions that get stuff (i.e. entries, links, sections, authors) and modify data (insert/edit entries, etc). About a third of the functions are responsible for merging data and design (i.e. create HTML), and the other third of the functions are for the archiving system (i.e. takes HTML and writes them out to static files). The problem is, they all rely on each other. The archiving functions need the display functions and the display functions need the miscellaneous functions. The miscellaneous functions then call the archiving functions where changes are made.
The other question is, whether or not there really is any merit to breaking up this monster class. The only reason I feel like breaking it up is because it's big, but other than that, I'm not entirely sure if breaking it up has any merit at all...
|
|
Ryo Chijiiwa
I'm a biologically Japanese, culturally American, Germany-raised, socially liberal, politically independent, gun-totin', code writin' dude. My life is currently sponsored by Google.
|
Posted Fri, June 6, 2003 12:36 by dirvish
Couldn't a lot of those functions in the blog class be their own classes?
[moderate]