The value of knowledge

Y’know, this is quite a large project. I’ve been steadily adding functionality, which requires a bit of work on each step. First, I update the database model, then I update the PHP model, then I add create, edit, and view HTML for inserting, updating, and presenting the model. Then, I add custom styles and JavaScript that are appropriate to only those screens. Then, I…well, you get the picture.

Don’t get me wrong, I’m not complaining. This is a blast, and I just rattled off five different programming languages that I am coding in on a daily basis: MySQL, PHP, HTML, CSS, and JavaScript. The styles also tend require fine-tuning for the various viewport sizes. But, with proper planning–and, I’ve sure done a lot of that–I’m able to create functionality that is reusable and portable, reducing my efforts to only focus mostly on the business logic, which is the how the data is entered and presented for the end-user.

I’ve also been adding to my PHP models, enabling me to navigate database objects using simple, readable code. Take, for example, an organization’s leagues and tournaments. Since the tables are all separated (`organization`, `competition`, and `organization_competition`), writing the query logic every time would get old real fast. By adding the logic to the PHP model, I’m able to get them by simply writing $organization->competitions.

This makes the code read like a book, almost. I like to work this way, “backwards” in a sense, where I write my business logic as I would like to read it. I tend to write my blog posts and emails much like I’ve wrote reports and resumes, with drafts and proofreading. The same is done with my code. When you’re dealing with a lot of code–so far I’ve hand-written roughly 64,000 lines (admittedly, “expanded” lines)–it is imperative that return visits are comprehensible and easy to pick back up.

Once I determine how to best write the end logic, I go back and update the PHP models to add the necessary properties and methods that enable the business logic I wrote to run. Certainly, there are areas for improvement, though. I’m fairly certain that will always be the case, however.