Posts Tagged ‘Write’

PHP:Write Clean Logic Statements

Monday, June 30th, 2008

Example 1: Unclean Conditional Logic

<?php
if($userLoggedIn) {
// Hundreds of lines of code
}else{
exit();
}
?>

The above statement seems straight forward, but it’s flawed for the reason that the developer is giving this conditional block too much responsibility. I know that might sound a little weird, but stay with me.

The type of conditional organization above makes for unnecessarily complex code to both interpret and maintain. A brace that’s paired with a control structure hundreds of lines above it won’t always be intuitive for developers to locate. I prefer the style of conditional logic in example 1.2, which inversely solves the previous example. Let’s take a look.

Example 2: Clean Conditional Logic

<?php

if(!$userLoggedIn) {
exit();

}

// Hundreds of lines of code

?>

This conditional statement is more concise and easier to understand. Instead of stating: “if my condition is met, perform hundreds of operations, else exit the script”, it’s saying “if my condition is not met, exit the script. Otherwise, I don’t care about what happens after that. I am only concerned with stopping execution”. So, by doing this, you’ve limited the operations that a given control structure has been tasked with, and that will help other developers quickly understand your code.

Javascript:How to convert string to ASCII number sequence in JavaScript

Monday, June 30th, 2008

<script type=”text/javascript”>
var str = “Hello World!”
var res = “”
for (i=0;i < str.length; i++) {
res += str.charCodeAt(i) + ‘,’;
}
res = res.substr(0, res.length - 1);
//Result: 72,101,108,108,111,32,87,111,114,108,100,33
document.write(res);
</script>

How to convert ASCII number to string in JavaScript

Monday, June 30th, 2008

<script type=”text/javascript”>
// outputs: “Hello World!”
document.write(String.fromCharCode(72,101,108,108,111,32,87,111,114,108,100,33));
</script>

7 tips to writing effective web copy

Monday, June 23rd, 2008

When preparing content for your website, it’s important to remember that writing for the web is very different than writing for print. You need to get your point across quickly and engage your readers before you lose them.

Here are some quick tips to get the best results from your web copy:

Write Compelling Headlines
Always start with a relevant, attention grabbing headline - it can make the difference between the user feeling compelled to read more or choosing to ignore your page. Use sub-headings to define different sections of your content and help your readers locate the information they are looking for.

Make it Short, Sweet and Scannable
In general, people don’t really ‘read’ on the web, they ’scan’. Web readers are impatient - they want quick and easy access to the information they are looking for. Write succinct paragraphs and use bullet points and lists to break your content into scannable chunks.

Emphasise important words
Use Bold and italics to draw attention to important words. This helps improve the ’scanability’ of your content by ensuring the user is drawn to important words.

Use a Conversational Style
Keep it personal and avoid the marketing hype, it doesn’t go down well online. Write as though you were talking in person to your reader.

Build Trust
Establish trust and credibility with your readers by featuring testimonials and case studies. Have you read about the psychological phenomenon of Social Proof? Simply put, it’s when people form their opinions based on the opinions of others. Testimonials can be a very powerful tool for your website.

Use images
The old adage ‘A picture tells 1000 words’ is still true - but don’t go cliché. Photos of smiling, happy business people are overused and ineffective. Consider including some professional photos of your staff, customers, premises or products instead. You can also source suitable and low cost imagery on stock photography websites such as istock.

Consider Layout
Although multi-column content layout is common in print material, single column layouts work best on the web. Web layouts should be clean, simple and uncluttered.

Write Title Tags with Two Audiences in Mind

Thursday, June 19th, 2008

First and foremost, you’re writing a title tag for the people who will visit your site or have a subscription to your feed. Title tags that are short, snappy, on-topic and catchy are imperative. You also want to think about search engines when you title your posts, since the engines can help to drive traffic to your blog. A great way to do this is to write the post and the title first, then run a few searches at Overture, WordTracker & KeywordDiscovery to see if there is a phrasing or ordering that can better help you to target “searched for” terms.
-