Current Interests

Right now I am working with two great PHP frameworks for two different application: Zend Framework and Orchid. Although I'm a huge fan of CodeIgniter, I'm finding ZF to be robust and really solid for becoming the #1 choice of enterprises very soon.

In addition to them, I am also having a good look on Dojo - as it became Zend Framework's official JavaScript toolkit. I have to agree that there a few gems in it which I like, but I'm yet to discover its full potential. In the meantime, jQuery is helping me a lot.

Latest reading

powered by LibraryThing
 
Aug
15

Beware of the so called “Senior PHP Developers”

12 Comments   Trackback 
1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 3.25 out of 5)
Loading ... Loading ...

A splendid illustration of similar trait in OK-Cancel strips

With the rise of PHP developer as career, many are trying to get their share in the pie. Lately I’ve met a number of developers who have worked for more than one/two years in developing PHP applications in various companies and they consider themselves as “senior” developers. They try to emphasize that they’ve done enough raw programming and they are now in a position where they’ll only design architecture of applications.

When you interview them and ask about complex topics, they’ll reply: “Oh my last company didn’t allow me work with that, but I’ll be able to grab that in a day“. You trust them and think that if they get the chance, they’ll sure be able to excel. After all, they’ve got that Company X’s experience and Guru Y’s reference.

At first everybody gets amazed with these developers employment history, the projects they’ve done, the technical jargons they can utter, the ideology/framework/pattern they talk about, etc etc. Everybody wants them in their team. The team who gets them finally are happier than ever, after all life will get easier to have such an expert in team.

Soon projects get rolling and everybody in his/her team is eagerly waiting to see the magics from these “senior” developers. To their disappointment, more ideas/criticism/review (e.g. “Pattern X is better than pattern Y. Why you’re choosing X?”, “Why are you doing Z in this way? Who taught you this?”, “Have you ever heard of DEF?”, “I have done research on DB normalization and you teach me schema?“) takes place but they don’t see actual code from these developers.

They come to office in an awkward timing, leaves early, works with personal things at office - but nobody can question their activity as people might not believe them. With much regret, the remaining team members continue to complete the work which the “senior” developer was suppose to do. Instead of a team synergy, an unintended pressure is created in the team.

Eventually the project misses deadline by miles, team members become unhappy as they had to do extra work each day to cover the team’s ass, company gets screwed as client is unhappy and decides not to do repeat business. Company digs down the cause of the failure, finds the responsible person, and fires them away.

Surprisingly, when a friend of the “senior” developer asks them in a social party: “What happened with the Company X you were working on?”, they’ll reply: “Oh that crap! You know, it’s a pain to work with junior developers. They don’t understand things. All they know is coding, no knowledge, no understanding of architecture. And the management is so poor, you won’t believe……“.

Don’t include someone like them in your team and think twice or thrice if you don’t have many options. Try to find out how good programmer they are in the interview. How senior they might be, ask them to write code in the interview. Try out proven questions that others have shared from their experience. Overall, make sure you’re taking the right person. The best hiring option is to hire “no one”.

Have you been in such situation? Share your experience here!

Share and Enjoy:
  • Digg
  • del.icio.us
  • StumbleUpon
  • description
  • Furl
  • Ma.gnolia
  • Technorati
  • Reddit
  • Simpy
Jul
12

Extended Model for CodeIgniter

18 Comments   Trackback 
1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.67 out of 5)
Loading ... Loading ...

I developed this extension of CodeIgniter’s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev’s life easy. This extension has been used by several of my devs at RBS and has been proved to increase productivity and reduce the number of painful small queries to write. Their enthusiasm has driven me to post this for the CI fans out there.

Without much babble, let’s get into point. I’ve explained the process of installing it and then showed some example uses. For starter, click here to download it. Now follow these steps to get started:

1. Replace the system/libraries/Model.php file with the attached Model.php (CodeIgniter version 1.6.3)

2. For each of your tables, you will need to create a model file in system/application/models.

3. Lets say we have a "products" table whose schema is as follows:

   1: CREATE TABLE `products` (
   2:       `id` int(11) NOT NULL auto_increment,
   3:       `title` varchar(50) NOT NULL,
   4:       `description` text NOT NULL,
   5:       `color` varchar(20) NOT NULL,
   6:       `price` float NOT NULL,
   7:       `category_id` int(11) NOT NULL,
   8:       `featured` char(1) NOT NULL,
   9:       `enabled` char(1) NOT NULL,
  10:       `visits` int(1) NOT NULL,
  11:       `created` int(11) NOT NULL,
  12:       `modified` int(11) NOT NULL,
  13:       PRIMARY KEY  (`id`)
  14:     ) ENGINE=MyISAM;

