encapsulation is wonderful
i just finished building an object in php. well, a “class” really, called HTMLTable HTMLTable (latest version) to help me generate html tables.
my financial web application spits out a lot of information in the form of tables, with headers, column headers, footers, etc. i’ve been using a simple function that surrounds the content in each cell of my tables with TDs. but i still had to make sure all the TRs were in the right places, and i had to get the COLSPANs right for my headers and footers.
now i’ve just got this simple class with functions for adding-in the various parts of the table and then a function that spits out html all nice and formatted, all the right tags in the right place. ahh…
it was just so wonderful to spend time this morning and this evening crafting it, revising it, making it sure it accomodates all my known cases of table usage.
whereas all the other code i’ve written has been motivated by “i need a webpage to do X” or “i need a function that i think i might use in the future” this is the first time i’ve worked on something that seemed to have some objective rightness in the universe. like i wasn’t creating something new, i was discovering something old.
Keep going, don’t stop with one, more objects, aren’t they so purdy, many more objects, fill the world with ’em” said the mad object-oriented programmer.
built one the other day to generate HTML select drop down boxes and then extended it (!) to create a specific select box that I use frequently. :)