Archive for the 'PHP Development' Category

PHP Development

Lucene – Zend

I’m not sure if this is the norm, I stumbled across the answer while banging my head against a wall trying to integrate a Lucene search through the ZF framework (zend). So, as an example I wanted to run the following code block. It simply adds a document and some fields to the the document and some unstored content.. pretty basic.

Notice the last line though…. “index->commit();”

You will have to look hard to find the use or reason for using this, but if you do not and your script ends pre-maturely, there is a chance you will not get the results you expect. The examples I have seen do not mention that if you do not do this and you run and exit or throw an exception prior to the front controller dispatching, it goes to shit.

Just as an fyi many people after the commit will toss in the index->optimize,.. it’s a good practice, I just did not do it for this example.

Example code:

$index = Zend_Search_Lucene::create(SEARCH_DIR.'articles/'.$data['article_index']);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('title', $data['article_title']));
$doc->addField(Zend_Search_Lucene_Field::Text('description', $data['article_short']));
$doc->addField(Zend_Search_Lucene_Field::Text('link', $data['article_url']));
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $data['index_content']));
$index->addDocument($doc);
$index->commit();

PHP Development

Stupid things my foreign development counterparts have told me….

I currently work with a team overseas in a location that will remain nameless (India). Now I am not overly thrilled with having to work with this team, aside from the time difference, language barrier combined with my inability to spell, as you can probably see in my blog. I have tried to keep an open mind with them, to the best of my abilities, but my experiences with them are far from…. good.. hell they are just down right annoying at times.

I have a list of things I could post that would probably make most open source developers curl up under their desk and cry a little, but I’ll keep it short for now. I will post the following in a questions / answer format, my question… their response. (I refuse to call them answers.)

Q: This query we have on page “a” take 12 seconds to return 100 records…. I noticed it makes 3 joins to tables that have no relevant data in them to the response needed, why do we join those tables?

Response: We join those tables in-case our application corrupts data in the database. If we join those tables and the data is corrupted, then the query will not fail. It should still work.

Q:I have taken our repository and made a branch specifically for your team. This branch should be used for the new project you are working on as it will take a large amount of time to complete and modify large amounts of files. I have attached the check-out procedure for this branch.

Response: (paraphrased) Making another branch for a new project is very time consuming for us to maintain. Branching is really not a good practice in development and we should try and find another solution.

Honestly I think developers should all have to be licensed, if you fail your test and do not receive your license, you are banned from development and branded with “RETARD” on your forehead.

PHP Development, Vexed Daily

Best video I have seen in a while….

This is probably one of the best videos I have watched in a long while, it really hit home. Well Done

PHP Development

Coding Standards – OMG why…

So I have found my newest, “omg why would you do this” piece of code. The code in question is:
"value" == $variable;
//instead of the traditional
$variable == "value";

The reason given for writing it this way…. because if you accidentally forget to type the second =’s sign it will not cause the variable to set, it will just not set the variable.

WTF

So code backwards to allow you to screw up code? Honestly, check your code you lazy people. When I see this in my current employers code, I change it. When the other developers question me on why I change it, of course I go off on a rant about stupidity, and I was actually told by one, that they would leave it and just conform.

Developers of the world…. please do not conform, and if you decide to conform, do not conform to stupidity. Code like this makes me cry at night when I am trying to sleep.

« Prev - Next »