PHP Classes

How to Use Your Programming Mistakes to Learn to be a Better Developer and the New PHP ElePHPant Models that Are Available Now

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Use Your Progr...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Viewers: 542

Last month viewers: 4

Categories: PHP Tutorials, PHP community, Software Business

Recently we discovered that we made a mistake in the implementation of our newsletter mailing system.

We believe that we have fixed this mistake, but more important than that we also learned how to improve our development and deployment practices to avoid the bad consequences of our mistakes in the future.

Read this article to learn more about how you can also improve your software development practices to implement software that is more robust and your work is gets better acceptance.

As a side topic, you can also see some pictures and learn about the new ElePHPant Models that we made available now in the PHP Classes so you may get as nice addition to your collection.




Loaded Article

In this article you will learn about:

1. Why Humans Need to Prepare to Deal with their Own Mistakes

2. What You Can Do to Deal with Your Mistakes in the Best Way

2.1 Be Positive and Always Look on The Bright Side of Life

2.2 Analyze the Bad Consequences When a Mistake Happens

2.3 Prevent that the Same Mistake Happens Again

2.4 Do not Blame Other People for Your Mistakes and Apologize to Others that May be Affected

2.5 Promise it Will Not Happen Again

2.6 Be Prepared to Avoid Future Mistakes Anticipating When they May Happen

2.7 Explain the Measures that You Implemented to Prevent the Same Mistakes to Happen in the Future

2.8 Be Tolerant and Accept that Others Also Make Mistakes

3. Example of How to Deal with Our Own Mistakes in Practice

4. Newsletter Mailing Solution to be Made Available to You

5. New ElePHPant Models that You Can Add to Your Collection

1. Why Humans Need to Prepare to Deal with their Own Mistakes

Everybody makes mistakes. That is part of our human nature. However, for each mistake you make there will be a penalty for you to pay.

Everytime that you deal with a new situation there is a good chance of making mistakes. So you need to be prepared to pay a penalty.

If the mistake was against your interests, that is fine although you still have to pay a penalty. If the mistake was against others, you need to be prepared to deal with the situation in the best way to minimize the penalties that you may have to pay.

2. What You Can Do to Deal with Your Mistakes in the Best Way

2.1 Be Positive and Always Look on The Bright Side of Life

When you make a mistake you need to realize that the mistake is done and you cannot go back to the past in the time machine and try again avoiding the mistake. Time machines only exist in the imagination.

You can remember what happened, but there is nothing that you can do to change the past. This is the down side of making mistakes.

On the upside, you can still do something in the future so you can become a better person.

This is a lesson that you may learn if you watched an old movie from the humor group called Monty Python. They end the movie with the song called "Always Look on The Bright Side of Life". If you want to get started dealing with the bad consequences of mistakes in a good way. Watch this video to read the lyrics of the music. I am sure you will start taking your mistakes more lightly.

2.2 Analyze the Bad Consequences When a Mistake Happens

The first thing you need to do is if you caused harm to anybody. If your mistake caused harm only to yourself that is not so bad, as the penalty is only for yourself.

Did you write programming code but did not test it before you shipped to the production? Soon or later you will realize that the code did not work and you need to spend more time fixing and testing it.

If your mistake caused harm to other people, that is worse because you need to pay some kind of penalty to those people that were affected.

Did you ship code to a customer that already paid you and that code has bugs? You need to spend more time fixing the code and the customer should not pay you more for the time you spend fixing the bugs. 

2.3 Prevent that the Same Mistake Happens Again

Human beings are intelligent. This means they can learn and evolve.

In practice you should pay more attention next time you go through a similar situation to avoid the same mistakes that you have done in the past.

Did you make the mistake of shipping code that was not very well tested? Next time test you code more extensively before you ship.

2.4 Do not Blame Other People for Your Mistakes and Apologize to Others that May be Affected

Your mistakes are yours. You need to act as grown up person with maturity. Humans make mistakes regularly. Each person should assume his own mistakes and do not blame others for those mistakes.

If you made a mistake, you should apologize right away to avoid that the person retaliates, even when you made a mistake as a consequence of other people mistakes. Other people mistakes do not justify yours.

Did you ship code with bugs after you got some pressure from a customer that kept asking when the code was done? That is still your fault because you are responsible for shipping your code. The bugs in your code are always your responsibility.

2.5 Promise it Will Not Happen Again

After you apologize for a mistake, you need to learn and avoid that mistake again. That is not enough.

If your mistake caused harm to another person, that person may have lost confidence on you and may have stopped believing that you will not repeat the same mistake. So it is up to you to at least try to promise that you will do your best to not repeat the mistake again.

Did you ship code with bugs to your customer? Promise that you will test better your code next time.

2.6 Be Prepared to Avoid Future Mistakes Anticipating When they May Happen

