<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>agum &#187; Web apps</title>
	<atom:link href="http://www.agum.com/web/category/web-apps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.agum.com/web</link>
	<description>The Web Dev Blog</description>
	<pubDate>Mon, 23 Jun 2008 10:47:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Facebook Applications</title>
		<link>http://www.agum.com/web/2007/09/16/facebook-applications/</link>
		<comments>http://www.agum.com/web/2007/09/16/facebook-applications/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 06:19:44 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[Facebook apps]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/09/16/facebook-applications/</guid>
		<description><![CDATA[The Facebook platform has been released for a while now, and believe you me, I&#8217;ve been doing development on it since day 1 of that until now, non-stop. I think I can say with fairly good confidence that I&#8217;m an expert Facebook developer in PHP.
Facebook applications originally provided something with very good potential, but unfortunately, [...]]]></description>
			<content:encoded><![CDATA[<p>The Facebook platform has been released for a while now, and believe you me, I&#8217;ve been doing development on it since day 1 of that until now, non-stop. I think I can say with fairly good confidence that I&#8217;m an expert Facebook developer in PHP.</p>
<p>Facebook applications originally provided something with very good potential, but unfortunately, it isn&#8217;t really working in the way I would hope it should.</p>
<p><span id="more-20"></span><br />
<strong>Usefulness vs triviality</strong></p>
<p>It is extremely unfortunate that majority of the Facebook applications that &#8220;succeeded&#8221; (currently) are entirely useless ones such as SuperPoke, X Me, SuperWall, and Top Friends. It is not hard to see how they succeeded.</p>
<p>Slide and RockYou apparently has some sort of partnership with Facebook (correct me if I&#8217;m wrong in this); they were able to push out some applications since day 1 of releasing the Facebook apps platform. They created these useless little apps, and made ways of spreading them (mainly the &#8220;Invite your friends&#8221; page when you first add the app).</p>
<p>Of course, now that everybody knows what that is, everybody just skips that page entirely. But when it first started, people actually invite other people through that.</p>
<p>Normally, an app getting popular, no matter what ways it used to accomplish that, isn&#8217;t really a problem. The main problem here lies in the fact that these apps are mostly useless trivial apps &#8212; look at SuperPoke, X Me, Free Gifts &#8212; they do nothing more than posting a message or an image on a friend&#8217;s profile. Top Friends has a little more to it than that, but also doesn&#8217;t have much practical uses other than generating hate from your <em>other</em> friends who didn&#8217;t get in your Top Friends list. (did anyone actually think of that when they add people to their top friends? I can&#8217;t believe how many people actually think Top Friends is cool. It destroys a lot more friendship than improving any.)</p>
<p>All of this gave a <em>really</em> bad example for new developers starting at this stuff. Other programmers see the success of these useless little apps, and they go ahead and make some too. It easily became the norm, then, to make trivial apps on Facebook. This in turn leads regular Facebook users to get used to the fact that Facebook apps aren&#8217;t to be taken seriously. It&#8217;s just fancy little toys to be added to your profile with no practical uses. Now, the only difference between Facebook Apps and the trash you see on MySpace is that Facebook Apps are more secure and more difficult to program for &#8212; other than that, there is no practical difference.</p>
<p>This is really, really sad because Facebook apps would have so much potential otherwise. Facebook could&#8217;ve pulled the a great part of web 2.0 applications into their platform if Slide and RockYou didn&#8217;t set such bad examples! The possibilities would&#8217;ve been endless.</p>
<p><strong>Before Facebook Apps</strong></p>
<p>Did you know that a Facebook development platform existed before Facebook released Facebook applications? You could develop third-party web applications (or even desktop applications!) using Facebook&#8217;s social network data to back you up. They would be standalone web sites, only having a Facebook login. All &#8220;Facebook Apps&#8221; did was to allow you to integrate your application into people&#8217;s profile boxes and provide you with a canvas page (which is mostly just an individual web site, for the most part).</p>
<p>Take a look at this: <a href="http://moochspot.com/">MoochSpot</a>. It lets you &#8220;keep track of debts and shared  		expenses with your friends&#8221;. Excellent idea, nicely done using the Facebook platform.</p>
<p>And you know what? That is what Facebook applications should have been like in the first place! Useful web 2.0 web apps integrated into Facebook. NOT trivial little toys to add to the Facebook profile.</p>
<p><strong>Another way to see it</strong></p>
<p>Perhaps, though, Facebook could help us partly solve this problem by fixing their Applications directory. Help those of us developers who actually invest development time into creating a serious application with practical uses, and help the users find out about these things.</p>
<p>Categorize Facebook Apps into two big categories &#8212; little toys and serious apps. Or better yet, just call little toys something different altogether, like &#8220;profile add-ons&#8221; or something. That is where stuff like SuperPoke, Top Friends belong. Facebook Apps should be where stuff like <a href="http://moochspot.com">MoochSpot</a> and <a href="http://www.goingifts.com">GoInGifts</a> belong. (That second one, by the way, is what my team has been developing in the past month. The Facebook app, not the standalone web site &#8212; that is just a temporary placeholder designed by some web designer.)</p>
<p><strong>Conclusion</strong></p>
<p>Of course, Facebook Apps are still young to really say anything about it significant at all. There could very well be major changes coming up within the year that makes it into something entirely different, maybe working like what I mentioned above. Even the Facebook platform itself isn&#8217;t in a stable state yet &#8212; changes are being made from their engineering team every week, stuff is getting added, removed, and updated all the time. Let&#8217;s hope for the best and hope that Facebook will eventually solve all this out, and not to make it like another MySpace.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/09/16/facebook-applications/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Where do you draw the line between designer and developer?</title>
		<link>http://www.agum.com/web/2007/08/03/where-do-you-draw-the-line-between-designer-and-developer/</link>
		<comments>http://www.agum.com/web/2007/08/03/where-do-you-draw-the-line-between-designer-and-developer/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 08:56:15 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/08/03/where-do-you-draw-the-line-between-designer-and-developer/</guid>
		<description><![CDATA[As web 2.0 applications get more and more mature, the roles of web designers, web developers and web application developers become more and more blurry.
Years ago, web designers simply design web sites. They aren&#8217;t very different from traditional print designers. Sure, some of them might not only do the design, but also code up their [...]]]></description>
			<content:encoded><![CDATA[<p>As web 2.0 applications get more and more mature, the roles of web designers, web developers and web application developers become more and more blurry.</p>
<p>Years ago, web designers simply design web sites. They aren&#8217;t very different from traditional print designers. Sure, some of them might not only do the design, but also code up their designs in HTML. But a lot of times, web designers are only responsible for the visual designs, and they pass on their work to web developers to convert the visuals into actual web pages. Back then, there wasn&#8217;t even much of a term as &#8220;web application developer&#8221; &#8212; what is a web application in 1998? A form mail script? A guestbook? Nobody would do that for a living. Let&#8217;s rephrase that &#8212; you won&#8217;t make a living doing that.</p>
<p><span id="more-19"></span><br />
Now we enter the web 2.0 boom. Full-fledged web applications are being developed. <a href="http://www.meebo.com">Meebo</a> is my favorite example. And there&#8217;s Google Docs &amp; Spreadsheets, etc. How are applications developed? By programming, obviously. Just like desktop applications, web applications also have a backend programming element to it, as well as a frontend interface programming element. These are huge applications we are talking about &#8212; they are as large as or even larger on scale than desktop applications in the past!</p>
<p>Web applications backend programming is really not much different from traditional programming people have been doing since the beginning of time. (except maybe working with different languages &#8212; like PHP, Ruby on Rails now. But people still use Java and C++ too!) When we get to frontend, things get a bit different. We have new technologies like DOM scripting and AJAX. These technologies are still in sort of an infant stage. It really takes a tech-savvy person to bend them at will and do what you need to do. Heck, even writing standard XHTML and CSS and making sure they work across browsers is a challenge!</p>
<p>Needless to say, frontend development work has to be done by programmers as well. Here&#8217;s where the problem comes in. As we all know very well, programmers aren&#8217;t good designers. What this translates into is a whole bunch of web applications with badly designed interface. You could hire a designer to make things look good, but if an application has a bad interface, that makes it a bad application.</p>
<p>It takes a usability expert and/or a great UI designer to do this frontend work. Very often, the frontend programmer is not this person. Currently, the only solution to fix this problem is to hire somebody who is both a great UI designer and a programmer to do the frontend work. It certainly is a big challenge! There aren&#8217;t that many of them out there.</p>
<p>And we come back to the question. Where do you draw the line between designer and developer? I am a web application developer. A lot of times, however, I find myself having to take care of some aspects of the frontend design. So should I be considered a designer in addition? The designer at my company needs to learn some web apps programming in order to improve on her work. She needs to understand how AJAX works, how the DOM elements on the page work, in order to make her designs work. So is she a developer now?</p>
<p>Frontend applications development is an interesting job. It takes both good design knowledge and technical knowledge to do the job &#8212; an unusual duo. Frontend developers should really be more valuable than backend programmers, since old-school programmers are a dime a dozen. Why aren&#8217;t we getting paid more? <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/08/03/where-do-you-draw-the-line-between-designer-and-developer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Multiple Browsers Testing</title>
		<link>http://www.agum.com/web/2007/07/19/multiple-browsers-testing/</link>
		<comments>http://www.agum.com/web/2007/07/19/multiple-browsers-testing/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 22:39:36 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/07/19/multiple-browsers-testing/</guid>
		<description><![CDATA[It&#8217;s been a while since I last posted something. I apologize for that, but I have been fairly busy in my job recently. So, this time I&#8217;m going to give you some useful information I&#8217;ve learned in my job lately.
It started from a time when one of my clients was using (are you ready for [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I last posted something. I apologize for that, but I have been fairly busy in my job recently. So, this time I&#8217;m going to give you some useful information I&#8217;ve learned in my job lately.</p>
<p>It started from a time when one of my clients was using (are you ready for this) <em>Firefox 1.0</em>. If you are one of the unlucky souls who don&#8217;t understand the meaning of this &#8212; Firefox 1.5 had been the &#8220;standard&#8221; Firefox for about a year or more, and Firefox 2.0 has been out for at least a month or two (or more; and I&#8217;m not even the type who keeps myself that updated). He told me that the page didn&#8217;t look right and he was using Firefox, so I wondered for a while before finding out that he was on Firefox 1.0.</p>
<p>So I figured there is actually a need to install multiple versions of Firefox for testing. Surprise! There are actually ways to install multiple versions of Firefox as well as IE on your computer, without having multiple computers or doing any sorts of virtualization. Oh, and this guide is for Windows users. If you&#8217;re doing any sort of frontend design, Windows testing is your main target, no matter how much you like Mac or Linux yourself. <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-16"></span><strong>Installing Multiple Versions of Firefox</strong></p>
<p>I will try to make this your one-stop guide to doing this, so I will include every link you&#8217;ll need here. First of all, to give credit where it deserves, I first got my information from <a href="http://dojotoolkit.org/node/209">dojotoolkit.org</a>.</p>
<p>If you attempt to simply install all 3 versions of Firefox separately and run them normally, you will always only open the latest version you have installed, no matter which executable you run. By following these steps below, you can run Firefoxes 1.0, 1.5 and 2.0 side-by-side.</p>
<ol>
<li>First, to get old versions of Firefox, you should go to this <a href="http://www.oldversion.com/program.php?n=firefox">oldversion.com link</a>. Firefox versions older than 1.5 are not available on the official web site, so you will have to get 1.0 on third party archive sites. I recommend 1.0.7, that&#8217;s the one with the &#8220;latest&#8221; bug fixes from the 1.0 series. Note: As far as I know, rendering engines have no differences between subversions of 1.0 (or that of 1.5, or 2.0). So you only need to get the latest 1.0.</li>
<li>As for Firefox 1.5, at the time of this writing, it is still available on the <a href="http://www.mozilla.com/en-US/firefox/all-older.html">official Firefox site</a>. I recommend getting it from there, since they have the latest 1.5.0.12, versus the 1.5.0.7 on oldversion.com.</li>
<li>Run the installations for Firefox 1.5 and Firefox 1.0. Do not install them at C:\Program Files\Mozilla Firefox. Instead, rename the installation folder to Mozilla Firefox 1.5 (and 1.0). At the end of the installations, when asked if you want to launch the program, click No.</li>
<li>Go to the two respective installation folders, and rename the firefox.exe file in there to firefox1.5.exe and firefox1.0.exe correspondingly. This is not a required step, but I recommend it because you&#8217;ll able to tell their differences in Task Manager.</li>
<li>Then you need to create a .bat file for both of these versions. Make a new file called firefox1.5.bat (and firefox1.0.bat for the second one), and paste these lines in it. Of course, for the 1.0 version, change all the &#8220;1.5&#8243; occurrences below to &#8220;1.0&#8243;.
<pre>set MOZ_NO_REMOTE=1
start "Firefox" "C:\\Program Files\\Mozilla Firefox 1.5\\firefox1.5.exe" -P "Firefox1.5"
set MOZ_NO_REMOTE=0</pre>
</li>
<li>Run the .bat file. The first time you run it, Profile Manager will come up and ask you which profile to run with. Create a new profile with the respective name (&#8221;Firefox1.5&#8243; for version 1.5, and &#8220;Firefox1.0&#8243; for version 1.0, as it shows in the .bat file lines above).</li>
<li>When Firefox runs, you will have all new bookmarks and everything, and the About window tells you that you are on the right version. By using the .bat file, you can run all versions of Firefox at the same time. After running for the first time, you will not get the Profile Manager that asks you for profile anymore.</li>
<li>Lastly, I recommend creating a .bat file even for your latest (2.0) Firefox, for maximum clarification. Use the same file content shown above, but take out the &#8220;1.5&#8243; occurrences. For the profile name, use -P &#8220;default&#8221; instead.</li>
</ol>
<p>That&#8217;s it!</p>
<p><strong>Installing Multiple Versions of IE</strong></p>
<p>Doing this with IE is way simpler than with the Firefoxes, thanks to some kind folks who developed a program called MultipleIE.</p>
<ol>
<li>Install IE7. Yes, you may feel free to overwrite your IE6. You will get it back later, so don&#8217;t worry about it.</li>
<li>Go to <a href="http://tredosoft.com/Multiple_IE">Tredosoft</a> and download the Multiple IE software. Follow all instructions on the web site and on the setup program.</li>
<li>You&#8217;re done. <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Did you expect more steps?</li>
</ol>
<p>Simple enough? <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Conclusion</strong></p>
<p>Now, you have on your Windows PC Firefox 1.0, Firefox 1.5, Firefox 2.0 as well as IE versions from 3.0 to 7.0. As a good web developer (especially a frontend one), you should be testing for as many browsers as possible and make your code work for as many of them as you can. <a href="http://www.apple.com/safari/">Safari</a> and <a href="http://www.opera.com/">Opera</a> are other browsers you should consider supporting. (You no longer need a Mac to test for Safari! <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>There is also <a href="http://www.caminobrowser.org/">Camino</a>, but it uses the same rendering engine as Firefox, so you can assume your site will work with it as long as it works with Firefox. As a bit more information: Safari and Opera use their own rendering engines which are different from Firefox. However, both follow web standards (defined by the <a href="http://www.w3.org/">W3C</a>) pretty well, so most of the time you won&#8217;t get too frustrated with them. Internet Explorer is really the only one that likes to stray away from standards (even now in IE7), but it&#8217;s also the most commonly-used one. What can you do, right? <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/07/19/multiple-browsers-testing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Separation of POST/GET requests in PHP</title>
		<link>http://www.agum.com/web/2007/06/18/separation-of-postget-requests-in-php/</link>
		<comments>http://www.agum.com/web/2007/06/18/separation-of-postget-requests-in-php/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 23:26:05 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/06/18/separation-of-postget-requests-in-php/</guid>
		<description><![CDATA[Last time we talked about MVC application design. There is something I want to write about, stemming from the topic of the last article. It is the separation of POST/GET requests in PHP web apps, which I am an advocate of. It is sort of like a VC (View-Controller) architecture.
This is strictly an application-design topic. [...]]]></description>
			<content:encoded><![CDATA[<p>Last time we talked about MVC application design. There is something I want to write about, stemming from the topic of the last article. It is the separation of POST/GET requests in PHP web apps, which I am an advocate of. It is sort of like a VC (View-Controller) architecture.</p>
<p>This is strictly an application-design topic. I&#8217;m not introducing any new fancy functions or features in PHP. It&#8217;s about how you design your web app, for better usability. (I happen to be pretty serious about web app usability, which, IMO, all software developers should be, for any software they are working on. This is why so many of my articles focus on what you could do to improve usability &#8212; it&#8217;s something too many programmers neglect.)</p>
<p><span id="more-13"></span><strong>The history of HTTP&#8217;s POST and GET requests</strong></p>
<p>I&#8217;m sure almost anyone who does web development know what POST and GET requests are. GET requests include form parameters in the query string of the request; they can get cached; they can be sent to a friend through email/IM, and so on. POST requests send parameters as part of the header in the request, and are not visible. However, when you come down to the basic technical operations, they work almost the same way: you can do just about anything you could in either method in the other one as well. (multi-part form data are a bit harder on GET, but it could be do-able)</p>
<p>The most important difference, actually, lies in the definitions &#8212; when these HTTP requests were first invented. A POST request is defined to be a request to the server that changes the state of the server. This means, for example, posting a message on a forum, uploading a file, or anything at all that changes (inserts/deletes/updates) the database, the file system, or anything else. A GET request, on the other hand, is defined as a way to retrieve information from the server without making any changes, or a &#8220;query&#8221; as they call it.</p>
<p><strong>Why does it all matter?</strong></p>
<p>Knowing the history of POST and GET requests, you should also be aware that browsers like Firefox and IE are designed with this in mind. When you attempt to Refresh a page (or going Back/Forward to it) that you got from POSTing a form, you get a warning box telling you that POST data will be sent again to the server. This is because a POST request is expected to make a change, and repeating the same request just to view the resulting page is usually not what the users intend to do, or what the developers intend for the users to do.</p>
<p>Unfortunately, on the users point-of-view, this creates a very user-unfriendly situation when web apps aren&#8217;t designed with this in mind. The average internet user does not know the difference between POST and GET requests (many won&#8217;t even be able to tell what an HTML form is), but web developers assume people know what they are doing. Your job, as a web developer, is to make it as less painful as an experience for web users as possible. Back and Forward buttons are the most commonly used features by web users, and you want to design something that works with them, not against them. This is why I&#8217;m an advocate of separating POST and GET requests in PHP.</p>
<p><strong>What do you mean by separating POST and GET requests?</strong></p>
<p>It might not be the best way to phrase it. What I mean is to make only GET requests display anything at all, and POST requests results should always redirect to another page in the form of a GET request. In other words, POST requests always only get sent to &#8220;Controller&#8221; scripts, while GET requests always only get sent to &#8220;View&#8221; scripts.</p>
<p>To make this easier to understand, I will take the example of a project I have done a few years ago, designed in this method. It is a web-based file manager that lets you upload, delete, rename, move files as well as folders.</p>
<p>No AJAX was used in this application (it wasn&#8217;t popular in 2003). All actions are sent as a new POST request to a PHP script on the server. However, there really is only one script file for the &#8220;view&#8221;, called main.php. A handful of other PHP scripts handle all the different actions. When you upload a file, a request is sent to upload.php, and this script will redirect back to main.php in the end, using a Location header.</p>
<p>To handle error messages (or success messages), I use cookies. Back to the uploading example again &#8212; before redirecting to main.php, I set a cookie with the status and message. In main.php, if a cookie is found with this information, a dialogue box displays with the message, and then the cookie gets cleared.</p>
<p>Designed this way, Back and Forward buttons may be used freely without actually corrupting the state of the server. It is true that, for example, if a page was cached, hitting Back may lead you to an old page &#8212; but at least the POST request wouldn&#8217;t be sent again (as POST is what makes changes to the server). Most of the time, implementing some sort of cache-stopping mechanism can stop this from happening. In my file manager example, even dialogue boxes work correctly (would not re-display after showing once), due to the use of cookies.</p>
<p><strong>Some final notes</strong></p>
<p>If you are interested in some additional reading, you can look at the official <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html">HTTP/1.1 method definitions</a>. An interesting part of it is this:</p>
<blockquote><p>The action performed by the POST method might not result in a resource that can be identified by a URI. In this case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the response includes an entity that describes the result.</p>
<p>If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity which describes the status of the request and refers to the new resource, and a Location header (see section 14.30).</p></blockquote>
<p>It looks like that you should be returning a status code of 201 if you are going to redirect to another page using a GET request, after doing your processing in your POST request. I&#8217;m actually not entirely sure what benefits do you get from doing that other than being politically correct about definitions. If anyone knows the answer to this, feel free to post a reply and enlighten me. <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/06/18/separation-of-postget-requests-in-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MVC architecture in PHP development</title>
		<link>http://www.agum.com/web/2007/06/10/mvc-architecture-in-php-development/</link>
		<comments>http://www.agum.com/web/2007/06/10/mvc-architecture-in-php-development/#comments</comments>
		<pubDate>Mon, 11 Jun 2007 00:45:06 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[MVC]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/06/10/mvc-architecture-in-php-development/</guid>
		<description><![CDATA[MVC stands for Model-View-Controller. It is a type of architecture for developing software, recently pretty popular in web applications development. In short, the three things are pretty simple. Model is what interacts with the database, it would be the backend class code for an object-oriented language like PHP, Ruby on Rails, or C++. View is [...]]]></description>
			<content:encoded><![CDATA[<p>MVC stands for Model-View-Controller. It is a type of architecture for developing software, recently pretty popular in web applications development. In short, the three things are pretty simple. Model is what interacts with the database, it would be the backend class code for an object-oriented language like PHP, Ruby on Rails, or C++. View is basically the user interface. Controller is the logic that operates everything in between.</p>
<p>They are easy to explain, but sometimes the concept is a little abstract and it&#8217;s hard to grasp for someone who doesn&#8217;t know what MVC is to begin with. To be honest, all my years in web development I never really understood exactly what MVC is, until recently when I started doing development in Ruby on Rails. In this article, I hope to explain MVC architecture development in PHP terms, so the average web apps programmer may benefit from understanding this powerful architecture.</p>
<p><span id="more-12"></span><strong>MVC and PHP development</strong></p>
<p>The reason I mentioned Ruby on Rails is because you really have to understand how to develop an application with the MVC architecture to do anything at all on RoR. (Next time, I will write another article on RoR &#8212; but this time, I&#8217;ll talk about PHP development.)</p>
<p>The Model-View-Controller separation actually makes a lot of sense, it is actually natural for a developer to divide his/her code that way when working on a reasonably large application. Java has classes, JSP and struts; Ruby on Rails has a built-in MVC structure; but even when PHP doesn&#8217;t have anything like that, it doesn&#8217;t mean you can&#8217;t do it.</p>
<p><strong>The Model</strong></p>
<p>The MVC structure is meant for reasonably-sized applications, using object-oriented coding. The Model part, in a PHP app, would usually be a class (or multiple classes). Fairly often, the class is a representation of a table you store in the database &#8212; member variables are the data columns, and member methods are operations that can be done. As an example, you might have a User class, having variables such as username, password, email address, and other things. Some of its methods might be a new user creation function, a login function, an authentication function, and a logout function.</p>
<p>Later on, we will see how User objects will be used in the Controller part of your application. The Model, in essence, tells you what methods are available &#8212; what <em>can</em> you do to the data in the database. I thought I should just clarify (if it wasn&#8217;t clear already) &#8212; this should be all PHP code, just as what you should do in OO-programming even without MVC. There should be no HTML or any kinds of outputs (redirection, etc.) here. If doing an action means that a redirection is needed or some output is needed, pass it as an argument or a return value. (It&#8217;s fairly basic programming practices, but you&#8217;d be surprised how many web apps programmers didn&#8217;t graduate with a CS degree..)</p>
<p>Here&#8217;s an example of the Model part of your code. Of course, there will be many more classes in a real application. This is just the code is the simplest form, without a lot of the details.</p>
<blockquote>
<pre>class User
{
   var $username;
   var $password;
   var $email;
   function User($u, $p, $e) // constructor
   {
      $this-&gt;username = $u;
      $this-&gt;password = $p;
      $this-&gt;email = $e;
   }
   function create()
   {
      // creates user in the db
   }
   function login()
   {
      // checks against db, does login procedures
   }
   static function authenticate($u, $p)
   {
      // checks against db
   }
   function logout()
   {
      // does logout procedures
   }
}</pre>
</blockquote>
<p><strong>The View</strong></p>
<p>The View, in the simplest words, is the user interface. However, it doesn&#8217;t mean it would be just straight HTML. Minimal PHP logic will need to be used in your application&#8217;s interface a lot of times. For example, if you were to have the main logged-in page say, &#8220;Hello, [username]!&#8221; You would certainly need some PHP code to handle that, right? That is all part of the View. Of course, all the CSS, Javascript would be part of this too.</p>
<p>It is important that whatever PHP code in here is only what needs to be used to display the interface correctly. No additional &#8220;action&#8221; code belongs to the View &#8212; that is the Controller&#8217;s job, which we&#8217;ll see next.</p>
<p>This was easy to understand, but for clarification&#8217;s sake, let&#8217;s see an example anyway. Of course, the following isn&#8217;t even valid XHTML 1.0 (it lacks a DOCTYPE, for instance), but this is just an example.</p>
<blockquote>
<pre>&lt;?php
require_once('User.php');
// makes sure user isn't already logged in
if (User::authenticate($_COOKIE['username'], $_COOKIE['password']))
{
   header(&#8221;Location:/main.php&#8221;);
   exit();
}
?&gt;
&lt;html&gt;
&lt;head&gt;&lt;title&gt;Please login&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Login&lt;/h1&gt;
&lt;?
if ($_GET['error'] == 1)
{
   echo &#8216;Login incorrect. Please try again.&lt;br /&gt;&#8217;;
}
?&gt;
&lt;form action=&#8221;login_action.php&#8221; method=&#8221;post&#8221;&gt;
User: &lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; /&gt;&lt;br /&gt;
Pass: &lt;input type=&#8221;password&#8221; name=&#8221;password&#8221; /&gt;&lt;br /&gt;
&lt;input type=&#8221;submit&#8221; value=&#8221;Login&#8221; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</blockquote>
<p><strong>The Controller</strong></p>
<p>Sometimes it is confusing to understand what the Controller needs to do, if you weren&#8217;t working on an actual application and just reading a book/an article. It would seem like the Model and the View are all you need. So let&#8217;s go back to a concrete PHP example.</p>
<p>Now imagine you have a login page setup. The login HTML form has to submit to somewhere, right? (Even if you&#8217;re using AJAX) You don&#8217;t submit directly to the Model class file (say, User.php), because that file only contains the class code, and no actual procedural code is there, so it won&#8217;t do anything. You certainly don&#8217;t submit directly back to the View file (say, login.php), even if it ends with a .php extension! Because its job is only to display the interface.</p>
<p>This is what the Controller is. Your form will submit to a file, say, login_action.php. In this file, you create an instance of the User class, running whatever initialization you need, and calling the appropriate methods that need to be run (login).</p>
<p>Some developers fall into the temptation to display outputs from the Controller, because it&#8217;s convenient. Imagine, if you had a login form, how easy is it to just print &#8220;Login incorrect&#8221; directly from the Controller PHP code? (assuming you aren&#8217;t using AJAX, for this particular example) It is an option, and I will tell you that many scripts do just that. However, to truly utilize a MVC structure&#8217;s advantage, the Controller (like the Model) should not display any HTML outputs, but rather use redirection. You may use cookies/sessions, database storage, flat file caching, or query string to the View file to store the states of your application; and then you should always let the View take care of displaying outputs, using these stored states.</p>
<p>Now let&#8217;s see an example of a Controller code.</p>
<blockquote>
<pre>&lt;?php
require_once('User.php');
// in reality, a lot more error checking needs to be done.
$currentuser = new User($_POST['username'], $_POST['password'], &#8221;);
if ($currentuser-&gt;login())
{
   // set cookies for login info
   header(&#8221;Location:/main.php&#8221;);
   exit();
}
else
{
   header(&#8221;Location:/login.php?error=1&#8243;);
   exit();
}
?&gt;</pre>
</blockquote>
<p><strong>Conclusion</strong></p>
<p>Using the MVC structure, code becomes a lot easier to understand. For other developers to join in to understand your code, as well as for yourself in the future when you come back to it after a while. Development is also a lot easier because you know exactly where to look for what piece of code. If you were going to change some message displaying in the interface, you only need to go to the View. If your database structure sees a change, such as passwords now encrypting in a different way, you only need to change your Model. The MVC architecture is very powerful and makes your object-oriented web apps development a lot more efficient.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/06/10/mvc-architecture-in-php-development/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web Applications Innovation</title>
		<link>http://www.agum.com/web/2007/06/04/web-applications-innovation/</link>
		<comments>http://www.agum.com/web/2007/06/04/web-applications-innovation/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 06:51:09 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/06/04/web-applications-innovation/</guid>
		<description><![CDATA[Since we talked about web applications last time, I just wanted to say something more. Something I&#8217;ve been telling others in conversations, but never had a place to write in before I started this blog.  
Next-gen web applications really need innovation. If there is one thing I hate about the world wide web and [...]]]></description>
			<content:encoded><![CDATA[<p>Since we talked about web applications last time, I just wanted to say something more. Something I&#8217;ve been telling others in conversations, but never had a place to write in before I started this blog. <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Next-gen web applications really need innovation. If there is one thing I hate about the world wide web and web technologies, it&#8217;s bandwagon-jumpers who only learn the surface of things. There are more than enough web developers (or so-called developers) who only learn the latest tricks and start abusing them. JavaScript tricks and Flash were such things back then.</p>
<p><span id="more-8"></span>With AJAX and DOM scripting, you get those guys too. There are plenty of &#8220;Web 2.0&#8243; companies/web sites out there, and many are simply unnecessary and useless. With small web sites, you can afford to simply ignore their existences. Unfortunately, such lack of innovation also exists in large corporations.</p>
<p>I really hate to say it, but to give you an idea of what I mean: Yahoo falls under this category, especially in comparison with Google.</p>
<p>First of all, I just want to say that I like Yahoo as a company. Yahoo Games are some wonderful stuff that no other sites can replace even today. As for other services like Mail, Maps, and other things, I appreciate their effort to make them better every day.</p>
<p>Let&#8217;s look at Yahoo Mail now. And for comparison&#8217;s sake, we&#8217;ll also be looking at Google&#8217;s Gmail. If you still don&#8217;t know what Yahoo Mail is like today (you probably don&#8217;t use it then?), here&#8217;s a screenshot:</p>
<p><a href="http://www.agum.com/web/wp-content/uploads/2007/06/yahoomail.jpg" title="Yahoo Mail screenshot"><img src="http://www.agum.com/web/wp-content/uploads/2007/06/yahoomail.thumbnail.jpg" title="Yahoo Mail screenshot" alt="Yahoo Mail screenshot" border="0" /><br />
(Click to enlarge picture)<br />
</a></p>
<p>Looks familiar? That&#8217;s right, because it is familiar. That&#8217;s just like Outlook/Outlook Express! It is a great design, and it looks very pretty, I&#8217;ll give you that. If you were shown this UI 5 years ago, you would even think this is a desktop application and wouldn&#8217;t believe it if I told you it was web-based. It&#8217;s basically Outlook Express, with ads.</p>
<p>There is only one thing it lacks &#8212; innovation.  You can argue that from a usability point-of-view, this is a good design because it brings familiarity. Users tend to use their old knowledge to judge a new interface they come across. Being able to bring the desktop application experience entirely to a web application is a good thing. However, is that really all you can do? There are certainly more. So let&#8217;s look at how Google takes its approach at emails.</p>
<p>First, I should tell you (if you don&#8217;t already know) that Gmail came out way before Yahoo Mail released their new AJAX interface &#8212; so you can&#8217;t say that Gmail is better because it came late. Now, let&#8217;s look at a screenshot:</p>
<p><a href="http://www.agum.com/web/wp-content/uploads/2007/06/gmail.JPG" title="Gmail screenshot"><img src="http://www.agum.com/web/wp-content/uploads/2007/06/gmail.thumbnail.JPG" title="Gmail screenshot" alt="Gmail screenshot" border="0" /><br />
(Click to enlarge picture)</a></p>
<p>Gmail chose not to &#8220;duplicate&#8221; an all-too-familiar desktop email program look-and-feel. Instead, they just sticked with a regular web-based email design. However, a few things distinguish Gmail from the rest of the world&#8217;s email services.</p>
<p>1. Threaded conversation. It&#8217;s one of those things where you say, &#8220;Why was email never done this way before?&#8221; or &#8220;How could I ever live without that before?&#8221; Just like Apple says &#8212; the best design is one that goes unnoticed in users. It&#8217;s something that should <em>be</em> that way. Apple&#8217;s done it with iPhone and voicemails. (Why did nobody think of checking voicemails with a GUI and choosing which one to listen to? Why would you have to listen to the first 5 messages from friends before you get to the most important one from your boss?)</p>
<p>Why are there <em>still</em> no other email services that do it this way, after Gmail has done it for so long? If you have ever planned trips with friends, using Reply-All on every response, and getting people&#8217;s replies on the subject and leading to 100-message threads, you will not want anything but Gmail.</p>
<p>This wasn&#8217;t even something that would <em>require</em> the use of AJAX and DOM scripting. Using them just made it all a lot smoother. It&#8217;s just a general new idea, and Google was the one who made it.</p>
<p>2. Labels and searching. Personally, I don&#8217;t use labels as much as I should. Labels are better than folders in all kinds of ways, but I have to admit that many users just don&#8217;t &#8220;get it&#8221; &#8212; they don&#8217;t see how it can be used in place of folders. As for searching, it&#8217;s Google&#8217;s thing. You really can&#8217;t beat Google at searching, and they incorporated it into email, so I don&#8217;t have much to say about that.</p>
<p>3. Instant messaging within email. Yahoo has finally incorporated it now too (yeah, <em>finally</em>). As we all know, though, it&#8217;s <em>coming up</em> with the idea that is the hardest. It&#8217;s only half the work if you just say, &#8220;Hey, those guys did that. Let&#8217;s make that in our product too.&#8221;</p>
<p>All the same thing can be said with Google Maps. Interactive dragging, zooming were all done at Google first. Why did Mapquest, Yahoo Maps, etc. not think of them before? They have been in the mapping business for so much longer. Everybody switched over to Google Maps once it was released. Why? Innovation.</p>
<p><strong>Conclusion</strong></p>
<p>True,  it would be unreasonable to require everyone to be innovated geniuses. And Google is certainly not the only one who has made good stuff from technology. Meebo has done something incredible, and so has many other companies. (By the way, I have read an article before saying how Meebo is what&#8217;s wrong with today&#8217;s web technologies. I happen to disagree with it, but that&#8217;s topic for another day.) If you don&#8217;t try, you&#8217;ll never succeed, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/06/04/web-applications-innovation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#8220;Web 2.0&#8243; and &#8220;Next-gen Web App&#8221;</title>
		<link>http://www.agum.com/web/2007/05/27/web-20-and-next-gen-web-app/</link>
		<comments>http://www.agum.com/web/2007/05/27/web-20-and-next-gen-web-app/#comments</comments>
		<pubDate>Sun, 27 May 2007 10:53:30 +0000</pubDate>
		<dc:creator>Bigi</dc:creator>
		
		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.agum.com/web/2007/05/27/web-20-and-next-gen-web-app/</guid>
		<description><![CDATA[We have had mostly only PHP-related articles lately (even though this claims to be a web dev blog!), so for today let&#8217;s get away from that topic for a little bit and talk about something else.  
You&#8217;ve surely heard of the term &#8220;Web 2.0&#8243;. However, not everybody seems to have the same definition for [...]]]></description>
			<content:encoded><![CDATA[<p>We have had mostly only PHP-related articles lately (even though this claims to be a web dev blog!), so for today let&#8217;s get away from that topic for a little bit and talk about something else. <img src='http://www.agum.com/web/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You&#8217;ve surely heard of the term &#8220;Web 2.0&#8243;. However, not everybody seems to have the same definition for Web 2.0 &#8212; especially when it was just conceptualized. As time progresses, people have gotten more educated. Still, there seems to be many common misconceptions. Let&#8217;s look at them&#8230;</p>
<p><span id="more-7"></span><strong>Web developers</strong>, especially front-end interface developers, often feel that any web applications/web sites that uses AJAX and DOM scripting would be considered Web 2.0. This was particularly true a year or two ago when the term Web 2.0 first became popular in the public. It has a lot to do with the fact that around that timeframe, Google came out with <a href="http://maps.google.com">Google Maps</a> and <a href="http://www.gmail.com">Gmail</a>, both of which implemented a very interactive interface never seen before in other mapping and email services; and they were called Web 2.0. Yes, I was part of the group that fell for this &#8212; before I read more about it, I was convinced that Web 2.0 meant this.</p>
<p><strong>Web site producers</strong> (for the lack of a better term; it means people in charge of creating web sites but not the ones doing the technical work) and <strong>businesses</strong> consider user-based web sites and community-focused networks to be Web 2.0. They consider the earliest instances of Web 2.0 companies to be sites like Amazon (among some others as well), where content is fed to you based on information gathered from others. Wikipedia (user-contributed content) and Friendster (all the social networking sites) are then also considered to be Web 2.0, even though at that time they did not have anything like an AJAX interface.</p>
<p>So why was Google Maps considered to be Web 2.0? From the surface, we see that the most revolutionary thing about Google Maps was the interface, as the interactive dragging and zooming were never seen before at that time. (MSN later on came out with Windows Live Local, soon to be followed by Yahoo Maps and MapQuest as well who also updated their interface to something similar.)</p>
<p>However, Google integrated their normal search to Google Maps, effectively creating a &#8220;mashup&#8221;. You can go to any area on the map, and run a search for any businesses, or even a generic search. Searching for &#8220;pizza&#8221; in San Francisco will yield results of where you can buy pizza. Searching for &#8220;Star Bucks&#8221; in the city can tell you all the store locations of Star Bucks. In addition to this, the Google Maps API let other users make custom applications based on Google Maps. <a href="http://www.trulia.com">Trulia</a> is an excellent (and also one of the earliest) example of that.</p>
<p>Pulling information from various sources, creating a mashup and producing a useful application, define it as a Web 2.0 site.</p>
<p>Emil at friendlybit.com wrote <a href="http://friendlybit.com/tutorial/what-is-web-20-really/">a really good article</a> about the definition of Web 2.0. It basically means that it takes a combination of these things to be considered Web 2.0.</p>
<p><strong>So, &#8220;Next-gen Web App&#8221;?</strong></p>
<p>What do I mean by &#8220;Next-gen Web App&#8221; now? In short, any web applications that make use of an AJAX and DOM scripting interface is a next-gen web app.</p>
<p>Not every web application can take advantage of information mashup and community-focusing. There are applications that are made possible with AJAX and DOM scripting but do not qualify as Web 2.0 because of the above definitions, and I feel that they deserve a special name (for now at least &#8212; before they become commonplace). It&#8217;s something that wasn&#8217;t possible before xmlHttpRequest and DOM scripting were invented, and it&#8217;s revolutionary.</p>
<p>With the power of these two things, software that could only be desktop applications in the past are suddenly possible to make as web applications. <a href="http://docs.google.com">Google Docs &amp; Spreadsheets</a> is a good example. DOM scripting provides a way for developers to do almost any kind of manipulation on elements on a web page displayed by a browser. AJAX provides a way to connect to the server for any processing work needed at any time, without interfering with the interface (with page reloads). Comet lets you do the opposite &#8212; allowing the server to talk to the client when an update is necessary. The entire Office suite is now possible as a web application.</p>
<p>The possibilities are endless because now, almost anything that could be done as a desktop application, can also be done as a web application. <a href="http://www.meebo.com">Meebo</a> implements an IM software as a web app. Some companies are bringing internal applications to web apps. Now, installations, updates, and patches on mass machines are no longer necessary. Simply point your browser to an intranet page to run these apps, they will be the latest and greatest. And thanks to the speed of LAN, these apps run as smooth as if they were a desktop app.</p>
<p>As the average home user&#8217;s internet speed becomes faster and faster, any performance issues due to connection speed will be gone. W3C, along with browser makers like Microsoft, Mozilla and Apple, will be working together to create a stronger implementation of AJAX capabilities (something more robust and defined than relying on just xmlHttpRequest). In the near future, web apps can replace many traditional desktop apps. In my opinion, this is a huge leap in technology; and calling it the &#8220;Next-Gen Web App&#8221; isn&#8217;t too much of an overhype.</p>
<p>Web applications engineers are hot in the coming few years!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.agum.com/web/2007/05/27/web-20-and-next-gen-web-app/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.472 seconds -->
