Reusable Libraries: Good or Evil?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Kruse

    #1

    Reusable Libraries: Good or Evil?

    Since this topic has come up several times in other threads, I thought I'd
    make a separate thread and gather opinions from (hopefully) a more varied
    range of newsgroup participants.

    What are your thoughts on the development and use of generalized, reusable
    javascript libraries?

    Discussion points:

    1) Is the overhead of a 25k (for example) .js file too much for a typical
    (public) web site? What if it's cached, and used on a number of pages? How
    about if it's used on an Intranet? What if the library is 25k, but the user
    only actually uses about 15k of the code? Is there a limit to acceptable
    size of a reusable library?

    2) Is it beneficial to create a generalized library that contains solutions
    for a wide range of problems, and reuse that library on a number of pages?
    Or should those pages only include the exact functions/code that it needs?

    3) If a library can be created which will solve a complex problem in a way
    that is reusable and can be implemented into a working page by users without
    a lot of javascript knowledge, is this a valid and recommended thing to do?
    Even if the library solves problems an individual user may never encounter
    in their situation, causing the library to grow bigger than it needs to be
    in the given situation?

    4) What are the good points of developing reusable libraries? What are the
    bad points? Which one outweighs the other, and in what situations might the
    opposite be true?

    I'm looking forward to hearing what others in this group think!

    --
    Matt Kruse
    Javascript Toolbox: http://www.mattkruse.com/javascript/


  • Jim Ley

    #2
    Re: Reusable Libraries: Good or Evil?

    On Wed, 19 May 2004 22:48:10 -0500, "Matt Kruse"
    <newsgroups@mat tkruse.com> wrote:
    [color=blue]
    >1) Is the overhead of a 25k (for example) .js file too much for a typical
    >(public) web site? What if it's cached, and used on a number of pages? How
    >about if it's used on an Intranet? What if the library is 25k, but the user
    >only actually uses about 15k of the code? Is there a limit to acceptable
    >size of a reusable library?[/color]

    It's expensive but who cares, I have more problems with the tendency
    of such authors to spread it over 20 script files which impacts
    download performance much more than a few extra k. 75k I'd start to
    worry. The bigger question though is not in absolute size, but in
    overhead it brings to your page, a 5% decrease in time for the user
    probably doesn't matter, a 150% probably does.
    [color=blue]
    >2) Is it beneficial to create a generalized library that contains solutions
    >for a wide range of problems, and reuse that library on a number of pages?[/color]

    This is a difficult problem, the difficulty comes in the need (that I
    believe) to offer sensible degradation in this face of all behaviour,
    this very rarely works well with libraries, and you end up with all
    the degradation code seperate from the library anyway, making it all a
    bit crufty and negating a lot of value in the library.

    My experience of libraries is that they tend to increase the amount of
    script by 10 or 20 times what a specific solution would do, for not a
    whole lot of saved time on the final solution - People tend to spend
    more time playing with features in their library that are never used
    in production code, and the extra complications are rarely tested in
    anger.

    Jim.
    --
    comp.lang.javas cript FAQ - http://jibbering.com/faq/

    Comment

    • Randy Webb

      #3
      Re: Reusable Libraries: Good or Evil?

      Matt Kruse wrote:
      [color=blue]
      > Since this topic has come up several times in other threads, I thought I'd
      > make a separate thread and gather opinions from (hopefully) a more varied
      > range of newsgroup participants.
      >
      > What are your thoughts on the development and use of generalized, reusable
      > javascript libraries?[/color]

      I don't care for them.

      Not sure if it would qualify as a "library" (probably so), but if I ever
      manage to finish my dynamic loading of .js files page, I will put it in
      an external file for use on more than one page. Not for the use of a
      "library" per se, but to ease maintenance.
      [color=blue]
      > Discussion points:
      >
      > 1) Is the overhead of a 25k (for example) .js file too much for a typical
      > (public) web site? What if it's cached, and used on a number of pages? How
      > about if it's used on an Intranet? What if the library is 25k, but the user
      > only actually uses about 15k of the code? Is there a limit to acceptable
      > size of a reusable library?[/color]

      What if they only need 1K of it? 25K is a lot of code. The largest .html
      file I personally possess that is of any use to the internet, is only a
      tad under 10K, and thats the largest. And the majority of that page is
      CSS declarations.
      [color=blue]
      > 2) Is it beneficial to create a generalized library that contains solutions
      > for a wide range of problems, and reuse that library on a number of pages?
      > Or should those pages only include the exact functions/code that it needs?[/color]

      Personally, I prefer a tailored approach to the page.
      [color=blue]
      > 3) If a library can be created which will solve a complex problem in a way
      > that is reusable and can be implemented into a working page by users without
      > a lot of javascript knowledge, is this a valid and recommended thing to do?
      > Even if the library solves problems an individual user may never encounter
      > in their situation, causing the library to grow bigger than it needs to be
      > in the given situation?[/color]

      That is part of my dislike for libraries. The never encountered/used
      code and the lack of understanding of what the author is using. It also
      cuts down on the "discussion " of the use of the code.
      [color=blue]
      > 4) What are the good points of developing reusable libraries? What are the
      > bad points? Which one outweighs the other, and in what situations might the
      > opposite be true?[/color]

      I don't know of any good points, based on my personal beliefs. Doesn't
      make me right, doesn't make me wrong, just means I don't care for them.
      To me, they fall into the category of the proverbial fish. Give a man a
      fish, he eats for a day, teach a man to fish, he eats for life.

      Give a man a library.......

      --
      Randy
      Chance Favors The Prepared Mind
      comp.lang.javas cript FAQ - http://jibbering.com/faq/

      Comment

      • Matt Kruse

        #4
        Re: Reusable Libraries: Good or Evil?

        Randy Webb wrote:[color=blue]
        > What if they only need 1K of it? 25K is a lot of code. The largest
        > .html file I personally possess that is of any use to the internet,
        > is only a tad under 10K, and thats the largest.[/color]

        I would say you're a rare exception to the general rule, then! Most sites on
        the web have 50k of _graphics_ or more. I've had pages on internal
        applications that have over 200k of content alone (yuck). I'm not sure that
        25k of cached javascript - which adds functionality to a page, unlike
        images - is "a lot".
        With faster internet connections and faster computers being used by more and
        more people, I don't know if such a focus on small page sizes and dense
        content really pays off at all.
        [color=blue]
        > I don't know of any good points, based on my personal beliefs.[/color]

        No good points at all?
        What about in an environment where a web app is being developed by a team
        of, say, 15 developers. Most have little javascript knowledge, yet they must
        be able to perform basic javascript validation, implement dynamic select
        lists, implement popup controls for selecting data, tooltips, etc? In that
        case, developing a single library containing the most commonly-used
        functions, with an explanation of how to integrate them into a screen, saves
        considerable development/debugging/troubleshooting time, as well as time
        spent fixing javascript written by people who don't really know how to do
        things correctly. Not everyone can be a master of every technology.
        [color=blue]
        > To me, they fall into the category of the proverbial fish. Give
        > a man a fish, he eats for a day, teach a man to fish, he eats for
        > life.
        > Give a man a library.......[/color]

        Is it fair to expect everyone who wishes to use javascript to fully
        understand how it works, and have the skill and knowledge to implement
        complex functionality?

        Javascript is a tool. If the tool can be used in a "black box" manner,
        allowing people to perform complex tasks with a minimal amount of effort,
        isn't that a good thing? Look at Perl, even in a CGI environment where load
        time and code bloat is a concern - the perl community lives and dies by
        modules. The motto is, there's more than one way to do it, but why reinvent
        something that someone else has already solved in an extremely robust way,
        taking into consideration far more issues than you'll think of? Wouldn't the
        same apply to javascript?

        In fact, I used a library just yesterday for tooltips:

        I knew exactly what I wanted to do, and this did it. It has more
        functionality than I needed, but I was able to implement it in under 15
        minutes and have it work on a wide variety of browsers, and behave exactly
        how I expect. I could have written my own from scratch, but why? This saved
        me considerable time and effort. Why re-invent the wheel, to save a few
        kilobytes of download?

        Is it fair to say that your main objections come down to:
        1) too much extra code included that isn't necessary, increasing page size
        and
        2) Hiding implementation details from developers doesn't allow them to learn
        how to do it themselves
        ?

        --
        Matt Kruse
        Javascript Toolbox: http://www.mattkruse.com/javascript/


        Comment

        • Jim Ley

          #5
          Re: Reusable Libraries: Good or Evil?

          On Thu, 20 May 2004 13:44:49 -0500, "Matt Kruse"
          <newsgroups@mat tkruse.com> wrote:
          [color=blue]
          >Randy Webb wrote:
          >I would say you're a rare exception to the general rule, then! Most sites on
          >the web have 50k of _graphics_ or more.[/color]

          Sure, so the javascript enlarges the site 100 when it could only 2% -
          of course a preprocessor can help with this (at the expense of cross
          page cacheability/reusability.
          [color=blue]
          >With faster internet connections and faster computers being used by more and
          >more people, I don't know if such a focus on small page sizes and dense
          >content really pays off at all.[/color]

          Except we're now paying more for bandwidth than we were 5 years ago -
          10 UKP/mb.
          [color=blue]
          >What about in an environment where a web app is being developed by a team
          >of, say, 15 developers. Most have little javascript knowledge, yet they must
          >be able to perform basic javascript validation, implement dynamic select
          >lists, implement popup controls for selecting data, tooltips, etc?[/color]

          I don't think anyone is arguing that re-using code across pages is
          valuable, and providing code that can be integrated by other people in
          the team is good. But that is not quite the same as always using a
          library. In any case - could you please point me to a product that is
          in the situation you describe, I've never seen one.
          [color=blue]
          >Javascript is a tool. If the tool can be used in a "black box" manner,
          >allowing people to perform complex tasks with a minimal amount of effort,
          >isn't that a good thing?[/color]

          the problem is it can't! it only does half the job, and in an
          environment where you're executing code on unknown systems it's
          dangerous to do that!
          [color=blue]
          >Look at Perl, even in a CGI environment where load
          >time and code bloat is a concern - the perl community lives and dies by
          >modules. The motto is, there's more than one way to do it, but why reinvent
          >something that someone else has already solved in an extremely robust way,
          >taking into consideration far more issues than you'll think of? Wouldn't the
          >same apply to javascript?[/color]

          Perl is a known execution environment, javascript is not, that's the
          key difference libraries start to break when you cannot know what
          you're doing.
          [color=blue]
          >Is it fair to say that your main objections come down to:
          >1) too much extra code included that isn't necessary, increasing page size[/color]

          no, that's a minor detail, and one that can be mostly overcome with
          simple code-coverage preprocessors.
          [color=blue]
          >2) Hiding implementation details from developers doesn't allow them to learn
          >how to do it themselves[/color]

          No, that's the wrong thought of the problem it's hiding the pitfalls
          of your script from those developers so they are not able to correctly
          cope with the script failing.

          Jim.
          --
          comp.lang.javas cript FAQ - http://jibbering.com/faq/

          Comment

          • Andrew Thompson

            #6
            Re: Reusable Libraries: Good or Evil?

            On Thu, 20 May 2004 13:44:49 -0500, Matt Kruse wrote:
            [color=blue]
            > ..This saved
            > me considerable time and effort. Why re-invent the wheel, to save a few
            > kilobytes of download?[/color]

            One person saved three hours(?) on a single
            web design problem, as opposed to 10's
            of thousands of visitors (not) saving a
            few kilobytes on each uncached fetch
            over a period of years...

            Think your math is a bit awry their Matt.

            Quick'n'Dirty (so to speak) might be fine
            for some applications with a small user base
            and/or limited lifespan, but there has to
            come a point when minimal bandwidth and
            high efficiency take precedence over the
            'off the shelf/plug-in' solution.

            --
            Andrew Thompson
            http://www.PhySci.org/ Open-source software suite
            http://www.PhySci.org/codes/ Web & IT Help
            http://www.1point1C.org/ Science & Technology

            Comment

            • Matt Kruse

              #7
              Re: Reusable Libraries: Good or Evil?

              Jim Ley wrote:[color=blue]
              > Except we're now paying more for bandwidth than we were 5 years ago -
              > 10 UKP/mb.[/color]

              I don't pay for bandwidth, so I can't relate ;)
              [color=blue]
              > I don't think anyone is arguing that re-using code across pages is
              > valuable, and providing code that can be integrated by other people in
              > the team is good. But that is not quite the same as always using a
              > library.[/color]

              How is it not?
              By library, I'm talking about a set of reusable functions which provide
              known functionality.
              Even if you tell your developers, "here's 25 validation functions like
              isBlank(), isInteger(), isCurrency(), etc. Use them to validate your input
              fields, rather than writing your own validations from scratch. It's all in
              this js file." That kind of library is very valuable, IMO.
              [color=blue]
              > In any case - could you please point me to a product that is
              > in the situation you describe, I've never seen one.[/color]

              I've worked on several in the last few years for one of the biggest banking
              institutions in the world. Sorry, can't point you to them. But they do
              exist. :)
              [color=blue][color=green]
              >> Javascript is a tool. If the tool can be used in a "black box"
              >> manner, allowing people to perform complex tasks with a minimal
              >> amount of effort, isn't that a good thing?[/color]
              > the problem is it can't! it only does half the job, and in an
              > environment where you're executing code on unknown systems it's
              > dangerous to do that![/color]

              Why do you say it only does half the job?
              For example, my dhtml tree, which is similar to some others:


              To use this, the page author needs to do very little. It degrades nicely,
              and they don't have to worry about browsers without javascript enabled or
              older browsers, etc. Would you say it only does "half the job"? Why?

              Further, developers aren't always executing code on unknown systems. If
              someone is developing for an Intranet for a company that only has IE6 on its
              desktops, the developer can be very sure of the environment. In that case,
              they don't even have to worry about supporting the unknown, and even an
              IE6-specific library could work very well for them and supply them with
              impressive functionality with very little cost.
              [color=blue]
              > Perl is a known execution environment, javascript is not, that's the
              > key difference libraries start to break when you cannot know what
              > you're doing.[/color]

              That's not true - Perl can run on almost any OS, and the modules need to be
              smart enough to take that into account. A module can't simply call a unix
              command to do something - it needs to do detection to determine where it is
              running, what commands are available, how to call them, etc. Similar to
              Javascript. Yet in Perl, relying on 10 modules in your script, which each
              rely on their own modules, is very common. In fact, encouraged.

              And I don't see why libraries need to "start to break" in an unknown
              environment. Shouldn't they degrade nicely?
              [color=blue]
              > No, that's the wrong thought of the problem it's hiding the pitfalls
              > of your script from those developers so they are not able to correctly
              > cope with the script failing.[/color]

              I can see how this might apply in some situations, but I don't think it
              applies to all.

              For example, if you have a dhtml date picker to select a date for a form
              field. If the user has javascript disabled and clicked on the "select date"
              link, nothing will happen. No problem. If javascript is enabled, the library
              is smart enough to figure out what the browser is capable, and use the
              available features to generate the date selector in a way which will work.
              The person using the script in the page doesn't need to worry at all about
              the script failing, if it's written correctly. If the page _depends_ on the
              javascript functionality, then yeah, the author should know how to handle
              failure cases. But, if the javascript is just adding extra functionality to
              make it easier, then the page author shouldn't care if the browser doesn't
              support it - their page will work anyway.

              Are you arguing against the general concept of libraries, or more about how
              _most_ libraries are written and implemented?

              If a reusable javascript library can be written that performs function X,
              and does so correctly on all browsers that support the required features,
              and simply doesn't do anything on browsers which don't have the required
              features, why is that bad?

              And are all your concerns still valid for an internal, intranet web
              application where the environment is known and faster/easier/better
              development is the priority rather than supporting 87 different browsers? Do
              you think libraries add value in those situations?

              --
              Matt Kruse
              Javascript Toolbox: http://www.mattkruse.com/javascript/


              Comment

              • Lee

                #8
                Re: Reusable Libraries: Good or Evil?

                Matt Kruse said:[color=blue]
                >
                >Since this topic has come up several times in other threads, I thought I'd
                >make a separate thread and gather opinions from (hopefully) a more varied
                >range of newsgroup participants.
                >
                >What are your thoughts on the development and use of generalized, reusable
                >javascript libraries?
                >
                >Discussion points:
                >
                >1) Is the overhead of a 25k (for example) .js file too much for a typical
                >(public) web site? What if it's cached, and used on a number of pages? How
                >about if it's used on an Intranet? What if the library is 25k, but the user
                >only actually uses about 15k of the code? Is there a limit to acceptable
                >size of a reusable library?[/color]

                The size probably isn't limited by bandwidth so much as by
                the namespace. I would worry about a user declaring variable
                isBlank, and wiping out not only that library function, but
                several others that rely on it.

                There are solutions for that, of course, but I think I would
                prefer to offer a library of smaller .js "packages" for your
                inexperienced developers to choose from as needed to provide
                validation, tree structures, etc. Each should define few enough
                globals to allow them to become reasonably familiar with them.

                Demanding that they know enough to choose the packages that
                they need doesn't seem unreasonable, to me.

                Comment

                • Matt Kruse

                  #9
                  Re: Reusable Libraries: Good or Evil?

                  Andrew Thompson wrote:[color=blue]
                  > One person saved three hours(?) on a single
                  > web design problem, as opposed to 10's
                  > of thousands of visitors (not) saving a
                  > few kilobytes on each uncached fetch
                  > over a period of years...
                  > Think your math is a bit awry their Matt.[/color]

                  You think? Wow, some of you guys are _really_ concerned about downloading a
                  few extra kilobytes. Why?
                  Do you download with images and css turned off too, to save all that
                  download time?
                  I don't think most of the web-browsing world has the same concerns.
                  Especially considering the weight of many pages these days. Clearly, users
                  prefer a nicer look and extended functionality over minimalist design to
                  save bandwidth. I think the bandwidth concerns are completely unwarranted.
                  [color=blue]
                  > Quick'n'Dirty (so to speak) might be fine
                  > for some applications with a small user base
                  > and/or limited lifespan, but there has to
                  > come a point when minimal bandwidth and
                  > high efficiency take precedence over the
                  > 'off the shelf/plug-in' solution.[/color]

                  In theory, I agree. But I don't think that "point" is anywhere close to
                  being a realistic situation.

                  It's like the people who will work for hours to improve the efficiency of
                  their code, gaining milliseconds here or milliseconds there. It's a fine
                  exercise, but not nearly as important as creating something _useful_. All
                  the good programming and efficiency in the world won't matter at all unless
                  you can build something that people want to use.

                  You can build a minimalist website that is only 10k in weight and has lots
                  of good content, but if your customers all go to your competitors site
                  because it has better navigation, dhtml widgets to help them out, and
                  enhanced functionality, have you gained anything?

                  --
                  Matt Kruse
                  Javascript Toolbox: http://www.mattkruse.com/javascript/


                  Comment

                  • Matt Kruse

                    #10
                    Re: Reusable Libraries: Good or Evil?

                    Lee wrote:[color=blue]
                    > The size probably isn't limited by bandwidth so much as by
                    > the namespace. I would worry about a user declaring variable
                    > isBlank, and wiping out not only that library function, but
                    > several others that rely on it.[/color]

                    True, namespace issues are important. I've seen libraries crash because they
                    rely on a global variable "i" or something. But that's bad design, not a
                    problem with the concept of libraries.
                    I always prepend my global variables and methods with unique text
                    qualifiers, so something like "isBlank" becomes "XX_isBlank ". I typically
                    try to expose only the constructor and possible a couple global variables to
                    keep track of the objects of the type with common names. Every other
                    function name is something no one else would ever use.
                    [color=blue]
                    > There are solutions for that, of course, but I think I would
                    > prefer to offer a library of smaller .js "packages" for your
                    > inexperienced developers to choose from as needed to provide
                    > validation, tree structures, etc.[/color]

                    Are we just playing a semantics game?
                    How would "packages" differ from "libraries" ?

                    When I say "library" I don't refer to these big 100k behemoth libraries
                    which hide all internals of, say, dhtml events and positioning, and replace
                    them with their own custom methods.
                    I'm referring to small, tight, compact files which provide very specific
                    reusable functionality.
                    How is that different from your idea of a "package"?
                    [color=blue]
                    > Demanding that they know enough to choose the packages that
                    > they need doesn't seem unreasonable, to me.[/color]

                    How many projects of over 10 developers have you worked on?
                    I find that javascript knowledge is hard to come by in circles of really
                    good C/Java developers. :)

                    --
                    Matt Kruse
                    Javascript Toolbox: http://www.mattkruse.com/javascript/


                    Comment

                    • Lasse Reichstein Nielsen

                      #11
                      Re: Reusable Libraries: Good or Evil?

                      "Matt Kruse" <newsgroups@mat tkruse.com> writes:
                      [color=blue]
                      > Wow, some of you guys are _really_ concerned about downloading a few
                      > extra kilobytes. Why?[/color]

                      Because users care.
                      <URL:http://www.useit.com/alertbox/sizelimits.html >

                      /L
                      --
                      Lasse Reichstein Nielsen - lrn@hotpop.com
                      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                      'Faith without judgement merely degrades the spirit divine.'

                      Comment

                      • Matt Kruse

                        #12
                        Re: Reusable Libraries: Good or Evil?

                        Lasse Reichstein Nielsen wrote:[color=blue]
                        > Because users care.
                        > <URL:http://www.useit.com/alertbox/sizelimits.html >[/color]

                        That article is 7 years old!

                        Users today aren't usually browsing on 14.4k modems. Cable modems are
                        everywhere, and most dial-ups are at 56k. I suppose if you want to continue
                        catering to _every_ possible user who might be behind on technology by 7
                        years, you could create pages that are 2k.

                        But, software continues to develop, and people do need to catch up. If you
                        have ancient technology, then you can expect ancient performance. New
                        off-the-shelf software today isn't written for Pentium60's with 8MB RAM, so
                        why should we develop on the web for technology of the same era?

                        It's difficult to keep a good grasp on where users are, but I have no doubt
                        that 14.4k modems and 2k page sizes are _not_ the type of stuff we should be
                        worrying about. IMO.

                        --
                        Matt Kruse
                        Javascript Toolbox: http://www.mattkruse.com/javascript/


                        Comment

                        • Lee

                          #13
                          Re: Reusable Libraries: Good or Evil?

                          Matt Kruse said:[color=blue]
                          >
                          >Lee wrote:[/color]
                          [color=blue][color=green]
                          >> There are solutions for that, of course, but I think I would
                          >> prefer to offer a library of smaller .js "packages" for your
                          >> inexperienced developers to choose from as needed to provide
                          >> validation, tree structures, etc.[/color][/color]

                          [color=blue]
                          >Are we just playing a semantics game?
                          >How would "packages" differ from "libraries" ?
                          >
                          >When I say "library" I don't refer to these big 100k behemoth libraries
                          >which hide all internals of, say, dhtml events and positioning, and replace
                          >them with their own custom methods.
                          >I'm referring to small, tight, compact files which provide very specific
                          >reusable functionality.
                          >How is that different from your idea of a "package"?[/color]

                          That's what I mean.
                          Your first post gave the impression that you were putting
                          all of your functionality into one large file.

                          [color=blue][color=green]
                          >> Demanding that they know enough to choose the packages that
                          >> they need doesn't seem unreasonable, to me.[/color]
                          >
                          >How many projects of over 10 developers have you worked on?
                          >I find that javascript knowledge is hard to come by in circles of really
                          >good C/Java developers. :)[/color]

                          But if they can program in any language, they should
                          be able to choose which package (ie, small library)
                          they need to include. I don't think we disagree there.

                          Comment

                          • Lasse Reichstein Nielsen

                            #14
                            Re: Reusable Libraries: Good or Evil?

                            "Matt Kruse" <newsgroups@mat tkruse.com> writes:
                            [color=blue]
                            > Lasse Reichstein Nielsen wrote:[/color]
                            [color=blue][color=green]
                            >> <URL:http://www.useit.com/alertbox/sizelimits.html >[/color][/color]
                            [color=blue]
                            > That article is 7 years old![/color]

                            Maybe, but it links to this page:
                            <URL:http://www.useit.com/alertbox/9703a.html>
                            which was updated four months ago. More people have fast connections,
                            but the majority are still using modems. The conclusion stands.
                            [color=blue]
                            > Users today aren't usually browsing on 14.4k modems.[/color]

                            The page assumes 33.6k modems. Todays modem users probably use 56.6k
                            modems. So, you can, perhaps, double the size.
                            [color=blue]
                            > But, software continues to develop, and people do need to catch up. If you
                            > have ancient technology, then you can expect ancient performance.[/color]

                            If the majority has ancient technology, then you should design for it,
                            if your pages are to be used commercially.

                            /L
                            --
                            Lasse Reichstein Nielsen - lrn@hotpop.com
                            DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                            'Faith without judgement merely degrades the spirit divine.'

                            Comment

                            • Matt Kruse

                              #15
                              Re: Reusable Libraries: Good or Evil?

                              Lee wrote:[color=blue]
                              > That's what I mean.
                              > Your first post gave the impression that you were putting
                              > all of your functionality into one large file.[/color]

                              Ah, certainly not. Perhaps that did cause some confusion.
                              By using 'libraries' I mean that if the developer wants form validation,
                              they include validations.js. If they want a tree, they include tree.js. If
                              they want to do tooltips, they include tooltips.js. Each library has its own
                              function and is stand-alone.

                              The only problem I have with this is that if each library has some similar
                              core code, that core functionality is duplicated in the page. I've overcome
                              this in the past by having dependencies defined, and a server-side script
                              which parses dependencies on the page and only includes those core functions
                              once when delivering the .js files. It worked very well.
                              [color=blue]
                              > But if they can program in any language, they should
                              > be able to choose which package (ie, small library)
                              > they need to include. I don't think we disagree there.[/color]

                              I agree.
                              But one of my primary reasons for writing and encouraging library use is
                              that so much _really_ bad javascript is out there.

                              Debate about certain techniques all you want, but if you find code that is
                              filled with evals and document.all and all that mess, and you know it's bad,
                              it becomes really beneficial to write stuff well once, and just tell
                              everyone else to use it :)

                              --
                              Matt Kruse
                              Javascript Toolbox: http://www.mattkruse.com/javascript/


                              Comment

                              Working...