|
Rob, This is the way it's done with Java Beans. Interesting article about this at http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation.html. I'm trying to apply these principles to ILE & RPGIV. You never access the data directly but do so through getters and setters. Getters can do more than just return a field value. The returned value might not even be a data field but could be derived from some other fields. GetName( SSN ) could return a formatted string derived from other fields. It might actually be stored in the record as first name, last name and middle initial. As an end developer I don't want to know the details about how the name is stored. I just want to use the name. If the fields aren't in the program you can't mess with them. Having the entire record's fields in the application program opens you up to all sorts of errors. You could change other fields in the record by mistake. Using getters and setters avoids those types of errors. BTW, The code would be more like Key = GetNextRecord(); MyWorkField1 = GetField1( Key ); MyWorkField2 = GetField2( Key ); than some generic GetField procedure. That 'actually do some real work' might be another getter procedure provided by the module instead of code in your application program. Rather than: SSN = GetNextEmployee(); MyFirstName = GetFirstName( SSN ); MyLastName = GetLastName( SSN ); Name = MyFirstName + " " + MyLastName; You'd have SSN = GetNextEmployee(); Name = GetName( SSN ); I'd rather code that that than Read Employee; Name = EMFNAM + " " + EMLNAM; Paul -- Paul Morgan Senior Programmer Analyst - Retail J. Jill Group 100 Birch Pond Drive, PO Box 2009 Tilton, NH 03276-2009 Phone: (603) 266-2117 Fax: (603) 266-2333 > Paul, > > I think you're the first person that I heard of, that wasn't the person in > charge of writing the access programs, that actually liked this scenario. > Why an end developer would like to replace > > chain(e) myfile; > // now actually do some real work with the fields > > with > getFilename(); > MyWorkField1=GetField(field1); > MyWorkField2=GetField(field2); > ... > // now actually do some real work with the fields > > rather escapes me. > > Rob Berendt > -- > Group Dekko Services, LLC > Dept 01.073 > PO Box 2000 > Dock 108 > 6928N 400E > Kendallville, IN 46755 > http://www.dekko.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.