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.
Just discovered MiniPage thanks to this. Thanks a lot :)
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:
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:
Coffeescript will do a
var CREDIT_CARD = '1'
inside the scope of theFormVaildator
definition, soCREDIT_CARD
will only be accessible from the classes methods, and not made public through the instances.