Sign up for our newsletter

Email Address:

We endorse and use:

We use Code Spaces for our SVN Repository
We use nopCommerce for our open source e-commerce solutions
We use Umbraco for our open source CMS solutions
We use SilverStripe for our open source CMS solutions
We use SourceForge for our open source project hosting
We use the 960.gs css grid for our projects

Valid CSS!

Valid HTML 4.01 Transitional

Softly softly, catchee monkey...

Posted by Ed on 19 July 2009 | 0 Comments

Tags: , , , , , , ,

A while back, I worked on a project for a software house for a big on-line application and every time we added some functionality or logic, the project manager always said 'and make it soft'.

So what did he mean by 'make it soft', what impact did it have on the project and most importantly, why would you be interested?

Let's do a little background.

When you write something in a computer program, you invariably have to communicate some message to the user. This could be the web page content, a response to an activity, interaction or selection you have made or some messages, error or otherwise.

The 'make it soft' requirement is now very important. Take this example.

if (SomeErrorCondition)
{
echo 'ErrorMessage'; / Response.Write("Error Message");
}

This is very common practice and works fine. But say somebody decides this isn't a particularly meaningful error message and wants it to be "Please select something". Ok, this isn't so bad in PHP or ASP3 [I'm not picking on anyone particularly here. This is aimed at all lazy programmers!] but in .NET you have to change the source code, recompile, upload the .dll (at least). A world of pain.

So how do we get round this? Well, it's simple, and I guess most programmers know this anyway, but you put the string in a file that can easily be read and edited. This could be .txt, .XML, .csv, in a database or an .ini file. Note: Using web.config isn't a good place for this content BTW.

The way I do this in c#/.net for example, is to create a few XML files. I then have a few methods in my utility class that get values from nodes (defined by XPath) in the xml file, that returns a string that I can either output to somewhere appropriate in the markup or use String.Format() to output something meaningful like:

string s1 = "user name";
string s2 = "account";
String.Format("Please enter your {0} in the {1} field.", s1, s2);

So what impact will hard coding values have on your project? Well, apart from it being bad practice and also a little lazy, it can add to the cost of site updates. It may also create situations of inflexibility or mis-understanding in your web site where messages become out of sync with changes to content . This can't be good. The biggest thing of all, is having to pay the developer to change a line of text, in an application, that he didn't structure appropriately.

Worst of all is where people hard code things like Literal.Text = '<p>Sorry, you can't do that</p>'; This isn't good.

I hate seeing this approach in source code. Considering how easy it is to do better, I can't understand why programmers don't just do it as a matter of course.

However you decide to do this, the important thing is that when you need to change a message or content or ant [potentially] volative text in a web site or application, you should be able to change it without changing any source code.

And most importantly, if someone is building a web site for you, make sure they make as much of the text as 'soft' as possible. It will save everyone time and money in the long run.

.


Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments

Text size: Aa Bb Cc

Follow us on...

N-WebDesign news

Terms :: Privacy :: © N-Web Design 2012