Archive

Archive for the ‘Resources List’ Category

How to handle checkout when we are selling unique products?

Checkout process for unique product has to be handled in different way than products which are available in quantities. Products with one quantity are unique product. Paintings, concert tickets, hotel rooms, flight tickets ( when you choose a specific seat) are unique products. Old household items are also unique items.

We have two types of process for processing any purchase. In first type, we can do cart based checkout where a user usually add more than one product to their cart. In the end of shopping process, user do checkout process for all products in his or her cart. In  second type of process, it is items based, user is forwarded to checkout process as soon as “Buy Now” button is pressed.

In this article, we will try to handle second situation as most of eCommerce websites which handles unique products handles checkout through that process only. We will discuss cart based process in another article in future.

First, let’s create list of challenges we have with unique products checkout.

1. As product is unique, we need to avoid over selling. Unique products have only ONE quantity. We cannot sell it to more than one user.
2. Payment stage in checkout process took some time as most of the time users will be redirected to a third party payment gateway.
3. Users leave the checkout process in middle.
4. A payment gateway does not reply in time or any other technical event may prevent us from getting payment processing information in time.
Before we go further, we need to identify the intensity of probability of duplicate orders. If you have really high demand for your unique products, then you have a big business opportunity. Instead of going into simple eCommerce checkout, you should introduce “Auction” model. This model works best for unique items like paintings for famous painters.

 

Lets assume 3 different situations. I will try to propose solution according to those situation.

1. Very high demand.
I will really recommend an “Auction” Model for this portal. You have customers and you SHOULD  monetize them for sake of your business.

2. Moderate demand
Mark product unavailable as soon as a user start checkout process. Set a timeout of specified minutes. Inform user about this time frame. We cannot tolerate slow users . Those will be handled in next situation.

3. Low Demand
Mark product unavailable as soon as a user start checkout process. Set a timeout of specified minutes. Refresh this timeout after every page refresh for user. By refreshing timeout with every request, we can handle very slow users. In my view, every eCommerce system at least cover this situation.

Now big question, How new users will be handled while an old user is in checkout process?

It depends on one very big factor, Are you using cache or indexer based search for your site? If you are not using any cache or indexer, you can simply make product unavailable.

In case of cache or indexer, we need adopt a different approach. I will  recommended leaving your cache or indexer system unchanged. Whenever a user tries to purchase an item, we need to put an extra check for checking “availability” of product for smooth transaction. If product is unavailable, we need to inform user.  WE may/can also show a waiting window to this user if timeframe is few minutes. In waiting window, A message like “We are checking availability of this product, this may take few minutes, Please stand by” can be shown. After specified time, if product is still available we can proceed with checkout or we can say sorry to that user and show other relevant products to him or her.

 

One thing more, do not forgot to record incidence of purchases where user did not finish payment process. You may contact them to know why they left process in the middle. This may be vital for your business.

 

 

 

 

In defense of QA team: Who is responsible for errors in any software or website?

Consider this hypothetical situation.

Something very precious was in a building. Building was being guarded by a guard who was responsible for the safety of precious item. A thief using his intelligence and luck stole that precious item from building. At a later stage, thief was caught but he claims that only security guard can be prosecuted for theft, in fact he demands that his act should be rewarded as a skill.

What is your first reaction? Impressed with thief’s arguments? Feeling angry with security guard? Or laughing on the irony? It can be anything, but I am going to ask a fundamental question, should we stop prosecuting thief for theft?

In my view, a thief is still a thief, no matter who was ultimate responsible person in this case.

Now, let’s apply this situational story on software development. An error ( I am not using the word ‘Bug’ intentionally) was found in software or website, who will be held responsible?

In my view, as far as responsibility is concerned, it lies with QA team, but development team is still responsible and can’t be absolve of that error.

Before we continue, lets me clarify my definition of error and bug in context of this article. A bug is an un-intentional behavior of application while an error is simply a failure of one feature. For example, broken login form is an error, but slowness of login system or successful login without correct details is a bug.

IN any software development process, basic testing of functionality has to be done by development team only. Even in our constitutional and parliamentarian laws, we have a term ‘merchantability’ … which gives an implied warranty in any purchase of product or service we bought from seller. So basic ‘merchantability’ has to be incorporated in any product or service. A pencil doesn’t need a documentation or purpose statement. Pencil is always expected to write on a paper.

Lets be more specific, suppose there are two buttons on a page, which supposed to do some specific task when user click on them. Those buttons don’t work and even cause a crash in application. Unfortunately, It went through to production.

Who is responsible? As I said, responsibility still lies with QA(Quality Assurance) team, but we cannot release development team from responsibility as they fail to test buttons for merchantability.

In my view, if we only held QA responsible for this situation, development team will be relaxed (… and lax) in their work as they know they do not own any responsibility in trials.

A thief is still a thief… A guard deserves his share of punishment and prosecution, but thieves still deserve to be punished, so they have some fear. Imagine a situation where thief will never be prosecuted because a security person has failed in securing valuables.

A clear line has to be created between errors and bugs, for any ‘error’ in merchantability, development team must be primary responsible party while bug falls under QA team

2 things you should never do as a programmer

You will find lots of guides and articles on the internet about what you should do to be a good programmer. A lot has been written on what we should do to excel in any field.

In my view, its not only what we do which make us good in our profession. It mostly depends on what we should not do which make us excel at our work.

In this article I am making short list of two things which any programmer should not do.

1. Stop Reading about new things

