I have a sublcass that inherits a base class that imports the goog.string class. Given that the subclass inherits the base class does the subclass need to import the goog.string library in order to use it? I am assuming that would be redundant.
// Base class
goog.provide('baseClass')
goog.require('goog.string');
baseClass = function() {
}
// Subclass
goog.provide('subClass')
goog.require('baseClass')
goog.require('goog.string'); // do i need this in order to use goog.string?
baseClass = function() {
}
goog.inherits(subClass.prototype, baseClass);
It isn't required for your code to function now but it definitely causes maintenance headaches if you depend on the 'requires of your dependencies being there. If your super class no longer needs "goog.string" and removes it the 'require then your code breaks. Whether this matter to you is a question of scale, but being explicit about all of your dependencies is generally considered good practice.