Entries Tagged 'kiosk' ↓

Refactoring – What a time-saver

This weekend has been a nice relaxing weekend for me and so when I got back home this afternoon (on Sunday the 16th), I was in a great mood to refactor some of my kiosk code base. Now, I should start by saying, I decided to refactor code instead of write new code tonight because I wanted to lessen the number of files that needed to load in the Ajax functionality.

Kiosk, uses Ajax in interesting ways to provide a better experience, but with that, the Ajax applications were built as each page was assembled. This caused functionality across pages to get a bit messy or functionality shared across pages to get thrown into individual files. Well the problem with individual files, is that is yet another file for the browser to download.

So before I get any further, let me discuss refactoring and how it can solve many performance binds your application may be experiencing.

To start off, refactoring is taking common code, or code that is used across pages or frequently and moving it to a more global location so it can be called easier and the code only has to be written once.

So where can this help?

  • First of all, by refactoring code into a single global file, you can limit the number of HTTP requests if that file is accessible via the web. Since your common code is in a single file, the browser only has to fetch that code once, and will then likely cache that file for each page after, giving you even better performance.
  • Secondly, by placing the common code in a global method/function, you are writing less code. As now when you need to call that code on your second page, it is already written, so just call the function. Otherwise, you would need to write the code all over again.
  • Thirdly, less code equals smaller files. By refactoring your code, you can have smaller file sizes and in turn that is quicker to download, quicker to parse, and quicker to execute.

Now in my situation, I took about 4 JavaScript files and combined them into a single file adequately named “general.js”. The file contained code to automatically log the user out after a set amount of inactivity in the UI (User Interface). Secondly, it contained the version checking mechanism calls that see if they are running the latest version of the software. Unfortunately, those are the only two things it does right now, but as the project progresses, I am sure more utilities will get added in this file.

My next task is to refactor the Data Grid functionality so it is 1) XHTML, 2) easy to build complex columns with complex rows, 3) customizable by identifying StyleSheet classes for the columns and rows. Hopefully, I can get my head around this idea and get it working with little trouble to the programmer.

So what can you think of that you need to refactor? What performance gains do you suspect you will achieve with the refactoring you do? Any performance markers?

Fun with Kiosk

I am having a blast writing some of the things in kiosk. I have put in a few things, I am fairly certain no one has done before. The use of AJAX is completely written throughout the application and it has allowed the application to be placed on a level like no other.

For example, imagine having the ability to upload 1000 images for all of your products using cpCommerce or a different cart variant. You would have to upload them individually. Now, take a look at how kiosk handles it.

Kiosk Image Area Let’s take a look at the Kiosk Image Area located in the Administration Area. This area has many options, but look at the intriguing “Find FTP’d Images”. Now that is what I am talking about!


Kiosk Image Folder Now, this is the folder where the images are stored in Kiosk. Look carefully, and you will see a folder named “FTP”. This is the folder where your 1000 images should be uploaded to.


Kiosk Image Folder With Images To show you that this works, I have placed over 600 images in the folder! I realize that isn’t exactly 1000, but it should be enough to prove it will work with 1000 as well. Now, that I have the images placed, I need to head back to the Administration Area to complete this process.


Kiosk Image Inserting the Images Back in the Images Administration Area, I clicked on the “Find FTP’d Images” and this is what you will be presented with! Now realize, only one process of this is able to run at a time. So if you have 4 people updating the store, when one person runs this command, it will prevent the other 3 from running it too. With that said, the process also checks to see where in the process it is. For example, it checks every few seconds to see if it is finished inserting the images, or if it is still running. Now, I know what you are thinking. What about the Time Out Limit in PHP? How do you get around that? Well that is my secret and you can’t figure it out unless you pull down the Source Code from the SVN Repository.


Kiosk Image Inserting the Images Complete Finally, when it is all said and done, you the user are prompted with this final screen. The process is complete.


Kiosk Image Listing Upon clicking on “Close” it will reload the page to show all of your images now listed within the application. That’s it! It doesn’t get any easier than that! Feel free to comment and leave your remarks, as this is going to make kiosk stand out from Joe Smoe and you got my word on that!


kiosk Development

kiosk is progressing very well. I have started the programming some of the more significant portions of the project, such as, uploading Image, and creating Categories. Unlike cpCommerce images will not be handled during the Category, Product, Manufacturer, etc. creation. Instead, it is its’ own section. Why? This way you can upload all of your images via FTP, click a nice little link stating “Find Uploaded Images” and it will insert them into your database for you. Then all you have to do is assign them to a Product, Category, Manufacturer, or Both, or All Three!

Images are entirely reusable. So if you want to show a Product’s Image as the Category Image too, YOU CAN! And you can do it without uploading another file! I like to think kiosk is taking what cpCommerce started and taking it to a whole new level learning from its’ mistakes, and hopefully you all agree.

Well that is enough on that for now, I will update everyone once again, when I have these sections entirely done. Then you can pull it from the kiosk subversion repository and give it a try yourself.