Path: csiph.com!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.xdsl-87-79-255-186.netcologne.de!not-for-mail From: Patrick Roemer Newsgroups: comp.lang.java.programmer Subject: Re: double == double Date: Mon, 17 Oct 2016 23:21:09 +0200 Organization: news.netcologne.de Distribution: world Message-ID: References: <8737k0qd38.fsf@golem.phantasia.org> <87zim5es30.fsf@golem.phantasia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 17 Oct 2016 21:21:10 +0000 (UTC) Injection-Info: newsreader4.netcologne.de; posting-host="xdsl-87-79-255-186.netcologne.de:87.79.255.186"; logging-data="31312"; mail-complaints-to="abuse@netcologne.de" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.24) Gecko/20100411 Thunderbird/2.0.0.24 Mnenhy/0.7.6.0 X-Mozilla-News-Host: news://news.netcologne.de In-Reply-To: Xref: csiph.com comp.lang.java.programmer:35806 Responding to 4ndre4: > 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. Fundamentalism is always bad. ;) > 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 :) The limits of our language are the limits of our world. :) Most languages, including Java, simply don't allow the introduction of cheap, ad hoc derived data types. If there were a way to declare a Distance type derived from double that inherits the full double algebra and incurs no runtime (Un-)Boxing overhead and minimal coding overhead, there'd be every reason to do so. This is a limitation of our tools, not a conceptually unreasonable thing. Your argument holds as long as the overhead of a dedicated type outweighs its benefits. If you never take an email address apart and only use it as a string, by all means stick with String as the type. But in the Version case everything, even performance considerations (re-parsing!), seems to speak for the dedicated type. Best regards, Patrick