Skip to content

Instantly share code, notes, and snippets.

View mathifonseca's full-sized avatar

Mathi Fonseca mathifonseca

View GitHub Profile
@mathifonseca
mathifonseca / MVC.md
Last active August 29, 2015 14:06
MVC.md

#MVC = Model-View-Controller

##Contexto La interfaz de usuario es usualmente la parte más frecuentemente modificada de una aplicación interactiva. Por esta razón, es importante mantener las modificaciones a la interfaz de usuario separadas del resto del sistema. Los usuarios pueden querer ver los mismos datos desde distintas perspectivas, como en un gráfico de barras o de torta. Estas representaciones deberían reflejar el mismo estado actual de los datos.

##Problema Cómo se puede mantener la funcionalidad de interaz de usuario separada de la funcionalidad de la aplicación y aún poder responder a acciones del usuario o cambios a los datos de la aplicación? Y cómo pueden crearse, mantenerse y coordinarse las múltiples representaciones de los datos cuando estos cambien?

##Solución El patrón Model-View-Controller (MVC) separa la funcionalidad de aplicación en tres tipos de componentes:

@mathifonseca
mathifonseca / GRAILS - Get configuration from Holders.md
Last active February 9, 2018 12:47
GRAILS - Get configuration from Holders

Since Grails 2.0, the usage of org.codehaus.groovy.grails.commons.ConfigurationHolder has been deprecated, and you get a very annoying warning, even when it is being used by one of your plugins.

The recommended way of getting your config since then has been using dependency injection to get the grailsApplication bean into your controllers or services.

I've found a better (more concise and readable) way to get my configuration. I haven't done any serious research yet, but the only difference at first look is that instead of using DI, I'm getting my configuration from a static method in class grails.util.Holders.

So, here is an example Config.groovy:

@mathifonseca
mathifonseca / note.md
Last active August 29, 2015 14:01
GRAILS - Strange behaviour when having a whitespace in a GSP tag

In Grails 2.3.7, if you accidentally (I can't think of any other reason) leave a white space between the closing bracket and quote of the test attribute of an <g:if> tag, its condition will always evaluate to false.

<g:if test="${1 != 2} ">
     Should be here...
</g:if>
<g:else>
     But it’s here!
</g:else>