4. Now we need to create system/application/models/product.php:

   1: <?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
   2:  
   3:     class Product extends Model {
   4:  
   5:         function Product()
   6:         {
   7:             // Call the Model constructor
   8:             parent::Model();
   9:             
  10:             // Load the associated table
  11:             $this->loadTable('products');
  12:         }
  13:  
  14:     }

5. From any controller, you can load the Model as instructed in the CI manual. Here are some sample usage of the model functions:

   1: function products()
   2:     {
   3:         // Load the model in the default way
   4:         $this->load->model('Product');
   5:         
   6:         // Total # of products
   7:         echo $this->Product->findCount();
   8:         
   9:         // Total # of featured products
  10:         echo $this->Product->findCount("featured = 'Y'"); 
  11:         
  12:         // Retrieve ALL the products
  13:         $allProducts = $this->Product->findAll(); 
  14:         
  15:         // Retrive id, title and price of top 10 products (based on popularity) that are enabled
  16:         $topProducts = $this->Product->findAll("enabled = 'Y'", 'id, title, price', 'visits DESC', '0', '10');
  17:         
  18:         // Retrive id, title and price of the 1st most popular product that is enabled
  19:         $topProducts = $this->Product->find("enabled = 'Y'", 'id, title, price', 'visits DESC', '0', '10'); 
  20:         
  21:         // Retrieve the product with id = 1
  22:         $oneProduct = $this->Product->read(1); 
  23:         
  24:         // Retrive the price of the product whose id = 1
  25:         $productPrice = $this->Product->field('price', 'id = 1'); 
  26:         
  27:         // Single array with the titles of all the enabled products
  28:         $productArr = $this->Product->generateSingleArray("enabled = 'Y'", 'title'); 
  29:         
  30:         // Insert a new product in the db
  31:         $newProductId = $this->Product->insert(array('title' => 'New Product', 'price' => '10.99')); 
  32:         
  33:         // Update the price of the newly added product
  34:         $updProduct = $this->Product->save(array('price' => '20.00'), $newProductId); 
  35:         
  36:         // Delete the product
  37:         $this->Product->remove($new_product_id);
  38:     }

7. There are a number of other helpful functions in this file. If you have a careful look, you’ll discover that some of them are really handy.

UPDATE: I forgot to give due credit to the wonderful developers of CakePHP - I’ve taken inspiration from their Model implementation while building this one for CodeIgniter.

Download

Model.php
Extended Model for CodeIgniter
Downloaded: 454 times
Share and Enjoy:
  • Digg
  • del.icio.us
  • StumbleUpon
  • description
  • Furl
  • Ma.gnolia
  • Technorati
  • Reddit
  • Simpy
Apr
27

Power situation in Bangladesh

5 Comments   Trackback 
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.5 out of 5)
Loading ... Loading ...

Nothing to say much, check the image below:

Utilizing boring time during load shedding hours

Power line in BD

Share and Enjoy:
  • Digg
  • del.icio.us
  • StumbleUpon
  • description
  • Furl
  • Ma.gnolia
  • Technorati
  • Reddit
  • Simpy
Mar
06

jQuery Essentials - Round 3

4 Comments   Trackback 
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.5 out of 5)
Loading ... Loading ...

I still receive a good number of hits to my first (10 jQuery Essentials) and second (jQuery Essentials - Round 2) collection of jQuery plugins. So, I have been thinking about making the next post in the series for quite some time. Time has always been the killer of ideas, along with the fact that not too many plugins found way to my list of favorites.

Now that I have some fresh essentials, this post was inevitable.

Should there be a 4th installment in the "jQuery Essentials" series?

View Results

Loading ... Loading ...

18. jQuery UI

ui

This is the official big boss with a number of core interactions (drag, dropping, sorting, selecting, resizing) and few great widgets (accordions, date pickers, dialogs, sliders, tabs) built on top of those. Although its a great collection, I somehow haven’t been able to use it in any real projects yet. It seems small plugins always get a favor than big collections :)

19. Facebox

facebox

This is a cute, little plugin that shows Facebook style dialog boxes using jQuery. It supports nearly all the possible contents you might want to show in a dialog box: image, div, remote pages. It has both automatic behavior and manual invoking. Simple and fun to me.

20. Pagination

pagination

