Completely Drained, Totally Knocked Out and Annoyed Too

Lately I have been thinking less and less, but today my head is really out of it. It is because of the music I use to shield myself from the ever-present, never-ending loud noise. On top of that, over the last few days I have fallen for Christian music again, so I do not know whether it scrambled my brain that quickly, or whether it is because I listen to it almost nonstop at max volume.

Still, I am better off than I would be without the music and the headphones. So what happened? All day today I have been doing silly things and not thinking at all about what would be best, fastest and simplest. It started right after I woke up, when I decided to optimize the CasdMladez website. I did it by hand for about 1.5 hours before it occurred to me to write a program like this: 👻 The page moved out and left no forwarding address.

The idea is that I enter parameters and it prints out code that I just copy to wherever it fits best, and it also replaces the variables with new names on its own.

This will make optimizing all my websites much easier – I write every website as unoptimized at first, I simply have “TableRow” classes that I generate myself based on table definitions, and they have 3 main advantages:

  1. I create the tables in the database with a single click
  2. I just create a TableRow object, which is strictly typed (it knows exactly which columns the table has and what type they are), and then I can insert, update, delete and retrieve data from the table very easily
  3. All I need is to create a TableRow....2 definition with different columns and write some very simple code that moves the data into the new table, deletes the old one and renames the new one to the old name, so nobody notices a thing.

Of course, what I am doing has more upsides than downsides. If I change a column name, I will have to change it everywhere by hand.

That could be worked around by having a class with constants for all the columns, and whenever I changed a table definition, a new file with constants would be generated. Visual Studio would then tell me that it cannot find such and such constant, and I could fix it. It still would not fix type-related errors, although… that could also be solved with a class of constants.

It is an excellent idea, and I am not sure whether I should start building it right away. I feel a slight urge to, but probably not, since after all I do not change column names or the like very often. The most time I wasted today went into manually moving table names into the object that holds the individual columns. Until now they lived in a dictionary (a collection of objects indexed by an object of any type, in other words you could call it an associative array), and once I had done that, I also had to write a class with an interface similar to a dictionary, while actually being a plain collection.

I will probably roll it back using the files I have on my hosting, for the first time in my life doing something like that, because the old way was more logical.

Categories

Leave a Reply