Talks around PHP, Computer Science and Stuffs
In: Uncategorized
13 Mar 2010Yesterday, the Confoo conference held in Montreal ended. I had the chance to assist to the three days of the conference.
The presentation slides are available here : http://www.confoo.ca/en/download or you can view some of them on Anis blog.
Thanks to a very good organization, this conference was a real blast. All went very smoothly.
I can’t wait for Confoo 2011 !
In: Singleton
13 Mar 2010So, again I will talk about Singleton and why you should be carefull with them. Everytime I think or discuss singleton the following things come in to my mind :
- Global State;
- Hard to test (refer to unit test post);
- Singletonite (I see Singletons everywhere);
- Violating the Single Responsibility Rule.
I could spent a few pages arguing and / or explaining those issues. Instead of that, I would recommend you to watch Miško Hevery’s presentations.
“Ok great, I am convinced. Singleton are bad. What are the alternatives ?”
Let’s suppose we have a class named article, that has a save() method allowing to persist this instance of an article (in a database or any kind of persistency layer).
/**
* Singletons are my best friends
*/
class article
{
public $title;
public $text;
public function save()
{
$storage = storage::getInstance();
if(false === $storage->save())
{
logger::getInstance()->log("Sorry !");
}
}
}
$myArticle = new article();
$myArticle->title = 'I love sushi';
$myArticle->text = 'I really do...';
$myArticle->save();
What are the problems with the previous code ?
Well, first you can’t mock the storage object and therefore this class can be hard to unit test. Secondly, the save method has a dependency with two objects, those dependencies are hidden within the save method and as a consumer of this API, you would expect to be able to know what the collaborator and / or the dependencies of a class are without having to look at the implementation of some methods.
So, let’s get rid of all singletons !
/** * No Singleton, use collaborators instead */ class article { protected $storage; protected $logger; public function __construct($storage, $logger) { $this->storage = $storage; $this->logger = $logger; } public function save() { if(false === $this->storage->save()) { $this->logger->log("Sorry !"); } } } // Having to instantiate "manually" the storage and logger // is a actually a bit a pain $storage = new storage($param1, $param2, ...); $logger = new logger($paramA, $paramB, ...); $myArticle = new article($storage, $logger); $myArticle->title = 'I love sushi'; $myArticle->text = 'I really do...'; $myArticle->save();
We just need to pass the storage and logger objects into the constructor of the article object and now the article class is easier to test (easier to mock objects).
In: Fun and stuffs| Others
3 Oct 2009This is definitely not PHP or IT related but is worth talking about
The com department of the UQAM (Universite du Quebec a Montreal - Canada) has done an awesome and incredibly popular lipdub video.
This LipDub has been produced during the integration week of UQAM with 172 communication students. It was made on September 10th 2009, the footage lasted approximately 2h15min.
Available on youtube / google video, it is getting more popular every hour / minutes (more than 750k views already) and it is creating kind of a buzz on the web.
They even got an interview on CNN.
Congratulation to them all. As an ex-student of UQAM, I specially enjoyed watching it.
In: Uncategorized
11 Sep 2009Once again, Thanks Google for their tech talks.
Here is a video from Steve Souders named “Life’s Too Short - Write Fast Code”. This video talks about how to write efficient code and discuss speed optimizations techniques in Web programing.
Steve works at Google on web performance and open source initiatives. His book, High Performance Web Sites, explains his best practices for performance; it reached the top of the Amazon computer and Internet bestseller list. His follow-up book, Even Faster Web Sites, provides performance tips for today’s Web 2.0 applications. Steve is the creator of YSlow, the performance analysis extension to Firebug, with over one million downloads.
(Source : http://stevesouders.com/bio.php)
You can also find his latest book named “Even faster websites” at books.google.com.
Here is a very interesting video from Linus Torvalds on Git. He emphasizes on the importance and added value for companies to use decentralized source control.
You better listen to this video or you just may end up stupid and ugly
In: Scalability
10 Aug 2009If you ever worked in a software company, you most likely heard once someone saying “Hey, we can’t do this, because this doesn’t scale!”
I believe “Scalability” must be on the top 10 list of the “buzz words” most used in the software industry.
It is usually considerated as a killing argument in a conversation. “If something doesn’t scale, then we don’t want it.”
One of the things that fascinates me about “buzz word” is that most of the time it has so many different definitions. Everyone has a tendency to give it a personal definition. Often, people will be too shy to ask for a clear definition. Therefore, it makes it even harder to be able to really understand what underlies behind it. So, What does Scalability mean ?
In telecommunications and software engineering, scalability is a desirable property of a system, a network, or a process, which indicates its ability to either handle growing amounts of work in a graceful manner or to be readily enlarged. (Source: Wikipedia)
In my humble opinion, there are a few important keywords (in bold) in this definition that should be kept in mind when thinking about scalability.
I recently watched that video (I love google tech talks) from Cuong Do Cuong given during a quite old conference in Seattle (in 2007). Cuong is an engineering manager at Google (YouTube). “He was part of the engineering team that scaled the YouTube software and hardware infrastructure from its infancy to its current scale. Prior to YouTube/Google, he held various software development and management positions at PayPal and Inktomi.”
Cuong shares with us some his experiences, the different issues related to scalability he and the team faced. I hope you will enjoy it as much as I did.
In: User Experience
15 Jun 2009Recently, I have been working on building a new search engine. After performing some searches on Google, I ended up watching a tech talk from Marissa Mayer. Marissa is vice President (Search Products & User Experience) at Google. Just to give you a background here is a short summary of her bio, she has an impressive experience (found on the google site) :
Marissa leads the company’s product management efforts on search products – web search, images, news, books, products, maps, Google Earth, the Google Toolbar, Google Desktop, Google Health, Google Labs, and more. She joined Google in 1999 as Google’s first female engineer and led the user interface and web server teams at that time. Her efforts have included designing and developing Google’s search interface, internationalizing the site to more than 100 languages, defining Google News, Gmail, and Orkut, and launching more than 100 features and products on Google.com
I saw her presentation named “Scaling Google for Every User” (June 2007) at the Seattle Conference on Scalability. I really liked the part where she talks about how much features should be presented to end users, how to present them and how basically simplcitiy beats complexity. She kinda destroys the myth that “having more features is always better”.
In: PHP
29 May 2009PHP Code Comparator is a command line script allowing to compare different versions of a library, framework or package. It will detect code changes in terms of class existence or method definitions.
If you ever wanted to have a way to quickly identify what classes have been altered or methods have been changed between two different versions of the same package, PHP Code Comparator will help you achieve that.
Instead of using a diff tool, you can simply use this tool. It will basically parse a folder recursively, detect any defined classes and extract the various methods and parameters. This will then be performed on the second version of your library. Finally, a summary will be displayed showing the differences that have been detected.
This tool will detect if a class has been removed, if new classes have been added, if methods have been removed or added and also if the signature of a method has changed.
You can browse the code and download it from github.com.
http://github.com/alfallouji/PHP-Code-Compare/
You can also directly get the source code from the git repository.
git clone git://github.com/alfallouji/PHP-Code-Compare.git
You will find more information on the official page : PHP Code Comparator
In: PHP
25 May 2009I recently heard about a funny contest handled by Microsft. The concept is really fun, and so is their web site (Check the video!).
Here is a short description of the contest.
Microsoft presents the Ultimate Battle: It’s a knock-down, drag-em-out battle between professional and student developers! And it’s your big chance to show the world your awe-inspiring PHP application – on the Windows-based platform! We’ll select one student and one professional coder for the Ultimate Throwdown – a final bout at the “Make Web, Not War” Conference! The winner can take home up to $10,000 in total prize money!Challenge a friend, invite a colleague, ask anyone – get the whole gang in on the Ultimate Throwdown Action.
Last day to enter the contest is June 3rd. So hurry !
In: Knowledge
21 May 2009WolframAlpha is a computational knowledge engine created by Stephen Wolfram
It basically generates output by doing computations from its own internal knowledge base (composed of many trillions of elements), instead of searching the web and returning links.
I spent some time testing it and I gotta say it is awesome. So, no it isn’t gonna replace Google, it is for a different usage.
It is very usefull when you want to find answers to a particular question, for instance, if you look for earthquake in indonesia, you will get this as a result.

I really like the way the information is reported / outputed to the end user. If you try with “barcelona montreal”, it will even display the result in a table and compare the results.

I took some time to read a little bio about Stephen Wolfram and well, it is pretty impressive. Here is a short summary of what we can read about him on Wikipedia.
Who is Stephen Wolfram ?
Stephen Wolfram (born in 1959) is a British physicist, mathematician,author and businessman, known for his work in theoretical particle physics, cosmology, cellular automata, complexity theory, and computer algebra.
Wolfram is considered as a child prodigy, he published an article on particle physics at age 16 and entered Oxford University at age 17. He received his Ph.D. in particle physics from the California Institute of Technology at age 20. He developed the famous software Mathematica.
(Source : Wikipedia)
Have fun and try that very nice tool, this is defintely going in my bookmarks folder: WolframAlpha.com
My name is Bashar Al-Fallouji, I am an IT Consultant and Co-Founder at DevMotion.
I am particularly interested in Web applications, Open Source Development, Software Engineering, Information Architecture, Unit Testing, XP/Agile development, etc.
On this blog, you will find mostly technical articles and thoughts around PHP, OOP, OOD, Unit Testing, etc. I am also sharing a few open source tools and scripts.