Poll

Which of these is easier for [you] to read

fun_1
fun_2

Author Topic: Reading Code  (Read 5010 times)

0 Members and 1 Guest are viewing this topic.

wizman

  • Bull Frog
  • Posts: 290
Re: Reading Code
« Reply #15 on: March 13, 2010, 06:51:57 AM »
Thanks Kerry, I consider this more as a guidance.  :-)

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: Reading Code
« Reply #16 on: March 13, 2010, 07:45:26 AM »
The VLIDE formats fun_1 with the following end-of-line style:

Code: [Select]
(defun fun_1  (l n / a b c d)
  (while (setq d l)
    (while (< (setq b (length a)) n)
      (setq a (cons (nth b d) a)
            l (cdr l)))
    (setq c (cons (reverse a) c)
          a nil))
  (reverse c))

I think this is clearer for me  :-)

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Reading Code
« Reply #17 on: March 13, 2010, 07:49:59 AM »
fun_1
James Buzbee
Windows 8

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8785
  • AKA Daniel
Re: Reading Code
« Reply #18 on: March 13, 2010, 07:52:22 AM »
fun_2

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Reading Code
« Reply #19 on: March 13, 2010, 09:10:35 AM »
of the options posted fun_2

my real preference tho is subtly different:

Code: [Select]
(defun fun_3 ( l n / a b c d )
    (while (setq d l)
        (while (< (setq b (length a)) n)
            (setq
                a (cons (nth b d) a)
                l (cdr l)
            )
        )
        (setq
            c (cons (reverse a) c)
            a nil
        )
    )
    (reverse c)
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10658
Re: Reading Code
« Reply #20 on: March 13, 2010, 12:58:54 PM »
I can see you're point about the (re)formating.

My use of the `end-of-line' style developed when i started to get better with Vim and my studies of Scheme came about. I can "move around" better in most cases with the `end-of-line' style in Vim. Most if not all of scheme code is written in the `end-of-line' style.

If i take your two functions as posted; some days it can go either way but i wold say that fun_2 is easier to read more often than fun_1 because i have more experiences with the fun_2 style (posted, and learning).

When im developing apps on my own i use fun_1 style for several reasons. -e.g. i can either "fold up" regions of code quicker or i can ignore those regions like black-boxes.

So what are we getting at? Would we like to see only code posted in fun_2 type of style (It is the recommended style Autodesk recommends)?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reading Code
« Reply #21 on: March 15, 2010, 06:42:45 AM »
< .. >
So what are we getting at? Would we like to see only code posted in fun_2 type of style (It is the recommended style Autodesk recommends)?

Thanks John.
I've tried the endOfLineClosure formatting as well but found I had trouble breathing when reading ... from not having the the code blocks obvious ... particularly on larger files.
BUT, to each his own :)

I'm sure NOT trying to establish a forum standard ... just seeing how many people care enough to post about the issue.

 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.