Live blogging from Singapore PHP User Group meet up (January 2008)

Blogosphere January 9th, 2008

Welcome to the first PHP Singapore User Group meet up for 2008! Today, the meeting is held at Singapore Management University (SMU) at Seminar Room 2.1. So if you are around the area, do pop by and let the security know that you are attending the PHP. Besides free good food and drinks, you get to surf the Net for free if you are not on any paid broadband or if your Wireless@SG is not working as usual.

The highlights for today includes Design Patterns in Web Applications and PHP201 - connecting to MySQL Database. This meet up is different from the previous one in that the tracks are ran consecutively instead of being concurrent like the previous one. In this way, we would be able to provide you with the entire content via live blogging.

The first track will be presented by Tang Chin Yong, who is a code crew from Ablewise Free Classifieds while the second track is covered by Michael Cheng. For those who are present at the meet up, do sit back and relax and mingle around.

7:52pm: We have reached the limit for simultaneous log-on and are trying to resolve this ASAP. Meanwhile, do… enjoy the food. =)

7:55pm: The room’s filling up to almost 3/4 of the seminar room. It’s beginning to look like a really big up for this month’s meet up. Indeed, what a great start to the new year! =) We have the familiar faces in the room today, including Ming and Nannywen from Nuffnang, Damien, Lester, Bernard Leong, Yuhui, Nicole, Neil and the list goes on.

8:00pm: Here’s the official word. The number of Internet connections had been max’d out. So for those who have wireless connection now, the official word is to continue enjoying it. For those who do not have Internet connection, well, we hope to iron this out by the next meeting. Michael sends his apologies to everyone else who are not able to connect.

8:05pm: Michael started off with an opening address introducing himself and the Singapore PHP User Group in Singapore. He is also covering the mission of the PHP user group as well as the vision for this year. For the first quarter of 2008, we would also be doing a facebook developer garage for those who enjoy doing facebook stuffs as well as a PHP boot camp in June this year. A PHP apps contest is also in the pipeline to bring in the fun and thrill.

If you would like to help out with the PHP user group, do feel free to contact Michael because he feels that there are much more that we can achieve together. We have some new members including Damien, Neil, Terrance, Shawn, myself (!), Bernard (marketing, and working with Neil), Adrian Quek (curriculum together with Chin Yong). For more information, you may drop by the PHP Wiki or facebook.

8:15pm: Chin Yong has taken over and is starting on the first official professional track. He is a little nervous now because he feels that he can never be prepared sufficiently for such stuffs. This section will be covered by himself and Tji Han.

In a nutshell, they run Ablewise.com and have been through various stages and would like to share their experience. Today, they will cover design patterns by giving an introduction as well as highlighting 3 common design patterns. There is also a hidden agenda which is to determine possibility of more design patterns and a … ahem, shameless plug to get publicity.

The overview of today includes covering design patterns, what design patterns are not, the gang of 4 format and various selected design patterns. For those who are not familiar with design patterns, they are actually using 1 type too. It’s know as spaghetti pattern. =S

What are design patterns?

Theoretically, there are more than 1 type of design patterns, but there is usually 1 preferred over the others. Design pattern is platform independent, which is pretty much like object orientation, which is essentially a concept.

There are no hard and fast rules in coding and design pattern is not a hammer for all nails. There are no hard and fast rules and it’s highly contextual. However, different design patterns are not applicable to all languages. and it does not make any language better.

He’s covering the gang of 4 format, which is created by 4 founders.

The purpose of this pattern is that it should tackle the problem at hand. It’s not easy to mention in words now, so it’s better to wiki it here.

This track is a little too technical with about 40% of the people in the room looking a little lost. Frankly, I am a little lost too. So I’d get the slides from him later to be uploaded either here or on PHP Wiki. =P However, if you are really new to design patterns, one take hope lesson is that you should code to implementation and not to interface.

Chin Yong is going through the Facade Pattern now, which is one of the simplest design pattern available. A question is now posed to the floor which someone probably gave a different answer from what he was expecting. So the politically correct answer is to admit that it depends on the scenario.

Tji Han is now on the floor, covering MVC Patterns. He feels that it is possible to have an entire page on a single PHP page, which is probably not conducive for programmers and designers to work on. Hence the View and Model layers are separated and controlled by a main controller so that each of the people working on it need not share the page.

Depending on what kind of framework you are using, with Cake PHP framework being preferred for ablewise.com, He is currently running through some sample code on the screen which shows how a programmer does all the coding for the backend while designer does a simple call through another file.

For people who are new to design patterns, they may wish to pick up some books from the NLB which includes (1) PHP 5 objects, patterns and practice, (2) design patterns and (3) design patterns for dummies.

