<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Defining Scala Design Idioms</title>
	<atom:link href="http://www.codecommit.com/blog/scala/defining-scala-design-idioms/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:21:24 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Babar</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-4934</link>
		<dc:creator>Babar</dc:creator>
		<pubDate>Tue, 09 Feb 2010 15:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-4934</guid>
		<description>Hi, I realize this is a very old post but I came across Scala a little late and would like to have my naming conventions figured out. In C# I use CamelCase for accesors I wonder if same can be done in Scala.

so 

class Book(val title:String) {
  private var author:Author = null
 
  def Author = author
 
  def Author_=(authorP:Author) {
    if (authorP != null) {
      author = authorP
    }
  }
}
 
I use suffix P to distinguish parameters  from fields so I can avoid using &quot;this&quot;. Any thoughts?</description>
		<content:encoded><![CDATA[<p>Hi, I realize this is a very old post but I came across Scala a little late and would like to have my naming conventions figured out. In C# I use CamelCase for accesors I wonder if same can be done in Scala.</p>
<p>so </p>
<p>class Book(val title:String) {<br />
  private var author:Author = null</p>
<p>  def Author = author</p>
<p>  def Author_=(authorP:Author) {<br />
    if (authorP != null) {<br />
      author = authorP<br />
    }<br />
  }<br />
}</p>
<p>I use suffix P to distinguish parameters  from fields so I can avoid using &#8220;this&#8221;. Any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-4854</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Tue, 07 Jul 2009 22:30:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-4854</guid>
		<description>@Matthias

In this case, != would be a member of author.  However, Scala does avoid the whole null equality issue very nicely by making null a value of type Null, which does define the == and != methods.  Thus, the following works perfectly:

&lt;pre&gt;val t: String = null
t != null   // =&gt; false
t == null  // =&gt; true
null == null  // =&gt; true&lt;/pre&gt;

Gotta love Scala!</description>
		<content:encoded><![CDATA[<p>@Matthias</p>
<p>In this case, != would be a member of author.  However, Scala does avoid the whole null equality issue very nicely by making null a value of type Null, which does define the == and != methods.  Thus, the following works perfectly:</p>
<pre>val t: String = null
t != null   // => false
t == null  // => true
null == null  // => true</pre>
<p>Gotta love Scala!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthias Horn</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-4853</link>
		<dc:creator>Matthias Horn</dc:creator>
		<pubDate>Mon, 06 Jul 2009 12:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-4853</guid>
		<description>I think it is really important to develop conventions and standards, especially for new languages such as Scala, and the designers could do well to share their own conventions used for their libraries.

That all said, I ended up here looking for a way of Null checking in scala, and the comments did give the clear answer, don&#039;t use null,  use Option[...]  instead; makes sense.

However, your scala sample uses 

if (author != null) ...
.
As far as i understand &#039;!=&#039; is actually a function so I would expect that when author is null there to be a NullPointerException thrown attempting to evaluate a member (&#039;!=&#039;) of null.

Or dose scala treat null as a real object, supporting all the standard functions?</description>
		<content:encoded><![CDATA[<p>I think it is really important to develop conventions and standards, especially for new languages such as Scala, and the designers could do well to share their own conventions used for their libraries.</p>
<p>That all said, I ended up here looking for a way of Null checking in scala, and the comments did give the clear answer, don&#8217;t use null,  use Option[...]  instead; makes sense.</p>
<p>However, your scala sample uses </p>
<p>if (author != null) &#8230;<br />
.<br />
As far as i understand &#8216;!=&#8217; is actually a function so I would expect that when author is null there to be a NullPointerException thrown attempting to evaluate a member (&#8216;!=&#8217;) of null.</p>
<p>Or dose scala treat null as a real object, supporting all the standard functions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3923</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Tue, 12 Aug 2008 17:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3923</guid>
		<description>@jherber

Definitely +1 the use of Option over nullable values.  The mutable field (author) is a bit unidiomatic however, especially for a case class.  It&#039;s pretty good though.

I think that the more significant issue to resolve in Scala design idioms is how to deal with name classes, particularly in fields and methods.  There was some discussion about this above, leading vs trailing underscores, suffixes, etc.</description>
		<content:encoded><![CDATA[<p>@jherber</p>
<p>Definitely +1 the use of Option over nullable values.  The mutable field (author) is a bit unidiomatic however, especially for a case class.  It&#8217;s pretty good though.</p>
<p>I think that the more significant issue to resolve in Scala design idioms is how to deal with name classes, particularly in fields and methods.  There was some discussion about this above, leading vs trailing underscores, suffixes, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jherber</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3920</link>
		<dc:creator>jherber</dc:creator>
		<pubDate>Tue, 12 Aug 2008 03:33:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3920</guid>
		<description>daniel, what do you think of this scala representation:

case class Book( title:Option[String]) { var author:Option[Author]=None }

1. handles title constructor
2. handles avoiding null in favor of Option
3. author is R/W

usage:

var b = Book( Some(&quot;Fahrenheit 451&quot;) )
b.author = Some( Author(&quot;Ray Bradbury&quot;) )</description>
		<content:encoded><![CDATA[<p>daniel, what do you think of this scala representation:</p>
<p>case class Book( title:Option[String]) { var author:Option[Author]=None }</p>
<p>1. handles title constructor<br />
2. handles avoiding null in favor of Option<br />
3. author is R/W</p>
<p>usage:</p>
<p>var b = Book( Some(&#8220;Fahrenheit 451&#8243;) )<br />
b.author = Some( Author(&#8220;Ray Bradbury&#8221;) )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel Neely</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3541</link>
		<dc:creator>Joel Neely</dc:creator>
		<pubDate>Thu, 01 May 2008 12:21:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3541</guid>
		<description>Thanks, Daniel, for this very thorough discussion! Having seen too much Java written with a C accent, I&#039;m very interested in what a native Scala accent would look like, and how that would affect one&#039;s approach to a programming task. I&#039;ve been using the Project Euler problems as a way of exploring Scala, and found one of them a nice motivation for Scala&#039;s hybrid nature (http://joelneely.wordpress.com/2008/04/24/a-composite-function/).

I agree with the goal in your concluding paragraph, but wonder how much history/experience a language community needs before starting to converge on &quot;best practice&quot; style and idiom conventions. (I recall criticisms of new-born Ada, asserting that the designers had attempted to standardize areas which were not sufficiently well-understood.) Finally, I wonder whether multiple styles may emerge in the use of a hybrid language, a Java-like style in code that&#039;s primarily OO, along with a Haskell-like style in code that&#039;s primarily FP. It&#039;s going to be interesting to watch this develop!</description>
		<content:encoded><![CDATA[<p>Thanks, Daniel, for this very thorough discussion! Having seen too much Java written with a C accent, I&#8217;m very interested in what a native Scala accent would look like, and how that would affect one&#8217;s approach to a programming task. I&#8217;ve been using the Project Euler problems as a way of exploring Scala, and found one of them a nice motivation for Scala&#8217;s hybrid nature (<a href="http://joelneely.wordpress.com/2008/04/24/a-composite-function/" rel="nofollow">http://joelneely.wordpress.com/2008/04/24/a-composite-function/</a>).</p>
<p>I agree with the goal in your concluding paragraph, but wonder how much history/experience a language community needs before starting to converge on &#8220;best practice&#8221; style and idiom conventions. (I recall criticisms of new-born Ada, asserting that the designers had attempted to standardize areas which were not sufficiently well-understood.) Finally, I wonder whether multiple styles may emerge in the use of a hybrid language, a Java-like style in code that&#8217;s primarily OO, along with a Haskell-like style in code that&#8217;s primarily FP. It&#8217;s going to be interesting to watch this develop!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Det</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3495</link>
		<dc:creator>Det</dc:creator>
		<pubDate>Thu, 17 Apr 2008 10:13:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3495</guid>
		<description>&quot;I didn’t feel like trying to explain Ruby syntax elements in a post about Scala&quot;

Well, but that would highlight the topic much more, as mostly idioms result from specific syntax features available in different languages.  That is exactly what makes learning a new language so hard, when trying to avoid writing your &quot;old language&quot; only in another syntax.

So both examples of Ruby are useful to show the point.

Well, this article may be the first step of a long series, as in my opinion the &#039;uncertainty what is &quot;the right way&quot; &#039; reg. Scala indeed involves the bigger part, especially as it is based on Java.

I just hit the problem with:  &quot;Yes, I know how to open a file and iterate through the lines in Java. Yes, it all worked when likewise done in Scala syntax. But is scaladish Java the intented way to do it?&quot;</description>
		<content:encoded><![CDATA[<p>&#8220;I didn’t feel like trying to explain Ruby syntax elements in a post about Scala&#8221;</p>
<p>Well, but that would highlight the topic much more, as mostly idioms result from specific syntax features available in different languages.  That is exactly what makes learning a new language so hard, when trying to avoid writing your &#8220;old language&#8221; only in another syntax.</p>
<p>So both examples of Ruby are useful to show the point.</p>
<p>Well, this article may be the first step of a long series, as in my opinion the &#8216;uncertainty what is &#8220;the right way&#8221; &#8216; reg. Scala indeed involves the bigger part, especially as it is based on Java.</p>
<p>I just hit the problem with:  &#8220;Yes, I know how to open a file and iterate through the lines in Java. Yes, it all worked when likewise done in Scala syntax. But is scaladish Java the intented way to do it?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3490</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Tue, 15 Apr 2008 14:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3490</guid>
		<description>@David

The %* syntax was actually considered for deprecation in 1.9, so I&#039;m not sure it can be considered to be &quot;more idiomatic&quot;.  You&#039;re write about the one-line Proc though.  I thought about using it, but I&#039;ve always though that &quot;brace blocks&quot; are less readable than then do/end syntax and I didn&#039;t feel like trying to explain Ruby syntax elements in a post about Scala.  :-)</description>
		<content:encoded><![CDATA[<p>@David</p>
<p>The %* syntax was actually considered for deprecation in 1.9, so I&#8217;m not sure it can be considered to be &#8220;more idiomatic&#8221;.  You&#8217;re write about the one-line Proc though.  I thought about using it, but I&#8217;ve always though that &#8220;brace blocks&#8221; are less readable than then do/end syntax and I didn&#8217;t feel like trying to explain Ruby syntax elements in a post about Scala.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Madden</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3489</link>
		<dc:creator>David Madden</dc:creator>
		<pubDate>Tue, 15 Apr 2008 11:10:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3489</guid>
		<description>Ok, Ok I am being very pedantic, but a more idiomatic Ruby version of the first example would be:

first_names = %w{Daniel Chris Joseph}
 
first_names.each { &#124;name&#124; puts name }</description>
		<content:encoded><![CDATA[<p>Ok, Ok I am being very pedantic, but a more idiomatic Ruby version of the first example would be:</p>
<p>first_names = %w{Daniel Chris Joseph}</p>
<p>first_names.each { |name| puts name }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binil Thomas</title>
		<link>http://www.codecommit.com/blog/scala/defining-scala-design-idioms/comment-page-1#comment-3484</link>
		<dc:creator>Binil Thomas</dc:creator>
		<pubDate>Tue, 15 Apr 2008 05:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/defining-scala-design-idioms#comment-3484</guid>
		<description>Daniel, I hope your post gets the attention of Odersky, Spoon, and Venners. Languages tend to adopt the convention followed in the most popular (often first) book written on it.</description>
		<content:encoded><![CDATA[<p>Daniel, I hope your post gets the attention of Odersky, Spoon, and Venners. Languages tend to adopt the convention followed in the most popular (often first) book written on it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

