views:

203

answers:

3

In a lot of frameworks/AMS/CMS I see folders of "helper" scripts and classes. What exactly do helper scripts and classes do? What is their specific purpose. Is that defined by the developer or is their a standard for their function?

+3  A: 

I know that it means classes that help you in performing your tasks. It may be parsing a String in a specific way or some general purpose calculation one needs in various parts of its code.

Usually in Java (don't know php) they take the form of a bunch of static methods in a class named Util, or at least that's how I've always seen it.

From wikipedia

Helper classes are a term given to classes that are used to assist in providing some functionality, though that functionality isn't the main goal of the application.

Alberto Zaccagni
+2  A: 

Helper classes/scripts, in general, are utilities that are used by an application to perform certain tasks. Usually, these classes are created to centralize common task logic that is performed again and again throughout the application.

These utilities are often very specific, and perform 'actions' on data or objects within the application.

Common examples would be string manipulation, input parsing, encryption/decryption utilities, or mathematical calculations.

Jay S
+1  A: 

To add to what Montecristo says. Helpers make writing complex code easier by doing most of the work for you. For example in the PHP framework symfony, they have whats called Javascript helpers. These helpers wrap the API provided by the prototype library which makes creating AJAX calls much faster and easier.

Here is an example of a javascript helper:

<div id="feedback"></div>
<div id="indicator" style="display: none">Loading...</div>
<?php echo link_to_remote('Delete this post', array(
    'update'   => 'feedback',
    'url'      => 'post/delete?id='.$post->getId(),
    'loading'  => visual_effect('appear', 'indicator'),
    'complete' => visual_effect('fade', 'indicator').
                  visual_effect('highlight', 'feedback'),
)) ?>
Peter D