Software Engineering

About redirects

The web change constantly and content moves around. This article gives a brief overview of the various different options available to you, to make a redirect. Redirects come in two major flavors - clientside and serverside.

Client side

Clientside redirects reside within the HTML documents on the server. There are three basic ways of making these:

  • Manual (or user driven) redirects.
  • Meta headers.
  • Javascript redirects.

Manual

The manual redirects most often used when you really, really wants the users to know, that the page has moved. Instead of doing an automatic redirect, you create a common html page, which informs the user that the page has moved, and provide a link to the new page. In some cases, this redirect-type exists in combination with a timed auto-redirect that upon timeout do the redirect.

MVC for PHP

With the amazing buzz around RubyonRails, everyone seems to be hooked on the Model-View-Controller (or just MVC) paradigm – and do strive to mindlessly implement the ”Ruby way” into other programming languages without too much reflection and thoughts on how to do it. . Even tough most of the efforts I’ve seen so far seem pretty hopeless; I do believe you could actually do something good with MVC and PHP. Let me try to tell you how. My ”systems thinking” is usually in the ”large professional genre” and it’s an absolute requirement that the PHP code developed is Efficient, Secure and Maintainable. To get a decent shoot at these, we really can’t reuse ideas and ideologies from Java or Ruby into PHP – we must adapt them to the strengths, weaknesses and ”php ways” to get a good result.

Coding style

I usually edit more code others made, than I create new files, and while most of the code is in PHP, there’s a huge difference in the coding style applied by different developers, and some styles are much more annoying than others. I do respect that people are different and that is probably more efficient to allow for some degree of personal style than to try to enforce a single common style. If possible try to make standards where all can agree upon them, and where it isn’t possible, don’t force it too hard (on less pressing issues makes it necessary).

Validation: black or white list

When you’re validating data – either client- or serverside – there are basically two strategies you can choose between. You can either blacklist data or white list data. Blacklisting seems to be the most popular way to validate data, but white listing is so much better. Here’s a brief description of the two strategies and why the white listing is better. The black listing strategy is validating you input against a list of characters which are illegal in the input. You can either reject input containing the blacklisted characters or just remove them from the input.