Changes for page WebObjects with Scala

Last modified by Ravi Mendis on 2011/05/10 02:10

From version 518.1
edited by Ravi Mendis
on 2010/04/06 18:25
Change comment: There is no comment for this version
To version 519.1
edited by Ravi Mendis
on 2010/06/08 01:35
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -8,19 +8,19 @@
8 8  
9 9  Here's a quick summary:
10 10  
11 -|= |= Objective-C |= Java |= Scala
12 -|= Separation of Mutable & Immuable Datatypes | Collections //e.g: NSArray/NSMutableArray// | No | Yes
13 -|= Closures | Blocks (//Extension//) | No | Anonymous Functions
14 -|= Static variables | Yes | Yes | No
15 -|= Static methods or functions | Yes | Yes | No
16 -|= Concurrency | [[Grand Central Dispatch>>http://en.wikipedia.org/wiki/Grand_Central_Dispatch]] (//Extension//)| //Threads// |[[Actors>>http://en.wikipedia.org/wiki/Actor_model]]
17 -|= |= Weakly Typed |=--Strongly Typed--|= Strongly Typed
11 +|= |= Objective-C |= Java |= Scala
12 +|= Separation of Mutable & Immuable Datatypes | Collections //e.g: NSArray/NSMutableArray// | No | Yes
13 +|= Closures | Blocks (//Extension//) | No | Anonymous Functions
14 +|= Static variables | Yes | Yes | No
15 +|= Static methods or functions | Yes | Yes | No
16 +|= Concurrency | [[Grand Central Dispatch>>http://en.wikipedia.org/wiki/Grand_Central_Dispatch]] (//Extension//) | //Threads// | [[Actors>>http://en.wikipedia.org/wiki/Actor_model]]
17 +|= |= Weakly Typed |= --Strongly Typed-- |= Strongly Typed
18 18  
19 19  Other notable features include:
20 20  
21 -|= |= Objective-C |= Java |= Scala
22 -|= Parametered methods | Yes //e.g: addObject: to~:// | No | Yes //e.g: add(object= ,to=)//
23 -|= Class composition | Categories | Interfaces | Traits
21 +|= |= Objective-C |= Java |= Scala
22 +|= Parametered methods | Yes //e.g: addObject: to~:// | No | Yes //e.g: add(object= ,to=)//
23 +|= Class composition | Categories | Interfaces | Traits
24 24  
25 25  === Why Use Scala? ===
26 26  
... ... @@ -40,11 +40,12 @@
40 40  
41 41  == EOs in Scala ==
42 42  
43 -=== Thread-Safe Shared Vars ===
43 +=== Thread-Safe Shared Vars ===
44 44  
45 -Scala doesn't have static variables or methods. However, a class can have a //Companion Object// that will allow you to achieve something equivalent to static variables.
46 -One of the advantages of this approach is that it is **thread-safe**, so you don't have to worry about synchronizing access to these fields in a concurrent application.
45 +Scala doesn't have static variables or methods. Instead Scala employs the [[Singleton Pattern>>http://en.wikipedia.org/wiki/Singleton_pattern]] which is built into the language and is **thread-safe**: a class can have a //Companion Object// that will allow you to achieve something equivalent to static variables - but better.
47 47  
47 +So you don't have to worry about synchronizing access to shared mutable fields in a concurrent application.
48 +
48 48  The following is an example of the use of a //Companion Object// for Talent in Scala instead of Talent static fields in Java.
49 49  
50 50  Java:
... ... @@ -165,9 +165,9 @@
165 165  
166 166  An example of accessing variables in WebObjects with the following languages:
167 167  
168 -|= |= Objective-C |= Java |= Scala
169 -|= getter | ##object name## | ##object.name()## | ##object.name##
170 -|= setter | ##object setName:aName## | ##object.setName(aName)## | ##object.name = aName##
169 +|= |= Objective-C |= Java |= Scala
170 +|= getter | ##object name## | ##object.name()## | ##object.name##
171 +|= setter | ##object setName:aName## | ##object.setName(aName)## | ##object.name = aName##
171 171  
172 172  Of course in Java, we may generate WebObjects classes with "get" methods as well in order to stick to convention.
173 173  In scala there is an additional convenience we may use to produce "get" and "set" methods in addition to the default Scala accessors - Scala Annotations.
... ... @@ -197,7 +197,7 @@
197 197  def movies: NSArray[Studio] = {
198 198   storedValueForKey(_Studio.Keys.MOVIES).asInstanceOf[NSArray[Studio]]
199 199  }
200 -
201 +
201 201  def moviesList: List[Studio] = {
202 202   movies.objects.toList
203 203  }
... ... @@ -234,7 +234,7 @@
234 234  
235 235  When you create your ##.eogen## file, be sure to make the following changes in the EOGenerator Editor:
236 236  
237 -1. Point to the local [[Scala versions>>http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions]] of the .eotemplate files for ##Entity## and ##//Entity//##
238 +1. Point to the local [[Scala versions>>http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions]] of the .eotemplate files for ##Entity## and ##Entity##
238 238  1. Change the File Names Extension to "scala"
239 239  1. In Destination Paths set the Superclass Package (e.g: base)
240 240  1. Uncheck Java under Options