Joined August 2013
·

Emmanuel Joubaud

Melbourne
·
·
·

Posted to Constants in CoffeeScript over 1 year ago

This would add them to the prototype. In case you'd need to access it from outside the methods of the class, you would do it through the instance, which is counter-intuitive in most languages.

Another way to go is:

class FormValidator
  @CREDIT_CARD: '1'  # or @CREDIT_CARD = '1', generates the same thing

  show: ( ) ->
    if @input.val() == @constructor.CREDIT_CARD

That way the constant is tied to the constructor, not the prototype. And it's accessible from outside with FormValidation.CREDIT_CARD, kinda the way you'd expect a Ruby constant to be.

Another alternative is:

class FormValidator
  CREDIT_CARD = '1'

  validate: ( ) ->
    if @input.val() == CREDIT_CARD

Coffeescript will do a var CREDIT_CARD = '1' inside the scope of the FormVaildator definition, so CREDIT_CARD will only be accessible from the classes methods, and not made public through the instances.

Posted to Bootstrap without all the debt over 1 year ago

A framework is almost by definition a dependency that you can't remove without rewriting almost all your app. Trying to abstract over such a fundamental foundation of your site is a highway to hell:

1/ you create your own CSS DSL over Bootstrap so you loose most of the advantages of a framework: productivity and readability due to standardization

2/ you will most likely recreate about the same structure dependencies with your own class names, and the same amount of presentational markup anyway. For the extra effort, you just get the illusion of a slightly more presentation-independant markup. Markup that's presentation-independant enough that it turns out to be worth the effort when you redesign is not a realistic goal anyway in the current state of CSS.

3/ Incidentally you'll fall get some crazy long selectors with the extensive use of @extend.

On the principle it's a bit like trying to abstracting the programmation language away by using a home-made one on top of it, in case you want to change the underlying one some day.

There are some dependencies that should be tied to your app. Choose them carefully.

Posted to Meteor Starter Pack over 1 year ago

Just discovered MiniPage thanks to this. Thanks a lot :)

Achievements
71 Karma
0 Total ProTip Views