This could probably sound very strange to many, but I have noticed recently with my experience in developing poweredindia that there are some errors and bugs we might not notice/discover while coding in earlier ages of our applications.
I have struggled a lot to get a clear way of bringing them out of the shadows. Every time I tried discussing it with people they usually get confused about what exactly is the matter.
Coding is complex and requires a lot of attention and focus. When you code you define complex systems from their tiny pieces. Then those pieces, with their singularities, have to be assembled to define the main function(s) of the entire system. The more the pieces are, the higher the risks of mistakes and mis-configurations:
- You may miss a piece
- A piece can be of a bad quality
- A piece may have short life-time
- A piece can be mis-placed during maintenance
- A piece could be updated without considering to balance its co-relation with the rest
- etc
In case a piece is faulty, the effect is more or less felt in the entire system. Indeed, programming paradigms, like Object Oriented Programming(OOP), are there to help leverage such situations. In most cases they may be considered and handled as exceptions
This is how developing a website too is and has always been. It's made up of many things:
- The design
- Functional structure
- User experience
- SEO
- Administration
- Management
- Maintenance
- Etc.
Those problem can attack/appear in any of these aspects of your website/application regardless of the type of the website and its age. They have no real ending. They can't really be PERMANENTLY fixed because they depend a lot on TIME. The more time goes, the more obvious and clearer they become. There are like warms and can metamorphose at any time. When you roam on the Internet you can notice them here and there from website to website. Sometimes, most users or even website owner don't even notice them as such. Note that these problems are mostly human failure, due to mis-understanding or other factor related to human mind.
In this article I will try to illustrate some of those problems and share with you my idea of how they could possibly be handled.
Loops And Data Size
Loops in most programming languages are used to make decisions. While they are used for computational decisions, the programmer's decision matters a lot in how those loops will behave in the software.
Application Logic
If the programmer doesn't have a deep understanding of the situation and of the context to better format the loops, they may become a source of bugs and behavioral application.
Let me illustrate this with an example:
$posts = [1,2,3,4,5,6,7,8,9];
foreach($posts as $post) {
// do something
}
At first look this seems normal and harmless, but in time the number of post will increase and there you will notice the problem. The size of the array and the logic in the loop always impact the time of execution. Let's look at some facts:
Elapsed time: {$elapsed}";
With this, the execution time on my PC varies from
0.000001?s
and 0.000003?s
When I add a simple logic in the loop like this:
Elapsed time: {$elapsed}";
The execution time varies from
0.000002?s
and 0.000006?s
Now when I increase the array size to 10000 elements without the loop body the execution goes up to
0.001152?s
. When I add the loop body it goes up to 0.011447?s
.
This is an obvious proof that loops plus the size of your data can create a considerable execution time in your application. I do understand that most of us are aware of that. My warning here is for you to know that while you are creating your applications, you usually work with few data samples for tests. You can't rely on such data to prove at 100% how your application is going to react in time.
Design
Meanwhile, this is what concerns the application logic. In case of a website where the content display matters a lot, it's important you think of your design based on these facts.
This may happen in your forum, pagination system, commenting system, post listing etc.
Database
Databases are used in most websites which need to persist and store data for further use. As mentioned in above, the bigger the data used to feed your application, the slower it runs. It's therefore important you take care of how to fetch data from your database. Always think of having a maximum or a limit to your SQL queries in charge of fetching data.
SELECT * FROM table LIMIT 100;
SELECT * FROM table LIMIT 0, 100
I recently noticed this problem with some tutorials on phpocean.com. When I was coding the website I did not expect to have so many people visiting and commenting. So I just did it they working way. Then there is this tutorial I wrote since last year which has about 200 comments. At first I use to display all the comments at the bottom of the tutorials. But with 100+ comments, in time this tutorial started to load very slowly(very). Beside that, it was breaking the site design by tearing a lot of grids. The browser vertical scrollbar was becoming so tiny that you couldn't handle to scroll fast down. So, I re-factored the display by using some infinite loading principle. Then the comments start loading if only you scroll to the end of the tutorial. That one too, just one comment at a time.
Bottom Line
This may be a very huge topic, not only the code design or user interfaces but also can become a huge concern for your application security. Here I have given you an example of these mysterious problems that occur and become more obvious in time. I am sure from now you should be able to consider them in your next application. You will definitely discover more in various forms, always address them as possible as you can before they kill your application/website.
One advise, always fix bugs at the moment you meet them. Ignoring bugs can really increase the size of those problems.
2 Comments
Great work done by author of this blog. Its an Amazing blogger. We are one of the best Mobile App Development Company in Gurgaon.
ReplyDeleteRanking increases SEO Services Delhi NCR keep share more information
ReplyDelete