Difference between Library and Helper

Asked

Viewed 660 times

8

What differentiates the helper of a library? For example: let’s say I have a class for URL manipulation. I call it and it completes the URL with the site path. That would be a helper?

  • Depends on what you’re calling helper. If it is a helper method, I don’t know if you have a direct relationship between the terms unless a library can be a collection of auxiliary methods, among other things.

  • 1

    Helper is a design standard. Library is a set of structures and functionalities common to a set of applications. I don’t know if it’s worth comparing such different things.

  • I cannot speak in the context of Codeigniter, if it is about him you wish, put the tag identifying this. If it is in a general context, this is what we have already commented.

  • This article is appropriate: http://www.mikesdotnetting.com/article/173/the-difference-between-helpers-and-functions-in-webmatrix

1 answer

9


I never saw the term library (or library) be applied in the specific context of the MVC, even a specific technology using MVC. I’ve seen the term used in generic contexts, which obviously includes MVC. A library is a solution of structures and algorithms, a set of Features related. No doubt it may contain helpers. Eventually a library can be composed only of helpers.

In the context of the helper is something that should be used to organize the application. It is a way to create a canonical version of what needs to be used. It is very common to make a helper when it will be used several times in the application. But eventually it can be used solely and it is created to simplify its use by abstracting the content. This is important when it will create views, which must possess very little logic, so you "hide" this logic in these helpers. The same can be said for controllers.

At least in the context of the MVC helpers, in general, they usually function as snippets to use within views and as services in the controller.

The helper has a better defined function, although it is used essentially for organization. The library is a concept and technical organization and this is its main function: to organize. Changes little in the application if you don’t organize libraries. But changes a lot more if you don’t use helpers. Without helpers you may have redundancy, inconsistency, illegibility, just to name a few problems, in addition to specific problems due to lack of organization.

It may be that some specific MVC technology has a more specialized use and definition. For example:

In Daniel Omine’s commentary an article showing the difference between a helper classic used exclusively in view of ASP.NET MVC (Razor) and a function that can even be used as if it were a helper. Besides there is a semantic reason to choose each one there is a difference in the type of data that each one returns. Certainly the helper has a stricter standard because the framework can do something specific with that.

I did not answer exactly about the difference because, as far as I know, these concepts are not directly comparable. At most one can be part of the other.

I think your example is a helper but you need to see how it was written, used, and what technology it’s used in. Although you find it unlikely, it may be that this class does not have an Auxiliator function in the sense we usually understand.

  • To understand more specifically what you have said - https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html. Please note that through helper URL I can get the base url of my site, the current url, and other functions like redirect.

  • That’s what I figured, so this is it. But note that it is not the content that will define if it is helper or not, it’s because he exists and how he’s used.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.