Lastly, they would like to thank Wikipedia and Michael for making this presentation possible.

The parting shot for this presentation:

  • PHP Cheat Sheet
    • ilovejackdaniels.com

One of the attendees asked about persistence in Cake PHP and the answer is that Cake PHP does cache everything when it is loaded so that they load much faster the next time these objects are called.

Michael suddenly realised that he forgot to ask the audience on their user type so that there can be more interaction during the break so that the entrepreneurs know where the seasoned programmers are and where the beginners are so that they can be left out guided.

Bernard Leong highlighted that in Computational Biology, they use design patterns in a way that they do not have to do the same thing over and over again. To this, Chin Yong highlighted that design patterns are meant to help the programmer achieve in a particular goal through appropriate use of the correct design pattern. Of course, the other advantage of having a well-thought programming methodology or design patterns is that code can be easily reusable.

Michael also highlighted that design patterns are really everywhere and that using frameworks makes things easy by providing a particular methodology for the programmer to follow. One member of the audience highlighted that there are literally 1000s of frameworks available and asked what should be looked out for while looking for a framework.

The answer to this is that people should use google as a tool (like typing "framework php") and taking what returns most. One important factor is to make use of a framework that is well-supported or well-used because at the end of the day, programmers will depend on the community to help them along with it. Of course, feature sets are also important, but it is something that will continue to grow as long as there is a community.

Another thing to look out for is the footprint - in that Chin Yong feels that a small footprint is important. To this, Bernard feels that refactoring is something that is also important. Michael summed this up by noting that there is really no 1 good solution to this, and that what’s important is that the goals of the project should be met, which includes phone support, community support (leading, bleeding edge technology?), and programmer preference (lots of code vs. little code, drag drop) amongst others.

Michael exclusively uses Cake PHP because it follows a lot of philosophical stuffs in that it is very similar to Ruby on rails - including convention (Cake PHP?) vs. configuration (not good in ROR, good in Symfony.com/.org). There are also various characters in different frameworks, although Michael strong advocates Cake PHP.

Shawn from the floor utilizes spaghetti framework because he feels that as long as it helps unify his programmers, it’d do. Nuffnang also started with the spaghetti framework because he started small, but has now started using the MVC framework because it got much bigger now. Another site that started with spaghetti includes facebook too.

8:55pm: There is now a break cum networking session and Ming from Nuffnang is here to do a show case on his product. The session will resume in about 10 to 15 minutes’ time.

9:20pm: Welcome back! We have Michael Cheng on the floor now and he’s presenting PHP201 PHP and MySQL. There will be 3 parts today where he will cover some database concepts and tubes and some active participation in coding from the audience. He is trying to describe what a relational database is, but because of the lack of images, everyone has to imagine how a relational database looks like.

To access data from a database, we have to know what the server address is, the port number, some form of user authentication and the name of the database.

Next up is the tubes. As one Senator said, the Internet is made up of tubes. The joke is that, the Internet is made up of tubes and when they get congested, we need tiers….

Right.

So what are the tubes? They are:

  • Mysql_Connect
    • server address, port number, user name, password comes here
    • it opens connection to database server
    • mysql_connect("localhost", "root", "root")
  • Mysql_select_db
    • mysql_select_db("database_name")
    • selects database to query
  • Mysql_query
    • $local_var = mysql_query("statement")
    • to retrieve data / initiates a database query
    • while ($row = mysql_fetch_assoc($local_var)) { do something to $row or $row[’column_name’] };
  • Mysql_fetch_assoc
    • retrieves fetched rows
  • Mysql_close
    • Mysql_close()
    • closes the database connection
    • According to Michael, we should always close the connection while according to some books, MySQL does its own garbage collection
    • If this statement is executed twice or more times, it will report an error - hence to prevent the second one from reporting an error, we may use @Mysql_close()

Since the connect and select_db commands may be repetitive, we may use include or require to include an external file which contains all these commands. An example is include("config.php") or require("config.php"). The difference between include and require is that requires will return an error if a particular file is not found while include does not.

require_once is good if there may be a risk of nested includes that includes the same file more than once. For more information, some source code will be made available online. Members of the PHP Singapore User Group team will be there to answer your questions, if any.

9:43pm: We now come to the end of the PHP session. For more information, you may also refer to the official php.net official site. Today’s session is more precise because the core team felt that they may be going a little too fast or too much in the past 2 sessions. If you have any feedback, do feel free to leave some comments after this post.

Michael may be contacted at michaelchengchimun@hotmail.com, miccheng@php.com.sg and the official Singapore PHP User Group site is at www.php.com.sg

See you next month at the next PHP meet-up! Thank you!

For once, I actually agreed with Lee Kuan Yew… wholeheartedly

Perspectives January 9th, 2008

