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:38:46 -0400 Organization: Aioe.org NNTP Server Lines: 39 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=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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:35838 On 10/17/2016 3:32 PM, 4ndre4 wrote: > On 17/10/2016 17:58, Patrick Roemer wrote: > > [...] >> Passing an opaque string around to be interpreted as a version only >> "when needed" feels fishy to me in any paradigm. > > I agree that having a 'Version' class (as shown in my first example) is > generally better. However, I do not fully agree with not having opaque > information, in general. > > I believe that there has to be a certain "axiomatic" level with any data > structure. If you have the following: > > Double speed = 1.5; > Double height = 1.5; > Double size = 1.5; > > it is perfectly legit to have: > > String version = "10.10.10" > String name = "John" > String email = "john@somedomain.com" > > I might not always want to have a class for speed, a class for height, a > class for size, etc.. each with its own validation rules. Schools of > thought, maybe :) There is a big difference between the two examples. In the double example most of the required semantics exist in the Double type. In the version example significant logic about how to actually process the format has to be added elsewhere. Arne