From: Abraham T. <ti...@ta...> - 2001-12-14 17:00:23
|
So many choices.. good luck in your decision, i'm partial to this one you suggest, define, for example, Segment.copyInto(Segment otherSegment) and then implement it in AbstractSegment. , implementable in all relevant abstract classes. But depending on the direction of the project, you might want to consider this one : One other alternative which i've employed in some of the xml-ish stuff i've done is to have a utility-class that has a family of static methods for manipulating commonly manipulated objects... like segments. This would work if we could make a fundamental toolbox-class that people wouldn't forget to import when using the rest of the package. HL7API.Toolbox.copyInto(obj, obj, int x, String name); Where x is one of : Toolbox.SEGMENT Toolbox.MESSAGE Toolbox.<other element> And name is the name of the element. If we're trying to copy the msh segment we'd use Toolbox.SEGMENT, name="MSH". An advantage here is that we wouldn't break people's code with revisions of an abstract class, just because we found yet another thing we like to do with message elements in general. It's a pretty common way of doing things. The Graphics class is an example, the Math class another, even String has a couple of methods like the ones we're considering : static String copyValueOf(char[] data) Returns a String that is equivalent to the specified character array. static String copyValueOf(char[] data, int offset, int count) Returns a String that is equivalent to the specified character array. Abraham Tio MD, Chief Technologist Tacteon LTD. http://www.tacteonltd.com -----Original Message----- From: hl7...@li... [mailto:hl7...@li...] On Behalf Of Tripp, Bryan Sent: Friday, December 14, 2001 11:40 AM To: 'Abraham Tio'; 'Glock'; hl7...@li... Subject: RE: [HAPI-devel] deep copy functionality Hi Abe, Excellent advice, as always. We could use something similar to clone(), except that it wouldn't create a new object (so it would be copy(Object) : void, instead of clone() : Object). On the other hand why not define type-specific copy methods for Message, Segment, and Type? Would we want to copy anything else? You could define, for example, Segment.copyInto(Segment otherSegment) and then implement it in AbstractSegment. I guess it's a trade-off between genericness and type checking (?). The only annoying thing is that if somebody had a Segment that didn't inherit from AbstractSegment, they could have to implement copyInto again. But this would be a small percentage of the total work, and they could always cut and paste. Bryan -----Original Message----- From: Abraham Tio [mailto:ti...@ta...] Sent: Friday, December 14, 2001 10:09 AM To: 'Abraham Tio'; 'Glock'; hl7...@li... Subject: RE: [HAPI-devel] deep copy functionality In further thought, how about an interface for all things copiable ? Or add an abstract method to the base class common to all classes ? Abraham Tio MD, Chief Technologist Tacteon LTD. http://www.tacteonltd.com -----Original Message----- From: hl7...@li... [mailto:hl7...@li...] On Behalf Of Abraham Tio Sent: Friday, December 14, 2001 10:00 AM To: 'Glock'; hl7...@li... Subject: RE: [HAPI-devel] deep copy functionality I would do both, and use the implementation as a pattern for copying just about everything else that needs to be copied. Today we're thinking about deep copy for the purposes of echoing segments and messages. Tomorrow, who knows why we'll be copying. Much like the clone() method in many java class interfaces, the uses are varied and many. Does the pretense of the clone() method apply to hl7 message components ? Abraham Tio MD, Chief Technologist Tacteon LTD. http://www.tacteonltd.com -----Original Message----- From: hl7...@li... [mailto:hl7...@li...] On Behalf Of Glock Sent: Friday, December 14, 2001 8:02 AM To: hl7...@li... Subject: [HAPI-devel] deep copy functionality All: I'm working on the deep copy functionality (task 42332) and am seeking feedback on where this should be implemented. I'm leaning toward making it part of the Message interface since it must act on an entire segment in addition to select fields. Another option is to simply view the segment as comprised of "all fields" and make it part of Segment interface. Thanks, John Glock-- _______________________________________________ Hl7api-devel mailing list Hl7...@li... https://lists.sourceforge.net/lists/listinfo/hl7api-devel ???????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????? ?????? _______________________________________________ Hl7api-devel mailing list Hl7...@li... https://lists.sourceforge.net/lists/listinfo/hl7api-devel _______________________________________________ Hl7api-devel mailing list Hl7...@li... https://lists.sourceforge.net/lists/listinfo/hl7api-devel _______________________________________________ Hl7api-devel mailing list Hl7...@li... https://lists.sourceforge.net/lists/listinfo/hl7api-devel |