What are helper classes and scripts?

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

+4
source share
3 answers

Helper classes / scripts, in general, are utilities that the application uses to perform certain tasks. Typically, these classes are created to centralize the general logic of tasks, which runs over and over throughout the application.

These utilities are often very specific and perform "actions" on data or objects in the application.

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

+7
source

I know that this means classes that will help you with your tasks . This can be String parsing in a certain way or some general purpose calculation that is required in various parts of its code.

Usually in Java (I don’t know PHP), they take the form of a bunch of static methods in a class called Util, or at least as I always saw it.

From Wikipedia

Helper classes are the term, classes that are used to help provide some functionality, although this functionality is not the main purpose of the application.

+6
source

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

Here is an example 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'), )) ?> 
+1
source

Source: https://habr.com/ru/post/1285676/


All Articles