Just one more quick change

So this morning’s list of things to do includes finding a way to include a pdf file on certain pages. The solution seems easy enough but this is somewhere around a dozen “improvements” to this site. The site is also barely keeping up with the coding standards and needs a complete redo anyway. Those previous improvements have seen the datable add columns, add new tables and add characters to the data string so the potential for this getting out of hand is real.

So what might the solution be? Well, I feel a restructure is in order. A number of these improvements are of the exact type of page addition, just targeting a different group of pages. That means that the main table could stay the same size if smaller tables were created using the id from the main table as a linking key. I could set those tables to have just the few columns needed for the information additions and do a query based on another field which is what separates these pages in to the individual groups of the differing information needing to be added.

As far as the data string I could simply supply two pieces of information, id and this field. With that information and a series of if/if else statements I can determine the query and which table to query to find out if additional information exists for that particular page query. This could allow for potential expansion of “improvements” that seem to fit this style.

The improvements would possibly open up improvements in a different area where a page is built with a list of items compiled from a separate table. By changing the structure of that table, and again using the id from the main table, I should be able to use join statements to query the information the way I need to.

The final solution should keep the data string to a shortened length and set up more individualized queries which will improve performance, cut down on possible data errors and make the code maybe more reader friendly. The performance won’t be much unless this site grows by a factor that is not humanly fathomable but writing code with performance in mind is never a bad thing. The data errors are a real thing. If the query is going over data that can be negated from the query based off of a field reference then there is no way erroneous data from those rows/tables can be put into the output. Finally, being able to make sense of the data being received in each query from a programmers reading standpoint will help to get a different programmer up to speed if ever asked to contribute or fix an issue in the coding. Lastly but not mentioned is the fact that organizing the database and all the tables will make a redesign and updating of the code a much easier task because I won’t have to factor in all these little rogue “fixes” and “improvements” that have to be addressed individually.

So there you have it. A quick look in the mind of a real-world programmer trying to solve a real-world issue. May not be the best solution but it is the one that I was able to come up with based on everything I know about this particular situation. I expressed some of those factors above but like with anything else there are a number of factors I didn’t disclose either intentionally or not. More than anything I now have an understanding of the things the customer is going to want to continue to add so this fix should make the next improvements easier to make.

Now time to start the coding and no, it won’t be a quick change. It will be time consuming and have to be slow and methodical so I don’t break the entire site in the process.

Leave a Reply

Your email address will not be published.