MM Lee was posed a question by Dr Quah who asked about Singapore’s progress in terms of social graces and environmental consciousness just as the country succeeds economically. "Not in my lifetime" was his answer. To this, I actually agree with him wholeheartedly.

Give me five, Kuan Yew! With all due respects of course, Sir.

I believed I’d have blogged about this some time or other, that it is very difficult for Singaporeans to be as matured socially as it is economically. An oft-used statement that I tell my friends is that while it is easy for Singaporeans to find ways to boost the economy and be entrepreneuring, habits are harder to cultivate. After all, humans are creatures of habit (and actually so were my cats).

From the complaints of people on seats not being given up to the elderly, pregnant and disabled to that of people not keeping to one side of the escalator to how people just condemn others with their "holier than thou" (thanks Dr Chua for the phrase) attitude when others did something wrong or something that is not accepted by the society, it is quite prevalent that it will remain this way for many years or generations (*gasp*!)to come.

Indeed, we recall about how the angmos are supposedly treated better while the locals experience more hostility less friendliness. This, after much thinking (not analysis, just thinking), could be due to:

  • the encounter of more friendly and appreciative angmos
  • the higher expectations of Singaporeans

Of course, there may be many other reasons, but since this is impromptu, these are the only 2 reasons that I can think of. Many a times, we may have encountered rude angmos but again, this is a statistical game. What I do think I know is that they have probably came a long way too.

Like MM Lee, I think think I’d see a gracious Singapore in my lifetime.

A gracious Singapore? Not in my lifetime: MM

He says cultivating social graces will take longer compared to environmental consciousness

By Li Xueying

ENVIRONMENTAL consciousness among Singaporeans will come about very quickly when they realise how they will be in trouble when changes in the climate take place.

But attaining a gracious society will take more time, said Minister Mentor Lee Kuan Yew on Monday at a dialogue marking the 40th anniversary of the Institute of Southeast Asian Studies (Iseas).

In fact, he believes it will not happen in his lifetime.

‘I will not see it, maybe you will live long enough to see it; I wish you well,’ he told 48-year-old economics academic Euston Quah to laughter from the audience of diplomats, academics and government leaders.

Dr Quah had asked a question about Singapore’s progress in terms of social graces and environmental consciousness just as the country succeeds economically.

The issue he raised was among a host of subjects brought up by the audience, from the situation in Myanmar to the rise of China and India.

In his reply, Mr Lee said a gracious society will not happen so fast. ‘I think it will take more time to develop and mature culturally as a people.’

Even the British, he said, were ’sitting at a very high level over an empire for nearly 150 years before they developed their culture and then being invaded by football hooligans and foreigners who are now joining them and coarsening their society’.

‘So it’s very difficult to get a rough society onto a cultivated plane and it’s very easy to bring it down,’ he concluded.

Environmental consciousness, on the other hand, will come very quickly ‘when something happens and they say, you do that, your whole environment changes and you are in trouble’.

On the other hand, the idea of a gracious society - ‘where people are considerate to one another, where you don’t make more noise to upset your neighbour than you need to, where you tell the other motorist, please have the right of way’ - was ‘harder to come by’, said Mr Lee.

‘It will take time, but I hope it will come with cultivated living over a long period of time.’

Mr Lee recalled how, 45 years ago, Singaporeans wanted to take their chickens with them when they were resettled from kampungs into high-rise flats.

‘So it took some time to get them adjusted. A more cultivated way of life takes a very long time,’ he said.

xueying@sph.com.sg

Article obtained from straitstimes.com on 9th January 2008

Thanks to Paddy and all my friends and readers! But er… What is an iPod classic?

Personal January 9th, 2008

Seriously, sometimes I think I am not really that geeky after all - because when I first heard it, I was thinking to myself - what is an iPod classic? Haha… Before I go on, I would like to thank Paddy of Blog2u and iShop by Club 21 for the iPod classic and to all my friends and readers for supporting Simply Jean. Confused? Yeah… me too, but here’s the long and short of it. =)

Paddy from Bog2u called me on my cell phone this morning (which I missed) to congratulate me on being the winner for the Referral Contest, which I took part without being aware of it.

Apparently, there was a contest by Blog2u for existing bloggers who are with Blog2u to refer their friends to join the Blog2u network. So me being me, I think I told some of my blogger friends to sign up for it, and of course telling them that they do not need to wait to accumulate for their earnings - which really is a plus point. However, that was it.

Somehow, word got propagated and from what I heard from Paddy, quite a number of bloggers put me as their referrer so that effectively entitles both of us a coupon each; and as the saying goes, the rest is history.

