See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Readability and Stability

  1. #1
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Readability and Stability

    I just thought I would ask the question about readability and stability in code.

    I found writing code professionally, that the customer doesn't care why code crashes, just I hear about the frustration.

    I have always tried to write stable code but error checking and trapping is mush more important now.

    Also with large libraries (several hundred functions) it has made me much more aware of the issue of maintenance.

    If I cannot figure out what an expression or function does immediately it needs better naming and notes.

    Personally I do not use ;setq end type notes in my code because to me it is like switching from Spanish to English in the same sentence.

    I like VERY descriptive variable and function naming.

    I like short simple functions that do specific things with simple names.

    I like the noun first verb last function naming.

    I separate the command line functions in a library from the generic functions.

    I have libraries of general functions that I load with a function.

    I use LISP shorthand functionality... (I rewrote lisp to include errortrapping and remove the russian prefixes like vla-get...)

    I have a header on top of every file and a lisp browser to search for functions...

    I like the reddick naming convention for variables.

    I try to do the same process every time I write code to make it absolutely easy to read and easy to maintain.

    I would be interested in feedback and your own ways of achieving readability and stability.

    P=
    Last edited by peter; 2017-06-22 at 01:33 AM.
    AutomateCAD

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Readability and Stability

    Thank you for the code you've shared over the years, but you need to provide links or a Peter's web page with details.
    Lisp browser to search for functions? http://help.autodesk.com/view/ACD/20...D-7060F5E16547
    Reddick naming convention for variables? https://ss64.com/access/syntax-naming.html

    I use descriptive variable, function, and lsp file naming. Haven't tried the Prefix and Suffix stuff though.

  3. #3
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: Readability and Stability

    Oh *gag* - including value type in the variable name... years ago when variable names were deliberately short , yeah - intA1, strNm3, etc. But if a variable is named reasonably well that's redundant. A "loop_counter" is an integer, not a string; a "max_distance" is a double not a short; a "description" is a string not a double; a "line_ent" is an entity, not a value.

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Readability and Stability

    Writing lisp for around 30+ years using variable names that make sense is probably a 1st priority making reading easier, I always have points as p1 p2 or pt1 etc I noticed some code with weird naming *sdf* and always worry that it will not work compared to using alphabet I have started more recently making my defuns AHxxx so dont match some one else naming. Like Peter I believe in library use and have recently converted a lot of routines that ask for input using library dcl's that generate coding on the fly. Two lines in code 1st check if loaded 2nd actual call sequence. Most code now is also demand loaded. Most of the code I post is in response to a singular request so have to keep adding some extra defuns form the library. More recent have just started adding extra as attachments.

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Readability and Stability

    I rarely use global variables, but do weird the descriptive names when I do to avoid conflicts with other code by adding characters like *±°×|↑↓↕ before and after them.

  6. #6
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    2

    Default Re: Readability and Stability

    I don't have a web page, but I have posted over 900 times to this forum and to the guilds at least once a day for several years.

    I started coding LISP in 1986 and have been doing it daily since.

    I have written my share of spaghetti code...

    Then I learned structured programming and started creating reuseable functions.

    The functions I name like AttributeValue or AttributeValuePut (the get and put of the save object)

    I found the noun first verb second made my libraries (when alphabetized) easy to maintain.

    I also add errortrap expressions to methods and properties that may cause an error.

    I also design all functions to return T or a value for success and nil for failure.

    As far as lisp variables I too avoid global variables except in the case of recursive functions and of course DBX routines.

    For my naming convention prefixes I use

    Code:
    col = collection (sometimes I just use obj for collections)
    ent = entity
    lst = list
    lstOf = list (of sublists)
    obj = object
    sng = single precision real number
    ss = selection set
    str = string
    I call an entsel return value lstSelection
    ssSelections a selection set
    entSelection or entItem an entity
    objSelection or objItem a vla-object
    strFullName as the fullname of a file
    strFileName as the filename of a file
    lstObjects a list of objects (while I use a lot when I convert a selelction set or collection into a list of objects)
    intCount a counter

    etc...

    I would ask you all if you read my code is it clear when the functions do and what the variables hold?

    When I post to the group I write the base code and then go get the library functions to add to the post that do specific things.

    Most of my functions are super short but I have to expand them because you all do not have my libraries.

    I have hundreds of code samples here at AUGI for you all to review.

    I just wanted to help those new to lisp programming to not only think of making it work... but stable and easy to maintain and read
    AutomateCAD

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Readability and Stability

    Hard to imagine such a gifted coder without a web page, but there's many ways of sharing your code here where we can find it. Add a link to all your posts to your Signature peter's posts and a link to a post for needed library functions for the lisp you post so you don't have to expand them.

    Another way would be writing an article for AUGI on coding with descriptions and links to coding examples on the Lisp Forum. Keep in mind I doubt if much of you code I've saved of your's many years ago could be found on AUGI now.

    Lots of long time followers here who would love to access your deep well of code and from the amount of replies here most of the newer coders aren't sure what this thread is about.

    I use Altervista for free web hosting my page: http://beauford.altervista.org/ which is linked in my signature below where the two sections with the dark gray background (same as my AutoCAD screen) are all AutoCAD related. I'd be willing to help you create a web page if you would like, since it would be a nice lisp resource to have.

  8. #8
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Readability and Stability

    This thread is like VisualLISP 501 or a graduate level understanding.

    I choose to support AUGI and post here.

    Part of the reason AUGI has done well over the years is members chose to post here.

    I am a moderator/administrator here and I could teach LISP on a closed thread.

    What level should I start?

    If I teach a very basic class ( like expression level training) it could take a long time to get tot the really useful code and it may become boring to more advanced coders.

    If I start assuming a very basic understanding, you get to the good stuff faster but you might lose some of the newbies.

    I guess I would be willing to teach a class (or classes) HERE to the membership here if there is an interest.

    Chime in and let me know if you are interested in participating and where you think I should start or topics I could post on.

    P=
    AutomateCAD

  9. #9
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Readability and Stability

    I've seen too many basic lisp classes from ATP here to all over the web. Assume at least an intermediate understanding of lisp. Using an open forum where more experienced users could aide you in assisting those who need help keeping up like in the regular lisp forum.

    It should be broken in to segments like error management, recursion, dialog boxes, etc… that would be archived with routines so we could reference them years from now if we needed.

    Afterwards a beginner class on switching to NET would be nice as well.

  10. #10
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Readability and Stability

    I IM'ed to Opie and he is good with stickie classes with a linked discussion forum.
    That way the class is separated from the discussion.

    I would probably present an AutoLISP 101 and series for the newbies...

    A more advanced VisualLISP 101 and series at the same time.

    I wont waste my time unless I get involvement, but I do not have trouble sharing my expertise as long as it is appreciated.

    I also understand that everyone has their own style and styles evolve over time...

    I will teach my style.

    So far I have two interested participants of different levels.

    All you lurkers who are interested chime in.

    What would you like to learn?
    Last edited by peter; 2017-06-28 at 04:41 AM.
    AutomateCAD

Page 1 of 2 12 LastLast

Similar Threads

  1. Autocad Readability Bias
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2014-07-01, 02:56 PM
  2. Tags readability up then right like dimensions
    By dannysmelcer564090 in forum Revit Architecture - General
    Replies: 0
    Last Post: 2012-06-12, 10:10 PM
  3. Long schedules & readability
    By J. Grouchy in forum Revit Architecture - General
    Replies: 8
    Last Post: 2008-11-12, 02:20 PM
  4. Multileader plan readability
    By rickwingender in forum AutoCAD General
    Replies: 0
    Last Post: 2008-09-22, 03:18 PM
  5. tape measure readability
    By arnie1811 in forum Revit Architecture - Wish List
    Replies: 2
    Last Post: 2004-03-27, 06:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •