Showing posts with label web programming. Show all posts
Showing posts with label web programming. Show all posts

Sunday, October 2, 2011

Why should we use frameworks for web development?

Web programming, now-a-days it is the biggest field of working for programmers. PHP, Ruby, python etc. are popular languages of web programming. There are some frameworks for developing web programs using PHP, Ruby and Python. Zend, Cake, Codeigniter etc. are popular frameworks of web programming. Ruby-on-rails is the framework for Ruby and Plone is the framework for Python web programming. For developing a web program, it is not a mandatory to use these frameworks, but it is better to use them.

What is client's expectation from programmers?
1. They want fresh working codes.
2. They need codes which will be understandable by other programmers.
3. They need module based codes for easy opportunity to increase or decrease functionality.
4. All of above, they need something smarter.

Are frameworks gives opportunity to fulfill these expectations?
1. Yes, frameworks has a about to standard format of coding (Model-View-Controller).
2. They have a predefined structure, so every programmers can understand where to go for editing or changing a function.
3. Frameworks use Object Oriented Style of programming which allows to divide all modules into pieces.
4. Frameworks help to write codes in smart way but it also waste time of development and execution.

Without framework, is it impossible to write smart codes?
1. No, coding is the art of coders. It should not be predefined. It is obviously possible to write codes better than frameworks.
2. Procedural codes reduces time of development and execution. It is flexible to develop something newer and different without frameworks.
3. Coder can make codes more understandable than frameworks by his own ability.

I prefer not to use frameworks. Because, I can't write codes in a predefined way. I usually like to work for new and different things with new algorithm and new possibilities. So, I don't use any framework. But a new framework or style of coding is established for my own works by my experience. I like to work with that and I will try my best to improve this style.

Monday, April 11, 2011

HTACCESS CODING

Few days ago I have found one of my drawbacks of my PHP coding. My web programs fails about 40% of SEO friendliness because of dynamic urls of products like "kolorob.info/index.php?id=45". I got realized that I have to use more SEO friendly url structure like "kolorob.info/page/2". I could not find any way to make this. I searched google and asked my friends, but couldn't get any information. A week ago, I was continuing that discussion with Muntasir Rashid at our intro6's temporary tent and Tarif Hossain joined there and gave me the legendary information about .htaccess. He said that I can solve this problem by this. And at last I have solved the problem.

Now I am going to discuss about this problem.

Problem: Redirect a unknown url address to a known url address.

Description of the Problem: When one write an address in the browser's address bar it shows some information from the file belongs in that address. like when I write in address bar "http://kolorob.info/kolorob/" or "http://kolorob.info/kolorob/index.php" it can show the specific page because this page is physically or dynamically exists. But when I write "http://kolorob.info/kolorob/post/26" browser starts to find a folder named "26" from another parent folder "post". But these folders are not exist physically or dynamically. If I want to show the 26th post to browser I need to get the information from the url to any of my existing page. I need the type of material ("post") and the number of that type of material to show the user.

Solution:
Need to add the following line to the .htaccess file of the folder where the project is situated.

RewriteEngine on

RewriteRule ^(./*)$ index.php [QSA,L]

The code shown above will help the url like ("http://kolorob.info/kolorob/post/26") to be redirected to "http://kolorob.info/kolorob/index.php" and it will bring the asked url by a global variable $_SERVER['REQUEST_URI']. Now one can easily get the whole url that was requested by user in "index.php". This url could be broken into pieces with the explode function of PHP using delimiter ("/"). Then the pieces are found "post", and "26". Index.php can easily recognize the type of material ("post") to be shown and the number of that type of material (26th post).