I recently gave a brief overview of my permanent disability and workers’ compensation benefit calculators. In that post I wrote a little bit about how my online benefits calculators work. Since then I’ve posted about my use of javascript, PHP, and AJAX in creating these permanent disability and permanent impairment calculators.

As I mentioned in the prior post in this series, my first few versions of this website and its workers’ compensation calculators did not use MySQL.  The initial versions of this site only saved information – which meant I only had to use PHP to open a file on the server, add an extra line of information, and then close the file.  This had several problems:

  1. Once my website became more popular, it was not uncommon to have more than one user online.  That meant the server tried to open the file – but couldn’t since it was already open.  This caused the program to freak out.
  2. In order to view just a little bit of information, I had to download the entire file.  This got crazy pretty quickly.
  3. Each time the file got larger, it would take slightly longer to open, append with more information, and close.

MySQL is an incredible tool for storing, organizing, and retrieving a large amount of data.   Like PHP, it is also open-source.  This means it is:

  • Well supported.  There are lots of online resources and books to help you learn.
  • Secure.  Lots of people spend a lot of time thinking of ways to prevent security vulnerabilities.
  • Customizable.  You can configure or even rewrite it, if you wish.
  • Interoperability.  You can save it to just about any format – including MS Excel spreadsheets.
  • Free.  Unlike Oracle or any of the MS alternatives, it is totally free.

So, why did I avoid MySQL?  I didn’t want to have to learn a whole new programming language.  I had to learn how to set up a database, tables within the database, how to search for information in a table, how to put information into a table, and how to change information which was already in a table.  There was a lot of trial and error.  I ended up doing some pretty cool things in the process of learning this language.  Some examples:

  • Teaching others some of the basics of MySQL
  • Writing a program for cataloging books
  • Writing several programs which performed various calculations to track invoices, billings, etc
  • Setting up several blogs/websites

The end result of learning this language is a more interactive website.  One of the last incarnations of this site was a version that would show different color schemes, advertisers, and messages depending upon the user.  All of this was made possible by large amounts of data stored in MySQL.

Thus ends my technical overview of my workers’ compensation permanent disability calculators!  If you have any questions, please feel free to email me or leave a comment below!

Howie Mandell trying to look hard.
Howie Mandell trying to look hard.

Javascript appears all over the internet. You can be pretty sure that your favorite websites use a LOT of javascript. You see it every time a website creates a pop-up advertisement, sends you an alert, lets you bookmark their page, or interacts with you in some way.

I’ve written some pretty cool (in my nerdy opinion) things in javascript:

  • A blackjack strategy simulator. You tell the program how many decks, when you want to hit, stand, double down depending on the deck count, and it will run through a given number of hands – telling you how much your strategy has won/lost overall.
  • A “Deal or No Deal” odds simulator. The program calculated the average of the remaining unopened suitcases – to compare against the Banker’s offer. It made rudimentary guesses about how much the Banker would offer. There has been some incredible and complex analysis of how these offers are created.
  • A billing program. It had separate timers for different tasks, tallied time, expenses, ability to save reports, and create invoices for different clients.
  • A simple program for tallying points for gin rummy.
  • Several small programs for solving various internet website puzzles.
  • Several small tools which allow me to write other programs or web pages more efficiently.

I’ve written innumerable other mini-programs which either had a very limited or one-time use or which I never developed into an actual program. One example was a program that would help me quickly search muliple ebay auctions and compare the various prices. Another was a Sudoku puzzle solver which I never completed.

I recently gave a brief overview of my permanent disability and workers’ compensation benefit calculators. In that post I wrote a little bit about how my online benefits calculators work. Since then I’ve posted about my use of javascript and PHP in creating these permanent disability and permanent impairment calculators.

As I’ve mentioned in those prior posts, both javascript and PHP have inherent downsides. My very first attempt at online benefits calculators using javascript and ASP actually suffered from all of the downsides of javascript and PHP. Those first calculators used tons of user’s computers’ resources, bandwidth, and server power. However, learning more about AJAX enabled me to build a set of calculators which benefited from the strengths of javascript and PHP while minimizing, if not eliminating, their weaknesses.

The acronym “AJAX” refers to “asynchronous javascript and XML” – a collection of other technologies which allow a webpage to communicate with a web server without requiring an entire page download.

Example 1: A calculator without AJAX calculating “6 x 7” would send information to be calculated to the web server. The web server would then respond by giving you an entirely new page with the answer, “42”. However, in order to download that answer you would need to download a whole new page – and all the images, text, and code associated with it. Even a normal web page could be between 30,000 and 300,000 bytes in size. ((A download of “www.google.com” was approximately 30,000 bytes and a download of “www.yahoo.com” was approximately 300,000 bytes.))

Example 2: A calculator with AJAX calculating “6 x 7” would send information to be calculated to the web server. The web server would then respond by sending back just the answer, “42”. This would be 2 bytes.

If my calculators needed to download of 300 kilobytes for every single operation, a simple calculation could take about 30 seconds on dialup and a full 1 second on broadband. Although 1 second doesn’t seem like a long time – it is in the internet age. Most of the calculations on this site take approximately .500 seconds using a broadband connection. I would guess that about 90% of that time is due to network latency/network lag – which wouldn’t be much different for a dialup connection.

For the first few months after the launch of this website, it did not use a MySQL database. I actually went to some pretty ridiculous extremes to not have to learn a new programming language. I eventually gave in, learned how to use MySQL and am a better programmer for it.

Next up, MySQL!

I recently gave a brief overview of my permanent disability and workers’ compensation benefit calculators. In that post I wrote a little bit about how my online benefits calculators work. My last post in this series was about how and why these permanent disability and workers’ compensation benefits calculators use javascript.

I had tried Microsoft’s ASP (active server pages) in experimenting with a prior version of my permanent impairment calculators, and while functional, the coding was a complete mess since I didn’t fully understand what I was doing. To make matters worse, the only manuals on ASP I could find gave examples using VBScript – which is MS’s version of javascript. ((Can’t we all just get along?))

Just over a year ago a friend of mine encouraged me to try PHP. (Thanks Johnny!) Its syntax, the way in which you write code, is very similar to javascript and was fairly easy to learn.

Unlike javascript, PHP is run only on the web server. There are a lot of benefits to moving all of the calculations from being performed by a user’s computer to my web server:

  • Uniformity. All calculations will always be performed by the web server in the same exact way – irrespective of the user’s computer.
  • Speed. Since all calculations are performed on the web server, the user’s computer doesn’t need to do any number crunching.
  • Protection. All of the formulas, tables, and magical incantations used to generate the calculations are kept only on the web server.

But, PHP isn’t without its downsides:

  • PHP is being used to perform a calculation, even when javascript would be faster. Javascript takes longer to crunch the answer, but you have to “wait” for PHP to send a request to the server and wait for the answer. ((I say “faster,” but we’re talking about the difference between 10 milliseconds for javascript to calculate the answer and waiting 400 milliseconds for the server to return the answer.))
  • A pure PHP calculator would require the user to send the web server the entire page and wait for a whole new page to load. Every calculation would take a full second or more using a pure PHP calculator. ((A second might not seem like a long time – but it is when you’re using a computer. I’d bet that if these calculators took 1 second for everything (such as finding an occupational code or work restriction) no one would use them.))
  • When PHP is used to perform handle all calculations, there is more of a strain on the web server itself.

Using AJAX (more on this later) to create workers’ compensation benefits calculators has allowed me to take advantage of all of the strengths of javascript and PHP and minimize the negatives of these technologies.

Next up, AJAX!

As the man said, “you can’t always get what you want.” Here’s what I need from a cell phone:

  • Multiple numbers per contact
  • Multiple alarms
  • Scheduling events
  • Text messaging
  • Ability to jot down notes
  • A battery with 4 hours of talk time and a few days of standby time

My current phone can do all that. The battery life is failing, reception is spotty, and its been dropped more times than I was as a baby. Here’s what I want out of a new phone:

  1. Contacts and calendar that can synch with my laptop
  2. Bluetooth support and file access (to transfer files wirelessly)
  3. A web browser that works as well as IE7 or FF2 (Namely: proper HTML rendering, CSS rendering, cookies, and javascript support)

I know the LG Dare can handle #1 and #2, but I’m dubious about its support for #3.

I know the iPhone can handle #3 fairly well, but am dubious about its support for #1 and #2.