I am far from a Scala or functional programming expert, so I wouldn’t take anything here as definitive.
John Huss pointed me toward Scala templates for EOGenerator (http://wiki.wocommunity.org/plugins/servlet/mobile#content/view/2622529) and I have been working on some isolated projects with those because I don’t yet have the time to refactor everything in my EO Frameworks with the new templates. These templates look like they’ll make dealing directly with EO’s simpler from Scala but I have some questions about how the EOFramework would be used from Java (because we still have apps that use the frameworks in Java). I am probably just being paranoid, because it looks like it should be a drop in replacement, but I will have to refactor the entity custom logic to scala. I look forward to cleaning up that code, but it’s not going to be a small job. When I have a bit more testing of the Scala EOs and how they work and play well with existing java, I’ll start migrating them. I started integrating Scala with EOF for command line tools and bulk analysis and found that using scala.collection.JavaConversions._ allowed me to use toList to treat the NSArray<T> resulting from an ERXEOControlUtilities.objectsWithQualifier call using the common recursion and mapping of Scala collections. I do require some casting (asInstanceOf[]) occasionally, but I look at those places as examples of what I don’t yet know about how to work with Scala because most of the time I can find a better way to do this. I think the scala EO templates will help a lot in this regard. There is a lot of Scala that I have trouble interpreting but even with a rudimentary understanding of the language and FP, I am finding the code coming out is more concise and testable. Some of that is paying more explicit attention to side-effects and mutability (which I should have been doing more of in Java anyway), but re-writing some of the aggregation/analysis tools that already used recursive patterns has resulted less code and lower memory usage in most cases. Larry Mills-Gahl [email protected] On Jul 30, 2014, at 7:42 AM, Schoenenberger Dominique <[email protected]> wrote: > I’m quite interested to use Scala inside my WebObjects applications but after > some problems with Eclipse, I’ve restricted it to the tests. > > Could you give me more information how you manage the use WebObjects > collections and conversions ? > > Which part of WebObjects do you think is more appropriate / easier to use > Scala: business logic / component part / ... ? > > Dominique > > > On 10 Jul 2014, at 17:48, Larry Mills-Gahl <[email protected]> wrote: > >> Hello... >> >> I’m using scala with WebObjects/Wonder for a number of apps including a >> bunch of data loading/analyzation utilities (also exposed as services) >> >> This works extremely well and seamlessly (thanks to some of the >> scala.collection.JavaConversions._ and other bits), but there are a couple >> things about using EO’s that I’m working around and I wonder if someone here >> has more insight into where this mismatch is happening. >> >> Using ERXEOControlUtilities.createAndInsertObject(…) results in errors that >> the EOClassDescription cannot be found. >> >> Calling: >> val lab = ERXEOControlUtilities.createAndInsertObject(emrec, >> "BloodMeasurement").asInstanceOf[BloodMeasurement] >> >> ...will fail ( >> >> but >> val lab = new BloodMeasurement() >> emrec.insertObject(lab) >> >> … works normally (but feels so 1998) >> >> It looks like scala is not getting the class descriptions from the model, >> but I wouldn’t expect it to care if ERXEOControlUtilities is the class that >> needs the model. >> >> As long as I’m asking Scala questions, is there a way to use the static >> fields of the eogenerated classes without addressing them directly? (Perhaps >> this is an Eclipse issue, but the compiler doesn’t seem to know about >> BloodMeasurement.ENTITY_NAME, but it does know about >> _BloodMeasurement.ENTITY_NAME. I imagine this has something to do with how >> Scala treats “companion objects” in relation to static fields in Java, but I >> don’t know if there is a way to deal with this more elegantly (as there is >> with all of the collections and functional goodness in Scala) >> >> >> Larry Mills-Gahl >> [email protected] >> >> >> >> >> >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list ([email protected]) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/dominique.schoenenberger%40nagra.com >> >> This email sent to [email protected] >
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
