Showing posts with label documentation. Show all posts
Showing posts with label documentation. Show all posts

Thursday, May 30, 2013

Nothing in OOP is obvious


Is nothing in OOP obvious to the neophyte?

Here is comment from a class named Observable declared as follows :


   public abstract shared Observable


The documentation for the class contains the following method comment  :

public add-observer

Add an observer to this object's list of observers to be notified. Typically this is only called from the Observer's observe method.


For this to make sense to a neophyte, wouldn't we need TWO variants of PUBLIC, e.g.,

  • MY-PUBLIC-FACE
  • YOUR-PUBLIC-VIEW-OF-ME

corresponding to

  • obj-public (intended for me to call against myself)
  • consumers-public (available as your message sent to me)

??

BTW, that add-observer method is declared as follows :

public  
{Observable.add-observer
    o:Observer,
    error-if-present?:bool = false
}:void


Is the issue the method name ?  Should it be 

   all-ya-all-add-observer-to-me

??

Consider :

   receive-observer

But what in a name prevents a hack ?  One idea : object procedures and functions versus messages.  In such a language, an object never sends itself a message.  If you have a local copy of an object, you can use its public procedures and functions.  If you have a pointer to an object - an object reference - you send only messages.

And what did the documenting author mean by "typically" ?



Saturday, July 28, 2007

Example is the Curl developer's example macro


This little Curl script could be the web developer's best friend.
As a web content language, Curl 5.0 provides a powerful RIA platform. This applet using the macro 'example' might convince you.
The macro 'example' creates a live code example in your browser which will open a child applet window.
First we run the following code snippet as an applet in the Curl IDE, embed it as a web applet or launch it with the Curl RTE with a dbl-click in a file explorer.
{curl 5.0 applet}
{applet license="development"}
{curl-file-attributes character-encoding = "windows-latin-1"}
{import * from CURL.DOC.CONTENT.ACCESSORIES}
{example 
{bold Hello {italic there}! }
}

Example is a Curl macro. The result is a web page in which to execute Curl, revert and save Curl applets. It you know something slicker than this, I would want to see it.
You may notice that in my example I have thrown in a {VBox }
I could hit REVERT and I would be back at the original. Here is the result:



If I like my changes, I can save the code from the web page with 'Save Applet'.
In practical terms this also means the ability to create web-based developer documentation with 'live' code snippets. And the eample maco nests: you can have a nippet which is used to demonstrate another snippet.
Curl comes with a visual test framework, but this little 'example' macro should give you a hint of what is possible in Curl 5.0
Note that 'example' is made available by importing the Curl package
CURL.DOC.CONTENT.ACCESSORIES