Behind The Scenes Tour

Originally, I wrote this website in PHP/MySql because that's all I had available from GoDaddy. Even then, I couldn't use PDO. When I went to port the website oer to ASP.Net, I found out I was stuck at NET 3.5. That should have been OK, that's what I was taught in college. But I realized that if I could move to NET 4.0, I could use MVC (which I wasn't taught in college, but sounded really fun)! They agreed to an upgrade that included NET 4.6, PHP/PDO and even Python (something else I wanted to take in College that wasn't available).

So here is the newer ASP.NET MVC website backed with the old MySql database. Learning MVC was somewhat challenging, frustrating, and every bit as much fun as I expected (eventually).

In the Begining . . .

I had played with the website way back in the early days of HTML, early 2000's. It was all handwritten, WYSIWYG editors were really terrible back then. I got used to doing everything by hand.

I overhauled the whole site when I took a Web Programming class. It was completely rewritten in HTML4/XHTML with enough .css and javascript thown in to make us think we knew what we were doing. I know the top bar and side menu are redundant for navigation, I wanted to show that I could do both. Once I used Javascript to write the time and date, I realized that I could use it to change the CSS. For class, there were only 4 different color schemes tied to the time of day. (Now the site changes color every hour, on the hour. Check it out!) This was a programming/design class only, I didn't have any real provision for connecting to a real database.

After college

The next generation came with the PHP/MySql upgrade.The PHP/MySql site is still available. I had to learn MySqli to connect from PHP, we were taught PDO with MySql (depricated) for a back up. With this revision I could actually connect to a real database and have some fun!

One of my favorite things about the PHP/MySql site is that you don't have to be logged into the site to keep stuff in your cart. If you are logged in, your stuff is written to a cart table coded with your userId. But if you aren't logged in, your cart is stored in _SESSION variables. In PHP, I wrote an anonymous class for the connection. Then each connection extended that class to fit their needs. The SESSION_Cart class extends the Base_Cart class to do all the CRUD functions in _SESSION variables. The DbCart class does the same with storage in the actual database. I wanted to write a routine that would transfer your SESSION item to the Db if you log in, but then I moved on to MVC.

Now We're Cookin'!

Learning ASP.NET MVC had it's own challenges. Most of the documentation I found covered 'code first'. The code first method really looks handy! You can just write the classes to describe the data, then create the database from the classes! But I already had a database, so I needed Data first, or Entity Framework first. Making the connection to MySql was really pretty easy. Getting the model correct was more difficult.

The State Magnets and Clothing both have an Id, product code, picture, and price. But the clothing also needs a back picture, type of clothing, sizes and I also included sleeve length to help sorting (although everything we have now is short sleeve). The magnets don't need a back picture or sleeve length, but I wanted to include the state captial and they do need an available quantity. IF I were writing this code first, I would have combined the common items into a Base Products class and derived Magnet and Clothing classes from it. When I had the tables seperated like that, they follow 1st normal form, but ASP/MVC didn't like the duplicate keys on all the Id fields. I could have broken 1st normal form and put everything together, leaving fields that don't apply as NULL, and used a catagory field as a discriminator for magnets, T-shirts, onsies, etc. What I wound up doing was seperating the tables by the physical type of object. The magnets don't really need a price, they're all the same. That still duplicates the Id, product code, and picture fields (only a reference to the file/folder of the picture is stored). I think I can live with that, it took longer to write this article than to rebuild the Model, most of the Controllers and the other Views.

I'm not sure where this will go from here. I wrote most of this website as more of a resume than actually hoping people would buy the shirts or magnets. (The clothing listed in the store is clothes I have PICTURES of, not necessarily have the actual items.) I'll try to keep this updated if anything else interesting happens.


-Cube