Objects are the objective

Started exploring the use of objects in Javascript, something I had heard of before when referring to computer programming languages but hadn’t really been exposed to while learning them. At first I wasn’t sure how to employ objects, and then I learned about the ability of objects to contain variables and functions in a single container.

I was surprised to hear that objects could contain variables and functions in the same data structure. Then I remembered that I had written functions in AutoLISP that executed other functions. Some of my programs for AutoCAD were built on smaller programs that I wanted to be self-contained instead of piled into one large block of code. For example, a program that organizes a raw text file into a usable list in AutoLISP…

(defun prog04a ()
; file to read
(setq fh1 (open “I:/LISPDATABASE/StatesID.txt” “r”))
; Ignore first line
(setq stnmlist (list ))
; Begin transcribing
(while fh1
(setq nline (read-line fh1))
(if nline
(setq d1 (atoi nline))
(setq d2 (read (read-line fh1)))
(setq d2 (atoi d2))
(setq d3 (read (read-line fh1)))
(setq d4 (read (read-line fh1)))
(setq d4 (atoi d4))
(setq d5 (read (read-line fh1)))
(setq d6 (read (read-line fh1)))
(setq stnmlist (append stnmlist (list (list d1 d2 d3))))
(setq fh1 (close fh1))

…is executed in another program with a call after the list it feeds data into is created.

(defun prog04 ()
; file to read
(setq stnmlist (list ))


(setq fh1 (open “I:/LISPDATABASE/States.txt” “r”))
; Ignore first line
; Begin transcribing
(setq ncolor 0)

Going through some other AutoLISP programs I created I found that I had often created small programs to do some kind of prep work, usually preparing data, that I then used in another program. Most of the time the end program still executed a large amount of code, but the combination of variables and program references stored in a single block reminds me of an object.

I have noticed that objects are different in the sense that they are not executable themselves. My master programs that relied on executing smaller programs first were still programs. They had to be run in order to be useful, whereas I am discovering that an object can be a very complex container of data that is both executable (functions) and static (variables).