Usually mistakes happen in the first times that you try to do new things. So one way to be better prepared to avoid mistakes is to be more cautions when you start a new activity that had you have no previous experience.

For instance if you are starting a new software project for a new customer, try to listen very carefully about the requirements and implement measures to verify whether those requirements are fully satisfied. It may seem hard and take more time do this for the first time but once you succeed completing the project, it will be easier on a second time you implement that project. 

When you make a mistake, something must be changed in the way you act to avoid that the same mistake will not happen again.

2.7 Explain the Measures that You Implemented to Prevent the Same Mistakes to Happen in the Future

If you made a mistake that cause harm to other people, it is good that you also explain to them what you changed that will help you avoiding that mistake again.

For instance if you shipped code with bugs to a customer, you can implement a new way to test the code before shipping next time. Then you need to explain to the customer that the code will have better testing in the future.

2.8 Be Tolerant and Accept that Others Also Make Mistakes

Remember when you were younger and did not have much experience? Did you make lots of mistakes by then?

Well just like yourself, others also make mistakes when they do not have much experience on doing something new to them. You probably also wanted that others not be so hard on you when you made a mistake. Well, if you are tolerant with others, they will also be tolerant with you.

For instance, if you take more time to ship your code to a customer than you promised, you need to be tolerant if the customer takes more time to pay you.

3. Example of How to Deal with Our Own Mistakes in Practice

Well, most of what you have read above is mainly theory. To illustrate how it should work in practice, here follows a real mistake that we have made at the PHP Classes site so you can understand how we are dealing with it.

3.1 The Mailing System Mistake

Well basically what happened is that around October 19 2020 we have implemented an optimization of our newsletter mailing system that we have developed over the years to be able to deliver millions of newsletter messages to the PHP Classes registered users.

We do not use external mailing systems because these are too expensive for the volume of newsletter messages to over 200,000 active registered users.

Our system is so robust that we are able to run it on the same dedicated server machine that we use to run the site Web server and database server.

Not only we can deliver many newsletters at the same time, but we are also able to do other things, like handling bounced messages, and track the users that are able to open and read the newsletter messages.

To make this system more efficient, we make the process that records the users that open our messages to be performed before any new newsletters are delivered.

Our recent mistake is that after we processed the mailing open events, the process exited before it started processing pending newsletters.

3.2 The Bad Consequences of Our Mistake

Since the mailing system was on hold for about 10 days, there were over 220 pending newsletter mailing tasks that were processed one after the other.

If you have received many newsletter messages at once, we understand that may have irritated you. If this affected you, we totally understand you may be upset.

3.3 Prevent that the Same Mistake Happens Again

If we have detected this bug earlier, the mailing system would have not hold so many newsletters pending to be delivered.

Although we cannot anticipate all mistakes that we may do in the future, we may try to minimize the harm that is caused when mistakes like this if they happen again.

So what we did is to implement a new test script that checks if the number of newsletters that are pending in the queue is above an acceptable threshold.

The script could have been written in any language. Since this is a simple task, we have written a shell script that can run from a cron job regularly to perform the alarm condition tests. When that condition happens, the test script will output a message and the cron program will send us an email so we can act to fix the cause of the problem as soon as possible.

Here follows a sample of this script that you can use to adapt to your case. Basically it just performs a MySQL database query to count the number of entries that are in a queue table.

#!/bin/bash

# Set the limit variable to the number of entries that are acceptable to
# remain on the queue before it triggers the alarm condition
limit=10

# Set the file from which database access credentials will be read
database_configuration_file=database_configuration_file.txt

# Set the name of the database table to be queried
table=your_table_to_test

#Set the name of database table column that you will checked
column=table_column_to_test

# Check the command line parameters
if [ "$1" == "" ] || [ "$2" == "" ] ; then
	echo "Usage: $0 database mailing_queue"
	exit
fi

database=$1

column_parameter=$2

# Read the database access authentication configuration name from a file
# and check if it is valid
read <$database_configuration_file login
rc=$?
if [ "X$rc" != "X0" ] ; then
	echo $rc Could not read the database configuration file!
	exit $rc
fi

# Check if the database can be accessed
mysql 2>/dev/null --login-path=$login $database -e quit
rc=$?
if [ "X$rc" != "X0" ] ; then
	echo $rc Could not connect to database server!
	exit $rc
fi

# Query the database to retrieve the value to be checked
query="SELECT count(*) FROM $table WHERE $column='$column_parameter'"
value=`mysql 2>/dev/null --login-path=$login $database --skip-column-names -e "$query"`

# Perform the test condition and output a message if the check fails
if [ "$value" -gt "$limit" ]
then
	echo "There are $value $table entries in the queue of type $column_parameter ."
	exit
fi

3.4 Do not Blame Other People for Your Mistakes and Apologize to Others that May be Affected

Obviously this issue was caused by bug in the code that processes the PHP Classes newsletter mailings. So it is totally our fault. Therefore we wish to apologise for this mistake if you may have been flooded with too many newsletters that you may have received all at once.

3.5 Promise it Will Not Happen Again

Given that now we have a test script that is checking the newsletter mailing queue once every hour, we will be able to detect much faster if any mistake that we make and may cause that the newsletter mailing system holds to many messages in the queue.

Therefore we can promise that we can handle bugs like this in the mailing system to a point that you may not notice any mailing processing delays. 

3.6 Be Prepared to Avoid Future Mistakes Anticipating When they May Happen

Now that incident happened we will try to pay more attention every time we implement a new improvement on the PHP Classes site that requires new code or maintenance of the current site code base.

3.7 Explain the Measures that You Implemented to Prevent the Same Mistakes to Happen in the Future

In general we perform extensive testing of all improvements that require new developments. Unfortunately it is not possible to anticipate all sorts of mistakes that we may make, as we continue to be humans and may make unintended mistakes.

Anyway, we plan to continue to develop more scripts that perform self-testing procedures so we can detect issues that depend on our own code.

Part of our testing methods use automated tests that are already developed. Other tests need to be developed along with the code that implements new features. This will be done with extra care for critical systems that may affect people, like the newsletter mailing system described above.

In particular we will take extra care of the e-commerce system that deals with people money, security protection system that preserve the privacy of records of personal data.

3.8 Be Tolerant and Accept that Others Also Make Mistakes

One of the main reasons why the PHP Classes site has grown a community with over 1.5 million registered users in 21 years of age is that it always allowed developers to contribute code with quality levels that may vary a lot. This made it possible for over 4.300 authors to share their code to get great exposure.

Notice that there are packages that may have bugs and some may need extra care so you can check if they use secure programming practices before you can use them in your packages.

Therefore we recommend that you always review the code that important packages provide before you use them in your projects.

If you find any bugs in the packages that you try to use, please report those bugs to the authors of those packages, so you may become aware and fix the bugs as soon as possible.

You can report any bugs by going to the respective package page and click on the link that says: Support forum. Then you just need to post a message in that forum to tell the author about the bug you may have found.

4. Newsletter Mailing Solution to be Made Available to You

Now that you may have learned about the newsletter mailing system that we have developed and evolved over the years to make it really mature, so it can send millions of newsletters email messages every month, we are considering to make sell it to others that may want to use it in their own servers.

If you are interested, please post a comment below to this post, or send a private message to us by using the Contact link at the bottom of all pages of this site.

5. New ElePHPant Models that You Can Add to Your Collection

Well we hope you have liked what you can learn by reading this article.

To end we would like to let you know that we in the last 21 years we have spent many thousands of hours to provide a community site like this in a way that is totally free for you.

However, to make the site financially viable we depend mostly on the sales of premium subscriptions and more recently on the sales of elePHPant plush toys that many PHP developers want.

Fortunately we have been able to keep the site viable so far but we always could use more help from other developers to work on new features and bug fixes to make it better for everybody.

We are not particularly rich. That is not the goal of the site. The goal is to make the site sustainable while helping developers like yourself to benefit from the work of thousands of PHP developers, so you can do your work better and also make a fair amount of money.

One of the features that we want to implement in the PHP Classes site is a marketplace that will allow developers like yourself to sell your own software products to many other developers.

This marketplace is finally going to happen in the next months after 2 years of researching, planning and developing.

So make it happen faster you can do your part helping to fund the development of the site by buying any products that we sell.

In particular we have are now making available to buy new kinds of PHP elePHPants that were produced with the permission of Vincent Pointier.

Below you can find some pictures of the new models, namely the pink model. That model is the same as the blue one, except that it is pink.

Pink ElePHPant

You can also buy a pair of elePHPants in blue and pink, eventually to offer to your wife, husband, girfriend, boyfriend, daughters, sons, other familiy members and friends to show your love with them.

Pink and blue elePHPant

Soon we will also announce a new option to buy your own ElePHPants that can be personalized with your own logo. Below you may find a variant with the logo of one of our customers. Another shows the new logo for the upcoming PHP 8.

If you would like to get a personalized elePHPant, please contact us directly, so we can tell you more how we can personalize an elePHPant with your logo on one side of the elePHPant belly and still have the original PHP logo on the other side.

Personalized PHP Elephant with a PHP 8 logo

6. Conclusion

Well this is it. We hoped you have liked this article and it helped you to be a better programmer and a better person than you already are.

Do not forget to keep supporting the site, if possible buying your own elePHPants.

If you would like to send your site improvement suggestions, please post a comment below this article or send us an email message using the Contact link below.




You need to be a registered user or login to post a comment

1,611,040 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:



Comments:

No comments were submitted yet.



  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Use Your Progr...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)