Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Java blunders Date: Mon, 28 Jul 2014 12:52:49 +0000 (UTC) Organization: A noiseless patient Spider Lines: 63 Message-ID: References: <53cef75d$0$291$14726298@news.sunsite.dk> <7s6vs9p395bretqrtdvh9i6til83vfk52p@4ax.com> <53d04b5f$0$291$14726298@news.sunsite.dk> <53d19752$0$295$14726298@news.sunsite.dk> <7lcat9t8j6tuo1v2tm1od8rhvhcgf5i7g9@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 28 Jul 2014 12:52:49 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="20753"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gsjLlvr1Xviwi/ykFYBichemQTVMgWyE=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:Jbv6wFfedg9d90cPInCmI8Ljzxg= Xref: csiph.com comp.lang.java.programmer:29391 On Mon, 28 Jul 2014 13:22:49 +0100, Chris Uppal wrote: > Martin Gregorie wrote: > > >> Same applies to operator overloading: given a CurrentAccount object ca >> and a Payment object p there 's little or no difference in clarity >> between writing >> >> ca.acceptPayment(p); >> >> and ca += p; > > The latter pattern is used a lot in C# / .Net framework. For instance > you use += to add listeners for events. It keeps the code short, but > does nothing for clarity IMO. > > Your example of adding a depost to an account using += may make more > sense, but even there I think it's more "cute" than "clear". OTOH, if > Java had (say) "->" > and "<-" as generic (not Generic) operators for "putting stuff into > places" and "getting stuff from places" (pace the discusion elsethread > about notation for IO), then I'd be all for: > > ca <- p; > Yes, Mine wasn't a particularly good example. I should have used a real- life one. Given: - a PICTURE mode (which holds a 2D plottable diagram, scaled and ready to output - a SKETCH mode, which holds details of an unscaled item that can be plotted after its scaled and positioned in a PICTURE - a set of modes (RECTANGLE, CIRCLE, TEXT) derived from SKETCH and given the objects: RECTANGLE r; CIRCLE c; TEXT t; you could write PICTURE p = r + c + t; which I would say is entirely understandable and unambiguous. Using this library I wrote an Algol 68R program that drew a rectangular frame, filled it with a number of randomly sized and placed circles, wrote 'BUBBLES' centred in the frame, and output the completed image on a line printer. It was my test piece to make sure I'd installed the graphics library correctly. It was a 10 line program and pretty much readable by any programmer. I used the financial example because I thought it would need less explanation: obviously a mistake. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |