Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Common Lisp Object System (CLOS) Syntax

  1. #11
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Common Lisp Object System (CLOS) Syntax

    Quote Originally Posted by peter View Post
    The other thing I have been promoting is a verb last function or sub naming convention like SplashScreenShow compared to ShowSplashScreen.
    I'm with you on this. It also follows the normal OO naming in C#/VB.Net (or for that matter all dot-notation OO languages), e.g. SplashScreen.Show(). Though if you convert it into a CLOS method, you'd get one of 2 versions:
    • General purpose: (InvokeMethod SplashScreen 'Show)
    • Specific method: (Show SplashScreen)



    Quote Originally Posted by peter View Post
    WHat is you feeling on

    Dim objDatabase as Database

    or

    Dim dataBase as Database
    Not too sure here. Personally I don't feel that the obj prefix does anything to help, I actually think it may detract from the understanding (e.g. is it a database of objects - i.e. entities in the DWG; or is the variable an object type, just per chance containing a "database"?)

    Also the word "database" doesn't say much beyond that it's a query-able collection with multiple key(s) and value(s) per item, probably indexed on all keys and some values. Here also there's a bit ambiguous even from the start, is it:
    • The "database" of entities in the drawing - i.e. a collection object containing references to each entity (graphical or otherwise)
    • A database like a relational DB with multiple tables, relationships, built-in queries, etc.


    If the 1st, I'd probably prefer to call it something like DrawingObjects (or perhaps even ActiveDrawingDatabase), if the 2nd I'd go with <MyDescriptiveNameHere>Database.

    Quote Originally Posted by peter View Post
    It is a place to start.
    It definitely is a very good place to start! Would need to extend that a bit to also allow for invoking methods. Not to mention, probably needs some inquiry functions too - to find out what object classes are available as well as what properties and the details around their methods. I'd suggest not going with the same approach as vl-dump-object, but rather use a normal LispFunction which returns a list, e.g.: A list of (<property name> . <value>) pairs for the PropertyInspect function, a list of (<method name> (<arg1 type> <arg2 type> ... <argN type>) <return type>) for the MethodInspect function. That way, if the Lisp user wanted to list these things to the text screen it would be a simple task - it just allows for much more in the shape of actually useful info for Lisp.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

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

    Default Re: Common Lisp Object System (CLOS) Syntax

    Not too sure here. Personally I don't feel that the obj prefix does anything to help, I actually think it may detract from the understanding (e.g. is it a database of objects - i.e. entities in the DWG; or is the variable an object type, just per chance containing a "database"?)
    All the obj Prefix does for me is allow me to create an instance of a class with a slightly different name than the class name.

    Dim objDatabase as Database

    It would have been nice if the developers who named the classes would have included the name Class in their name like

    DatabaseClass

    so we could have had the ability to name them

    Dim Database as DatabaseClass

    I actually like the name Active and have a library like the AutoCAD interop files that have things like

    Active.database

    I suppose I could use the Class name in my names

    Dim DatabaseClass as Database

    I have seen the lower case first letter method. (That is my first choice after sing Reddick)

    Dim database as Database

    or finally

    Dim dbActive as Database

    Then you need to categorize all of the objects by prefix and ms frowns on the reddick naming convention prefixes now.

    I actually like them and think they make my code more readable.

    I absolutely do not like abbreviations in my code.

    Between the Full Descriptive Names like you mentioned, lowercase first letter, or prefixes which do you prefer?

    Peter
    AutomateCAD

  3. #13
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Common Lisp Object System (CLOS) Syntax

    Quote Originally Posted by peter View Post
    It would have been nice if the developers who named the classes would have included the name Class in their name like

    DatabaseClass

    so we could have had the ability to name them

    Dim Database as DatabaseClass
    That was actually a convention with Pascal. You'd place a T prefix on the type definition, i.e. the class definition would be named something like TDatabase, then your instance variable could be just Database, and a Pointer to an instance would have a P prefix. It's not needed (as the same name rules apply as in VB/C# - letters and underscore, numbers only after first character), but most of the built-in library was done this way (especially TurboPascal and later Delphi, even these days FreePascal and Lazarus still use the same convention), so generally it was adopted as a convention. Here's the interface section (note Pascal splits the interface & implementation like C++ does, though not in seperate files) of FreePascal's standard library's Database connection class: http://www.freepascal.org/docs-html/...tdatabase.html

    Actually it's a recommended naming convention to use small letters to start a variable's name in C#, and not use any acronyms. So for your example it's actually more accepted to use something like DatabaseObject than objDatabase (Hungarian Naming): 2 reasons - (1) obj is an acronym; (2) the word order is not as per English grammar (unless Database is the subject and Object is the "object" in the "sentence").

    And this ambiguity is why I don't like including the type into the variable's name, it doesn't always happen, but when it does it confuses the hell out of me:

    • dbObject (I read this as DatabaseObject)
    • objDatabase (and this as ObjectDatabase)

    But because it's Hungarian Naming I know that the prefix actually refers to the "type" - so the way I read it is probably "wrong". In both cases I'm unsure if it is a database containing objects, or a variable which is an object instance of a database class. Especially if the abbreviated prefix Hungarian Notation is used, or taken too far like in objDb or dbObj. At least when the full word is used, I can "understand" it better - at least I hope so.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  4. #14
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Common Lisp Object System (CLOS) Syntax

    Actually, we're slightly missing the issue of this thread. Are we referring to how to name variables or what CLOS conventions are? Because they're a bit different from C# - seeing as CLOS works differently, a method in CLOS is more like an Extension Method in C# (well usually) in that one method definition may be applied to multiple CLOS classes without needing inheritance.

    But even in Lisp it's recommended not to name variable according to their content, rather name them according to their INtent: http://google-styleguide.googlecode....t,_not_content

    So if you want a "selectionset of lines" rather call the variable "lines" than "selectionset". I know lot's of use have done the exact opposite (myself included), but it does make a lot of sense - it conveys the purpose of the code to the reader instead of the implementation (which should be evident by the code itself already, i.e. you use ssname on the lines variable so it must contain a selection set and not a list).

    The adding of type (like with Hungarian Notation or even the full grammatical naming) is basically joining the intent and the content into one name. If that's a good thing I'm not too sure, sometimes it "might be" (e.g. having a dialog with both a Username textbox and a Username drop-down-selection might require something like userNameTextBox and userNameDropDown), but I'm not convinced that it should be a convention for the general case.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

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

    Default Re: Common Lisp Object System (CLOS) Syntax

    I have decided to use the lowercase letter to designate the instances of classes.

    Dim database as Database


    I still like using the Hungarian notation for local numbers and strings.

    strFileName, intItem, dblFactor etc...

    Peter
    AutomateCAD

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 17
    Last Post: 2014-02-17, 07:18 PM
  2. 2013: Common Coordinate System - Large Site Model
    By Limbatus in forum Revit Architecture - General
    Replies: 3
    Last Post: 2013-08-01, 08:53 PM
  3. Lisp to add an MText object that contains an object property
    By sheila.bjerreskov717262 in forum AutoLISP
    Replies: 7
    Last Post: 2013-07-22, 05:58 PM
  4. Replies: 10
    Last Post: 2006-10-25, 09:33 PM
  5. New to File System Object
    By T_Livingston in forum VBA/COM Interop
    Replies: 5
    Last Post: 2006-05-24, 01:35 PM

Posting Permissions

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