Although we generate pagination mostly from back-end and display them in our pages, sometimes AJAX paginations are needed. This plugin outputs a superb pagination display to be used in such cases. If you know the usability issues regarding pagination and can distinguish between bad and good paginations, then you’ll find that this one has all the good in it. Check out their demo to know what I mean.

21. Ingrid, the jQuery Datagrid

ingrid

“Datagrids don’t have to be difficult to use anymore - say hi to Ingrid. Ingrid is an unobtrusive jQuery component that adds Data Grid behaviors (column resizing, paging, sorting, row and column styling, and more) to your tables.” - I can’t agree more on their say. It’s truly an excellent implementation of grid. And it makes conversion of normal tables to grids very easy.

22. jQuery Youtube

youtube

If you have any need to retrieve and show Youtube videos in your site, this plugin will be a life-saver. Specify a few properties and this plugin will fetch the videos utilizing the new GData API from Google. And the author makes an unique display of the thumbnails, but combining it with BlockUI - so when you click on a retrieved video, you have it in a modal for preview.

23. Coda Slider

coda

I am a huge fan of Coda Slider. It’s a slider plugin for jQuery and is much better than many other sliders out there. It has a pile of properties and display options to play with. I have been able to customize and use it in every possible need, so there is a chance it helps you out also. Supports custom height, width, tabs on top/bottom, without tabs, custom arrows, … and a lot more.

24. jQuery Lightbox

lightbox

The prototyped lightbox was very popular and I used it in a couple occasions. But since I’ve switched to jQuery, I hardly found any replacement for that. Thickbox and a couple other tried (and they were very good implementation), but couldn’t make me feel the same way. Suddenly I found this one and I knew its the one. A one-liner implementation and all the features from my previous fav is back. It has a number of customization also, if you need to modify the way it behaves.

25. Auto Completer

auto

Auto-completes have been there and I mentioned some great ones in my previous posts, but this one has also captured my attention and I like it very much. The author has gone a few extra miles and has explained the inner workings of the plugin. But if you just want to try it out, you can check the demo.

Categorized jQuery Essentials

A lot of people have asked me to categorize the posts so that it’s easy to pick for them. I waited for this post before doing that so I will do a categorized post of the cumulative list of plugins from the 3 posts in the series.

Happy jQuery !

Share and Enjoy:
  • Digg
  • del.icio.us
  • StumbleUpon
  • description
  • Furl
  • Ma.gnolia
  • Technorati
  • Reddit
  • Simpy
Mar
06

Cross-Domain AJAX calls using PHP

11 Comments   Trackback 
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

AJAX has become the core component of many web applications around us. And its fairly easy to handle AJAX now a days, with the help of various javascript libraries (ex: jQuery, Prototype, Mootools, YUI, etc). But there is one security issue that web browsers impose in doing AJAX calls - they don’t let you do AJAX calls in web servers different than yours. That means, if your script is in www.mydomain.com and you’re trying to do AJAX call to www.anotherdomain.com/get.php, then the browser will through error like: “Error: uncaught exception: Permission denied to call method XMLHttpRequest.open”.

Now, there are a number of solutions to this problem. Instead of explaining them all to you, lemme provide you the simplest one: using a PHP transport file. If you already know the thing and just need the script, download from here.

Others, let’s see an example implementation first.

Example use

   1: xmlHttp.onreadystatechange=function()
   2: {
   3:     if(xmlHttp.readyState==4)
   4:     {
   5:         alert(xmlHttp.responseText);
   6:     }
   7: }
   8:  
   9: xmlHttp.open("GET", 'http://myserver.com/transport.php?action=' + 
  10:                     urlencode('different-server.com/return_call.php') +
  11:                     '&method=get&data1=101&data2=pass', true );
  12:  
  13: xmlHttp.send(null);

Now, lets see how it works:

  1. The script makes an AJAX call to the myserver.com/transport.php with a few parameters:
    • action = the target URL you need to fetch, from a different domain
    • method = the HTTP method (post/get)
    • data1, data2 = sample parameters for using as either query-string or POST fields
  2. When the request is received by transport.php, it uses cURL to make a call to the page mentioned in action.
  3. Based on the method, it either makes a GET request or a POST request. In both cases, it sends the extra parameters that are sent.
  4. After the response is received, transport.php echoes it. So, you have what you need!

Download

transport.php
Cross-Domain AJAX call transporter.
Downloaded: 1088 times

Comments and suggestions are most welcomed :)

Share and Enjoy:
  • Digg
  • del.icio.us
  • StumbleUpon
  • description
  • Furl
  • Ma.gnolia
  • Technorati
  • Reddit
  • Simpy