Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!atha!aunro!alberta!ubc-cs!news.UVic.CA!sirius!peters From: peters@sirius.UVic.CA (Doug Peters) Newsgroups: comp.lang.smalltalk Subject: method-ology Summary: when should methods modify receiver/parameters? Message-ID: Date: 21 Jun 91 17:32:02 GMT Sender: news@sol.UVic.CA Distribution: comp Organization: University of Victoria, Victoria, BC, Canada Lines: 41 Nntp-Posting-Host: fort.uvic.ca aside{ Thanks to those who responded to my previous problem: Hubert Baumeister Chris Anderson (just where _is_ beldar, anyway :-) Michael Richardson (who directed me to gnu.smalltalk.bug *sorry*) & Steve Byrne (of course) } Now, I have a more general Smalltalk kind of problem. Perhaps the answer is obvious (in which case I'll learn something). Perhaps it'll generate discussion (I learned a lot from that "accessing methods" discussion a while back). Anyway, here it is: When should methods: a) modify the receiver -or- b) modify method parameters For example, I have a Matrix class, and I want to have a qr method that decomposes the receiver into (you guessed it) two matrices traditionally labelled "q" and "r". Should I a) modify the receiver to become the "r" matrix and answer the "q" b) leave the receiver and answer a size two array containing two matrices c) have a q:r: method whose parameters become the desired results d) some permutation of the above ? My thoughts so far: - c) sounds Fortran-ish and should be avoided. (Are there any exceptions?) BUT - the strategies implied in a) or b) could become _very_ ugly for a more complicated problem. Any hints? Thanks in advance =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Doug Peters (peters@sirius.UVic.CA) "If you have any answers... ...you've been asked the wrong questions." =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=