Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #18031

Re: Two versions of code - advantages and differences

From Cezary Tomczyk <cezary.tomczyk@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Two versions of code - advantages and differences
Date 2013-01-09 08:34 +0100
Organization Aioe.org NNTP Server
Message-ID <kcj6j1$p6v$1@speranza.aioe.org> (permalink)
References (1 earlier) <1512443.gQHv90F1im@PointedEars.de> <kccqct$ksk$1@speranza.aioe.org> <1603326.gHQpjbgioL@PointedEars.de> <kcfgto$4hj$1@speranza.aioe.org> <1718550.E62eDaYUNW@PointedEars.de>

Show all headers | View raw


W dniu 2013-01-08 12:35, Thomas 'PointedEars' Lahn pisze:
> Cezary Tomczyk wrote:
[...]
>> I was thinking that even if the functions are different then variable
>> name is the same. I thought that JSdoc will catch this, but this doesn't
>> make sense. When both of functions will be used in the same scope then
>> Version 2 will overwrite Version 1.
>
> Not all functions need be documented, so a documentor should consider the
> documentation for a function to be finished when it sees the next “function”
> keyword at the same nesting level.  However, an exception needs to be made
> for extra closures, because the outer function that returns the actual
> function is not the function, and its parameter list does not contain the
> parameters, that you usually want to document.  Yet the identifier is
> assigned the return value of that outer function, and you do want to
> document the identifier if it is globally available or forced by the
> developer to be documented.

I am just playing with JSdoc. Will see how it works.

>>> Your code does not make sense to me at all, regardless of possible
>>> inefficiencies.  You are creating on initialization an ”img” object only
>>> to clone it non-recursively (assuming this works) when the returned
>>> function is called only to skip the “width” and “height” assignment –
>>> seriously?
>>
>> I made a test and seems that creating once img node with properties and
>> clone them later every time is faster than creating new img node and
>> adding new properties. Just a small optimization.
>
> Even if that was so (never trust benchmarks), it adds a dependency on
> Node::cloneNode().

I made (also) benchmark as a standalone test and time I measured using 
simple new Date object.

As for dependency: yes, I know, but in this case there should be no problem.

>>> […] it escapes me here why you would want to insert
>>> the equivalent of “&nbsp;” before and after the image; this should be
>>> done with the “margin” CSS property instead.)
>>
>> Tried to use CSS, but it doesn't work for img. See:
>> http://jsfiddle.net/w7BAu/
>>
>> Tested on Firefox 17.0.1 and IE9 (Windows 7, 64 bit).
>
> AISB, use the “margin” property.

Yes, this may work. However, I need to test it. Thanks.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-03 22:58 +0100
  Re: Two versions of code - advantages and differences Stefan Weiss <krewecherl@gmail.com> - 2013-01-04 00:41 +0100
    Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-04 09:15 +0100
      Re: Two versions of code - advantages and differences Gregor Kofler <usenet@gregorkofler.com> - 2013-01-04 11:26 +0100
        Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-04 14:29 +0100
          Re: Two versions of code - advantages and differences Gregor Kofler <usenet@gregorkofler.com> - 2013-01-04 14:56 +0100
            Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-04 16:52 +0100
    Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-04 09:19 +0100
  Re: Two versions of code - advantages and differences Gregor Kofler <usenet@gregorkofler.com> - 2013-01-04 11:25 +0100
  Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-04 15:31 +0100
    Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 08:37 -0800
      Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-05 18:14 +0100
        Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 10:51 -0800
          Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-05 20:46 +0100
            Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 17:12 -0800
              Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-06 17:43 -0800
              Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-07 03:58 +0100
                Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-06 19:23 -0800
                Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-07 05:19 +0100
    Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-06 22:30 +0100
      Re: Two versions of code - advantages and differences Stefan Weiss <krewecherl@gmail.com> - 2013-01-07 02:35 +0100
        Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-07 22:45 +0100
      Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-07 04:36 +0100
        Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-07 23:06 +0100
          Re: Two versions of code - advantages and differences Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-01-08 12:35 +0100
            Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-09 08:34 +0100
  Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 09:13 -0800
    Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-06 11:09 +0100
      Re: Two versions of code - advantages and differences David Mark <dmark.cinsoft@gmail.com> - 2013-01-06 12:56 -0800
        Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-07 22:53 +0100
  Re: Two versions of code - advantages and differences Luc Yen <luc@goal.tw> - 2013-01-05 12:54 -0800
    Re: Two versions of code - advantages and differences Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-06 21:38 +0100

csiph-web