Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: double == double Date: Wed, 19 Oct 2016 21:58:20 -0400 Organization: Aioe.org NNTP Server Lines: 54 Message-ID: References: <8737k0qd38.fsf@golem.phantasia.org> <87zim5es30.fsf@golem.phantasia.org> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:35843 On 10/17/2016 4:53 AM, a.laforgia@gmail.com wrote: > On Monday, 17 October 2016 03:51:55 UTC+1, Arne Vajhøj wrote: > > [...] >> Having data and methods operating on the data separate is >> very non-OO'ish in my book. > > That's a kind of purist approach that I find very little > pragmatic. Having methods that act on data is how OO is > normally implemented. Usually I am rather pragmatic. But using a formatted string to as primary form for data should bother more than purists. > This: > > double d1 = 3.4; > double d2 = 5.6; > double dMax = Math.max(d1, d2); > > is certainly better than this: > > class PairOfDoubles { > double d1; > double d2; > > public PairOfDoubles(double d1, double d2) { > this.d1 = d1; > this.d2 = d2; > } > > public double max() { > return d1 >= d2 ? d1 : d2; > } > } > This example is not that close to the version number example. The version number example has data with an internal structure that the processing methods need to parse and format to work with the data. Consider a suggestion to instead of having a Circle and Rectangle class then you used String's in formats: "C(x,y,r)" "R(x,y,w,h)" Would anyone consider that good OOP? I doubt it! Arne