Hello all,
A question on MVC-like architecture for EmeraldView, the Greenstone PHP
frontend I'm working on. First, a crash-course in the Greenstone data
model...
The biggest unit of content in Greenstone is the "collection." Within
each collection, G references content in "documents" which are broken
into "sections." Each document and section (I've taken to calling them
nodes) is represented in a datastore by a record with metadata. So for
example, represented in YAML:
DOC123:
Title: "Pigs in space"
Subject: "pigs, space"
Contains: DOC123.1,DOC123.2
DOC123.1:
Title: "The mission begins"
Contains: DOC123.1.1
DOC123.1.1:
Title: "More of the mission beginning"
DOC123.2:
Title: "The mission continues"
Browse trees can be created on arbitrary metadata fields, and are called
"classifiers." They also consist of a root "node" and subnodes; for
example:
CL1:
Title: "Author"
Contains: CL1.1,CL1.2
CL1.1:
Title: "Aardvark, Larry"
Contains: DOC123,DOC456
CL1.2:
Title: "Milton, John"
Contains: DOC789,DOC654
Okay, now for the question. I have written a Node class to represent
this most basic level of organization, with subclasses Node_Document
(representing a document or section thereof) and Node_Classifier (for a
classifier or subnode thereof). This makes sense to me for representing
the metadata, as described above.
http://bitbucket.org/yitznewton/emeraldview/src/tip/application/libraries/Node.php
http://bitbucket.org/yitznewton/emeraldview/src/tip/application/libraries/Node/Classifier.php
http://bitbucket.org/yitznewton/emeraldview/src/tip/application/libraries/Node/Document.php
What happens when I need to deal with the *web page* representing the
content of a node? In Greenstone (and thus in EmeraldView), each
classifier, document, and section has a page view associated with it.
There are certain behaviors that apply to a web page and not a
"Model"-level node, such as getUrl(), getSourceDocumentUrl(), getHTML()...
I have been using wrapper classes for the Nodes (Classifier and
DocumentSection), and, realizing that there is much duplicate
functionality between the two, thought to make them inherit from a
common class.
[there are a couple of obsolete duplicate methods in here that I haven't
cleaned out yet]
http://bitbucket.org/yitznewton/emeraldview/src/tip/application/libraries/Classifier.php
http://bitbucket.org/yitznewton/emeraldview/src/tip/application/libraries/DocumentSection.php
When I came to the question of what to call this parent class, I took a
step back, wondering, what sort of class is this, exactly? Does it
merit a distinct class apart from Node? I looked through Gang of Four,
but couldn't find anything that really reflected what I'm trying to do -
this seems simpler than most of their patterns. Intuitively it feels to
me like this should indeed be a separate class from Node, as Node is for
metadata, and this class is to be for web page behavior. Perhaps:
NodeWrapper
NodePage
NodePageWrapper
NodeView
Thoughts?
Thanks so much!
--
Yitzchak Schaffer
Systems Manager
Touro College Libraries
33 West 23rd Street
New York, NY 10010
Tel (212) 463-0400 x5230
Fax (212) 627-3197
Email [log in to unmask]
|