reading-book-club
If you think you know a lot about programming because you are an expert in one of the so called mother language, then you are making a big mistake. Even languages which were marked as stable and labelled as mother languages like c and c++ are changing a lot. At least new libraries and being added to them. So you should never stop reading about new things. Subscribe to few good magazines or journals, even if you do not have time to read all articles and magazines. You will be at least aware of what is going on around.

2. Coding before architecture

code
Never start coding before deciding on the architecture of your application. Its a huge mistake many new comers as well as so called experience people do. I can tell you from my experience in projects, its architecture which makes a project success or failure. Starting code before taking decisions and making plan for project execution is like going for ride when you really dont know where to go. Read about design patterns. They are documented solutions for common problems. Try to use them.

Categories: PHP Notes, Resources List Tags:

How to optimize all databases and tabels on mysql server?

Optimization of database tables in mysql is a process which has to be carried out regularly to make your database in good health.

According to mysql manual,

OPTIMIZE TABLE should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have VARCHAR, VARBINARY, BLOB, or TEXT columns). Deleted rows are maintained in a linked list and subsequent INSERT operations reuse old row positions. You can use OPTIMIZE TABLE to reclaim the unused space and to defragment the data file. After extensive changes to a table, this statement may also improve performance of statements that use the table, sometimes significantly.

In phpmyadmin you can see data similar to following screen if your database tables are not optimized. Entries in Overhead column indicates size of data space which can be reclaimed after optimization.

A major challenge comes in optimization when you have many databasesm thus many tables on my mysql server. It is hard to do optimization manually for each and every table. So we have created this script which can optimize each and every table of each database on your mysql server. You can run this script as your cron script also so you can do your optimization activities automatically. We have also executed repair statement which will repair any table error.


$con=mysql_connect(DATABASE_HOST,DATABASE_USER,DATABASE_PWD);
$db_list = mysql_list_dbs($con); $dbtoProcess=array();
while ($row = mysql_fetch_object($db_list))
{
$dbtoProcess[]=$row->Database;
}

foreach ($dbtoProcess as $dbname) {
$db=mysql_select_db($dbname);
$sql = "SHOW TABLES FROM `$dbname`";
$result = mysql_query($sql);

$AllTablesinDB=array();
while ($row = mysql_fetch_row($result)) {
$AllTablesinDB=array_merge($AllTablesinDB,$row);
}

foreach($AllTablesinDB as $value)
{
mysql_query("optimize table $value");
mysql_query("repair table $value");
//print $value ." has been optimized and repaired";

}
}

Execution of this script may take some time depending on the size of databases and tables.

How to optimize Magento speed?

I came across this good collection of some good suggestions by Guido Jansen about Magento speed optimization. Most of  suggestion are not exclusive Magento, but totality it is good list to optimize any Magento or PHP based application.  As of he has not finished his target of listing 101 suggestions, but a must read for anyone who wants to optimize Magento speed.

 

http://www.gxjansen.com/101-ways-to-speed-up-your-magento-e-commerce-website/

Deploy and Release your PHP Applications with Phing

Phing is a PHP project build tool based on Apache Ant. A build system helps you to perform a group of actions using a single command. If you’re wondering why PHP needs a build tool, consider a work flow where you write code and unit tests on your local machine, and if the tests pass you upload the code to staging/production server and make any changes to the production database. Without a build file, you’ll need to go through each step manually. If you are doing continuous integration, you’ll be doing the same steps over and over again. It’s too easy to accidentally omit something in the process and end up with serious problem in production.

 

Phing helps overcome such issues by automating tasks like running unit tests, applying database changes, deploying application code, etc.

 

In an article published on PHPMaster,Vito Tardia has given the details how you can use Phing to deploy our applications. Read complete article at PHPMaster

Using PHP and Java in the Same App with PHP/Java Bridge

In this article you will learn how to install and configure the PHP/Java Bridge and how to use Java classes in PHP scripts in a demo application. To use the PHP/Java bridge, you should have knowledge of Java SE and the PHP5 core, as well as how they interact.

PHP 4 supported an extension for combining PHP with Java, but to combine PHP with Java in PHP 5  you should install the PHP/Java Bridge, which the website describes as:”… an implementation of a streaming, XML-based network protocol, which can be used to connect a native script engine, for example PHP, Scheme or Python, with a Java virtual machine.”

Read complete article at PHP section of developer.com written by Octavia Andreea Anghel.

 

Artificial Intelligence in PHP : Creating Neural Networks

This article at developer.com, gives first hand information about creating neural networks in PHP language. Artificial neural networks are developed mostly in high-level programming languages such as C or C++, So reading about them in PHP is a refreshing experience.

 

What are Neural Networks?

The network works similarly to the human brain: it is comprised of neurons that communicate with each other and provide valuable outputs. Although just a model — and not even close to human thinking — artificial neural networks have been used in prediction, classification, and decision-support systems, as well as in optical character recognition and many other applications.

 

Read complete article at developer.com

10 Reasons to Use Zend Framework

Why you should use Zend Framework? This is not only an interview question, while taking structural decisions about a project, we should ask this question to ourself. This article gives good reasons why you should adopt Zend framework in your working culture and what kind of benefits you can get out from Zend Framework.

  1. Extend Classes like There’s no Tomorrow
  2. Object-oriented Goodness
  3. Use What you Need, Forget Everything Else
  4. It lets you do a Lot of Things!
  5. No Model Implementation – Choose your Own Adventure!
  6. Integrate with Whatever you Want!
  7. Guidelines and Standards
  8. All Code is Guilty Until Proven Innocent (aka Test-Driven Development)
  9. Community and Documentation
  10. Certification

 

Read in details at  10 Compelling Reasons to Use Zend Framework