• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Polyglot and functional (Devoxx Nov/2011)
 

Polyglot and functional (Devoxx Nov/2011)

on

  • 1,160 views

Part 2/3 of our Devoxx University session. A discussion of functional programming and polyglot programming on the JVM for the Java developer!

Part 2/3 of our Devoxx University session. A discussion of functional programming and polyglot programming on the JVM for the Java developer!

Statistics

Views

Total Views
1,160
Views on SlideShare
1,157
Embed Views
3

Actions

Likes
0
Downloads
16
Comments
0

3 Embeds 3

http://us-w1.rockmelt.com 1
http://a0.twimg.com 1
http://coderwall.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • It’s always worth repeating a bad joke\n
  • Explain what polyglot means\n
  • Do yourself a favour and get a JRebel license if you web hack in Java\n
  • Learning non-Java languages will make you a better programmer\n
  • Java confuses matters as it’s.... both\nStatic types can be resolved at compile time for example\n\n
  • \n
  • \n
  • \n
  • \n
  • Intro the web dev slides. “One major use case for poly is web dev.”\nHands up if you do Struts or JSF. Hands up if you like it.\n
  • Upcoming 20 bullet point slide\n
  • \n
  • Actually I can talk to the start-up story here - MV\n\n\n
  • \n
  • \n
  • So, we have 2 sources of data, and we want to check whether the same elements appear in each. We need two loops to do this - as there are 3 cases - id is OK, id only appears in source, and only in DB\n
  • \n
  • \n
  • If you’ve ever found yourself writing collections code and getting frustrated because there’s a method which almost provides a way to do\nwhat you need, but you just need to tweak it slightly, then that frustration is an itch is could be scratched by functional programming.\n
  • \n
  • So, we’ve come at this a different way - we started out by saying that we need to pass in function values to customize functions. This is what’s called “higher-order functions”. This is a different approach.\n
  • Of course, this method doesn’t really exist. That’s why Eclipse has red-underlined it.\n
  • \n
  • \n
  • Let’s show a bit more context, and show how the reconcile() method gets called. DBInfo is the type which was actually returned from the DB lookup\nAlso, another slightly sneaky trick is in the call to reconcile() – we pass the returned List from extractPrimaryKeys() into the constructor for HashSet to convert it to a Set. This handily de-dups the List for us, making the contains() call more compact in the reconcile() method.\n
  • \n
  • Notice the “defensive copy”. We return a new List. \nWe don’t mutate the existing List (so once again the filter() form behaves like a mathematical function). \nWe build up a new List by testing each element against a function which returns boolean. \nIf the result of testing an element is true, we add it into the output List.\n
  • Predicate is the jargon for the returns-boolean testing function that we apply to each element in turn.\n\n
  • \n
  • \n
  • \n

Polyglot and functional (Devoxx Nov/2011) Polyglot and functional (Devoxx Nov/2011) Presentation Transcript