Re: [WebDNA] How to use [function]

This WebDNA talk-list message is from

2012


It keeps the original formatting.
numero = 108668
interpreted = N
texte = --Apple-Mail-1--565420559 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Yay Lawrence! First person to brave posting a webdna question on = stackoverflow (SO)! If we keep it up, we'll get our own tag there! = http://stackoverflow.com/questions/9398280/how-to-use-function-in-webdna/9= 399046#9399046 Toby, hope you don't mind I posted your example code in my reply to = Lawrence there ^^^. I would have given you direct credit, but then it might have been = confusing to readers on SO.. that were were referencing a conversation = in another thread. > I'm trying to understand in which case I should use the [function] or = not. Lawrence,=20 I would say that Ken is right ... that if you do not know you want = something (like a [function]), then better to avoid adding complexity = just because you think you are supposed to do it with complexity). That = will just make life harder. =20 Growing coding skills is organic.. they come naturally from just doing; = no use forcing the process. There are several reasons to use [function], .. at least these are some = reasons: 1). to make your code easier to read 2). to make your code easier to maintain 3). to remove unwanted white space from your code 4.) to make your code easier to write=20 (once you have done the extra work to set up a bunch of = functions to do various tasks, in a complicated site, then writing new = code to use those functions is much faster/easier! You just call the = functions!) You can think of function like an [include].. it effectively lets you = put a bunch of code at one spot in your page.. with just one short line = (the function call). I like to use functions like that... as an include... where I often put = the function definition even in the same file (if that function's code = is unique to just that page), ...but I put the function definition up at = the top of the page, out of the way, and NOT in the spot where the call = to the function is, where it would make my code harder to read. It is also good to use functions like Toby said, as a way to do the same = thing over and over again without writing the same code over and over. = That makes your code easier to maintain. If there is some change = required later (like the client now wants an ordered list (
    ) instead = of an un-ordered list (