When I returned the call to Paddy, I wasn’t expecting anything and thought that someone had called me by mistake. However, I was shocked beyond words that I actually won something from a contest. If it weren’t Paddy (or any other people that I have heard of) I would have nearly thought that it’d be a time-sharing scam scheme. It was to the extent that Paddy asked if I was usually that soft-spoken! Haha…

However, the next question that crossed my mind was… what is an iPod Classic? I mean… I know what an iPod is, probably the iPod Nano, Touch and Shuffle… but Classic? Isn’t that the name that they give to very old and out-dated products? Like… Mary Poppins is a classic, or Penguin classics and all? Then I did a search for it and realised that I can’t be further from the truth. Apparently the iPod classic is a remake (or sorts) of the classical iPod except that it is now more sleek and comes with an enhanced interface! 80GB! Goodness! The largest MPEG player that I have is only a 30GB! Wow, 80GB! w00t! w00t!

ipod-classic-2

Wow… I have not gotten over the shock yet! Haha… what a great way to start the new year indeed! =) Really… many thanks to Paddy and iShop again, and of course to all my fellow blogger friends and readers who made this possible. =)

Thanks and happy new year! Yippee!

Of taxi drivers and me

Perspectives January 9th, 2008

It’s been quite a long while since I last hopped onto a taxi without thinking much of the cost - after all, the papers and industry are right - the cost of taxi transport is relatively cheaper when compared to other developed countries. Of course, this was before the taxi operators decide to raise the fares of taxis recently, effectively bringing up the cost of taking a cab by almost 50% during peak hours.

On the fateful day that the fares were raised, all these changed. I stopped raising my hands as often as I would and I would think twice about the damage that I’d suffer should I decide to take the cab. Effectively, I have not taken a cab during peak hours. I wasn’t sure if I’d have an impact anyway, since the newspapers had been giving anecdotes of taxi drivers who praised the fare hike and that now they are earning a lot more.

However, there were recent news that some taxi drivers are in fact not earning as much as the papers have portrayed. It seemed that their businesses dipped tremendously - to the extent of some putting up notices of discounts. Unfortunately such innovations by the taxi drivers are not welcomed by LTA, who immediately slammed them (left, right and center), mentioning that this is illegal. There were reactions from some readers, with one highlighting the following:

When just a taxi driver give discounts, the authorities reacts so fast in the media. When so MANY taxi drivers tout, the authorities takes weeks to react.

Posted by: hongchris at Tue Jan 08 07:40:44 SGT 2008

There were also others who dug out the Public Transport Council Act:

The Public Transport Council Act (CAP 259B) states:

Bus, taxi and rapid transit system fares
23. —(1) No person shall be entitled to demand and take any bus, taxi or rapid transit system fare in excess of that approved by the Council.
[29/95;29/99]

(2) Subsection (1) shall not prevent any person from demanding or taking a lower fare than that approved by the Council.
[29/99]

This seems to shoot the LTA down, but no further details are known at this moment. However, the LTA thinks that by providing discounts, this may result in touting and is hence illegal. Hmm… so much for entrepreneurship.

There are also taxi drivers who are on the verge of swearing off driving taxis should business not pick up after Chinese New Year. After all, it’s during Chinese New Year that most businesses are gained, especially when the majority of Singaporeans are Chinese and that quite a handful probably do not own cars given the increased cost of ownership (COE, ERP, fuel hike).

The uncertainty, of course, lies until after Chinese New Year - since that’s when the litmus test really begins. A question that burns in my head is if Singaporeans really do have memory the size of a mouse? Are Singaporeans really that forgetful? Will "incentives" help them get over such things? What if the government throws in a transport rebate of $20, $50 or even a $100 to everyone before an impending transport fare hike? Will this help sooth any knee-jerk reactions?

Frankly, I don’t have the answers. However, there are still many people ("analysts") in Singapore who predicted this knee-jerk reaction and are persisting that we are still in the phase of a knee-jerk reaction - which I do not deny. After all, it’s still barely 1 month from the day that the fares were increased and conflicting anecdotes from taxi drivers do not really help much. LTA, of course, can only provide data after everything has "stabilized", by then, if the lack of customers persisted, I’m not sure how many taxi drivers would be emptying their saving accounts to pay rent if they are not already dead dead broke.

For me, I have struck off taking cabs as a means of transport and am usually left pondering the travelling salesman problem. It’s only in times of urgency and rush that I suddenly discovered a new form of (rather expensive) transport called taxis. Even then, it’d take a lot to get me to take one during peak hours. However, I know of business owners who take still believe that taxi fares are still really affordable in Singapore and are encouraging everyone to support the poor taxi drivers who really didn’t bring it upon themselves.

I sometimes wonder if ComfortDelgro had put any thought into this and if they really believed that Singaporeans are indeed forgetful. Food for thought, perhaps?