Monday, December 13, 2010

ObjectIcon HttpServer without minify-me

Here are a few notes on code in ObjectIcon 2.4 httpclient.icn and related files.
class HttpClient(NetClient)

# and in netclient.icn

class NetClient(Connectable, SetFields)

# in connectable.icn
package util

class Connectable()
My first thought is that Connectable - with no parents, no imports, would have served so much better as a Trait in a traits package. Here is the top of setfields.icn
package util

import lang
With that import, would SettableFields be a Trait?  Here is the head of that class
class SetFields()
   #
   # Generate the {Field}s for the given list.  Note that the list is
   # emptied by this function.
   #
   public static generate_fields(l)
Field is a class found in the same file.  But the problem lies in the last method of generate_fields with
suspend Field(attr, val)
Now we do not have a trait.  And then there is non-documenting code  (really not Icon-esque in 2010 ) which should at least have been
public static generate_fields( lst )
because this is not minify-me JavaScript at Google or Yahoo or qtask.com or...

This is not some stylistic quibble: in open-source code this can be decisive.  Style guidelines count as a matter of quality code.  Quality does matter.

ObjectIcon issues with packages

ObjectIcon 2.4 has folders in its ./lib for /gui and /main

What makes this arrangement an issue for me is the need to intuit what falls in 'main'.  Consider the package net.

In the /main folder we find cgi.icn  but only a 'grep' with Icon would tell you that this was declared package cgi and not package net   A comparable problem faces all OOP with classes when the code base is file-based (Smalltalk is the most notable exception in its use of a bytecode image.)

This is my result:

./address.icn:package mail
./base64handler.icn:package mail
./cgi.icn:package cgi
./codec.icn:package lang
./compoundedit.icn:package undo
./connectable.icn:package util
./constructor.icn:package lang
./contentdisposition.icn:package mail
./contenttype.icn:package mail
./encodinghandler.icn:package mail
./errno.icn:package posix
./evmonconsts.icn:package lang
./evmon.icn:package lang
./exception.icn:package exception
./files.icn:package io
./flag.icn:package util
./format.icn:package util
./graphics.icn:package graphics
./group.icn:package mail
./httpclient.icn:package http
./httprequest.icn:package http
./httpresponse.icn:package http
./ioconsts.icn:package io
./keyboard.icn:package io
./langprocs.icn:package lang
./listener.icn:package util
./location.icn:package lang
./mailbox.icn:package mail
./math.icn:package util
./md5.icn:package util
./messagehandler.icn:package mail
./message.icn:package mail
./mimeheaders.icn:package util
./misc.icn:package util
./msg.icn:package ipc
./multiparthandler.icn:package mail
./multipart.icn:package mail
./mysqlfield.icn:package mysql
./mysql.icn:package mysql
./mysqlres.icn:package mysql
./netclient.icn:package net
./noophandler.icn:package mail
./notes.icn:package notes
./popclient.icn:package mail
./posixconsts.icn:package posix
./process.icn:package util
./proc.icn:package lang
./prog.icn:package lang
./quotedprintablehandler.icn:package mail
./rfc1522.icn:package mail
./rfc822parser.icn:package mail
./sem.icn:package ipc
./setfields.icn:package util
./sets.icn:package datastruct
./shm.icn:package ipc
./smtpclient.icn:package mail
./streams.icn:package io
./system.icn:package posix
./tables.icn:package datastruct
./texthandler.icn:package mail
./text.icn:package lang
./time.icn:package util
./timezone.icn:package util
./typehandler.icn:package mail
./ucodeconsts.icn:package lang
./undoableedit.icn:package undo
./undomanager.icn:package undo
./unicodedata.icn:package unicode
./url.icn:package net
A little daunting when not ordered ... but also worrisome was how seldom the reserved word package occurred in those same source files.

[ TODO add the Icon code for sorted pkg list output ]