Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are helper classes and scripts?

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?

like image 374
Graham Avatar asked Jun 03 '09 14:06

Graham


People also ask

What is a helper script?

Helper scripts, or template modules, are helper files that can make your templates more efficient by performing specific functions. For example, you can use helper scripts to interpret resource metadata, create files, and launch services.

What are helper classes in PHP?

Helper classes are usually a sign of lack of knowledge about the Model's problem domain and considered an AntiPattern (or at least a Code Smell) by many. Move methods where they belong, e.g. on the objects on which properties they operate on, instead of collecting remotely related functions in static classes.


2 Answers

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.

like image 21
Alberto Zaccagni Avatar answered Sep 20 '22 17:09

Alberto Zaccagni


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.

like image 119
Jay S Avatar answered Sep 22 '22 17:09

Jay S