Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1150 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53050 invoked by uid 1007); 2 May 2003 03:57:25 -0000 Message-ID: <20030502035725.53049.qmail@pb1.pair.com> To: internals@lists.php.net Reply-To: "l0t3k" Date: Thu, 1 May 2003 09:02:07 -0400 Lines: 26 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Posted-By: 67.33.101.124 Subject: Object Design question. From: cshmoove@bellsouth.net ("l0t3k") im writing a UnicodeString class for an extension and wanted to ask a question related to the design of the user-space API. the issue is with operations that perform modifications (insert, remove, padding, etc). we have the java/javascript route where strings are immutable, meaning that each modification operation creates a new string while leaving the original unmodified. this has the virtue of being familar to people (less WTF), though its less efficient. but we may also choose to do modifications in-place and return a reference to the string. i copped out for now and provided for having modification methods function statically as well as non-statically. f. ex. // modifies $warAndPeace. $str and $warAndPeace refer to the same string (1) $str = I18N::UnicodeString::insert($warAndPeace, $editorsNotes, 0); // creates $newString, copies $warAndPeace to it, and does the insert (2) $newString = $warAndPeace->insert($editorsNotes, 0) the question is should (2) return a reference to the original which is modified in place. i think having static/non-static handling may be the way out, but the concern there is perceived bloatage. l0t3k