Refactoring to Functional Programming (with Java 8)

With Java 8’s lambda functions, Java now supports functional programming. Moving to functional programming can result in significantly better code and productivity gains. However, it requires a paradigm shift: you need to move away from imperative and object-oriented thinking to start thinking functionally. That’s what this session will help you achieve: it will help you make your shift towards functional programming. Bring-in your laptops and you can get your hands dirty refactoring imperative/OO code to functional code in Java 8! 

Attraction: Illustration of how you can perform automatic refactoring to lambdas using your favourite IDE. Special feature: Live demo of refactoring open source legacy code base to show how lambdas and streams can result in shorter and effective code. 

 
3 favorite thumb_down thumb_up 2 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist
 

Outline/structure of the Session

Outline/structure of the Session

* Introduction to lambdas and streams API (10 minutes) 

* Warm-up: Refactoring to lambda functions and functional interfaces (25 minutes) 

* Into the rapids: Hands-on with streams API (25 minutes) 

* Live demo: Refactoring legacy code to modern Java 8 code (15 minutes) 

* Using tools/IDEs for refactoring to Java 8 (10 minutes) 

* Wrap-up and Q & A (5 minutes) 

Learning Outcome

* How to convert imperative code (loops and conditionals) to functional code (lambdas and streams) 

* Know-how of approach to apply functional programming concepts in practice 

* When & how to use IDEs for automatic refactoring vs. manual refactoring 

Target Audience

Developers, leads, architects

schedule Submitted 1 year ago

Comments Subscribe to Comments

comment Comment on this Proposal
  • Naresh Jain
    By Naresh Jain  ~  10 months ago
    reply Reply

    Hi Ganesh,

    Thanks for the proposal. We don't have a 90 mins slot, can this be fitted into a 45 mins demo slot? Also can you please provide a video of any of your past presentations, this will help the program committee understand your presentation style.

    Thanks.

    • Ganesh Samarthyam
      By Ganesh Samarthyam  ~  10 months ago
      reply Reply

      Hi Naresh Jain, 

      Thanks for your update. Yes, I can fit this into a 45 mins demo slot. Here is a link to a presentation: https://www.youtube.com/watch?v=x9HkdzrKtLk. [This is a old presentation and I've considerably improved my presentation delivery.]

      Thanks! 


  • Liked John Hughes
    keyboard_arrow_down

    John Hughes - Why Functional Programming Matters

    John Hughes
    John Hughes
    Creator
    QuickCheck
    schedule 11 months ago
    Sold Out!
    45 mins
    Keynote
    Beginner

    25 years ago I published "Why Functional Programming Matters", a manifesto for FP--but the subject is much older than that!

    As software becomes more and more complex, it is more and more important to structure it well. Well-structured software is easy to write, easy to debug, and provides a collection of modules that can be re-used to reduce future programming costs. Conventional languages place conceptual limits on the way problems can be modularised. Functional languages push those limits back. In this paper we show that two features of functional languages in particular, higher-order functions and lazy evaluation, can contribute greatly to modularity. As examples, we manipulate lists and trees, program several numerical algorithms, and implement the alpha-beta heuristic (an algorithm from Artificial Intelligence used in game-playing programs). Since modularity is the key to successful programming, functional languages are vitally important to the real world.

    In this talk we'll take a deep dive into history to revisit our personal selection of highlights.

  • Liked Pushkar Kulkarni
    keyboard_arrow_down

    Pushkar Kulkarni - Going Swiftly Functional

    90 mins
    Tutorial
    Beginner

    Two years after its introduction, the Swift programming language finds itself at rank # 14 on the TIOBE index for July 2016. Some of the prime reasons for Swift’s meteoric rise are its carefully designed syntax and semantics - it borrows heavily from the best features of a wide range of languages. The syntax is intuitive and new Swift learners can often relate it to the language of their choice. Introduced primarily as a client-side language, Swift was open sourced in December 2015 via swift.org. Since then, there has been a community effort on extending its capabilities to the server side too. Swift is available on Linux today, and it is poised to become a language enabling end to end development - from mobile apps to server backends. 

    Swift falls in the category of “modern native languages” - like Rust and Go. These runtimes run code in bare metal, boosting performance. They are statically, strongly typed and with type-inference. This makes them safe. Their modern syntax also makes them expressive enough for high level abstractions like those seen in functional programming. They try to solve some of the tradeoffs that languages of the past battled with. On the other hand, functional programming has found new oxygen in the last couple of years when agile methodologies become as pervasive as multicore hardware . While we do have languages like Haskell that are purely functional and provide excellent support to express functional concepts, it is important to separate functional thinking away from the language. Functional programming is supported by most of the languages today because the returns of it in terms of expression, conciseness, readability, correctness and performance are unmatched. Swift is not a purely functional language. However, it provides syntactic and semantic support for functional programming to a large extent.

  • Liked Debasish Ghosh
    keyboard_arrow_down

    Debasish Ghosh - An algebraic approach to functional domain modeling

    Debasish Ghosh
    Debasish Ghosh
    Consultant
    IRadix Inc
    schedule 1 year ago
    Sold Out!
    45 mins
    Talk
    Intermediate

    Domain modeling is usually implemented using OO design. In this approach of "nouns-first" we design object hierarchies using subtyping to model the various elements of the domain. In this talk we will take a different approach using Scala:

    1. Start with focus on verbs first
    2. Think how we can model domain behaviors using pure functions grouped within extensible modules
    3. Use an algebraic approach towards evolution of modules,the algebra being composed of functions,types & laws
    4. See how the domain algebra can be constructed from categorical structures like monoids, functors & monads
    5. Discuss how the functional patterns lead to compositionality - an extremely important quality that scales your domain model.

  • Liked Tamizhvendan S
    keyboard_arrow_down

    Tamizhvendan S - Rethinking "State Management."

    Tamizhvendan S
    Tamizhvendan S
    Lead Consultant
    Ajira
    schedule 1 year ago
    Sold Out!
    45 mins
    Demonstration
    Beginner

    Persisting the State is an integral part of any application, and it profoundly influences how we architect the application. But do we need to store the state in the first place? Is there any alternative?

    Together, let's experience a difference perspective of State Management.

  • Liked Abdulsattar Mohammed
    keyboard_arrow_down

    Abdulsattar Mohammed - Dependently Typed Programming with Idris

    45 mins
    Talk
    Intermediate

    Types allow us to structure data to match the functional requirements of the problem we are trying to solve. But, in most languages, we end up choosing/building types that are the closest to our requirement. They don't exactly fit our bill, as a result of which, we write runtime code to enforce those conditions. Then we write tests because the compiler can't help us. Dependently Typed Languages like Idris allow us to encode a wide range of invariants into the type itself allowing us to possibly have zero runtime errors.

  • Liked Roger Hui
    keyboard_arrow_down

    Roger Hui - A Tour (de Force) of APL in 16 Expressions

    Roger Hui
    Roger Hui
    programmer
    Dyalog Ltd.
    schedule 1 year ago
    Sold Out!
    90 mins
    Workshop
    Beginner

    APL will be 50 years old in November 2016 (50 years from 1966-11-27 15.53.58, to be exact), and it remains unsurpassed in manifesting Kenneth E. Iverson’s five important characteristics of notation

    • ease of expression
    • suggestivity
    • subordination of detail
    • economy
    • amenability to proof

    These characteristics are demonstrated by working through 16 APL expressions. The material is approachable for beginners and yet thought-provoking for experts.

    One of the 16 expressions is a fast computation of the partition function without use of the Hardy-Ramanujan (1918) results.

     

  • Liked Monika Kumar Jethani
    keyboard_arrow_down

    Monika Kumar Jethani - "Kotlin is the secret of my functional power", says Android

    45 mins
    Demonstration
    Beginner

    Kotlin is a statically-typed programming language released by JetBrains. With the arrival of Kotlin, Android's functional power has enhanced as Kotlin brings a bouquet of features such as type inference,higher-order functions, lambda expressions, operator overloading, lazy evaluation,immutability,recursive functions and lots of useful methods to work with collections. Kotlin comes up with essential functional facilities such as filter,take & drop, first & last, fold & foldRight, forEach, reduce,etc making it a perfect match for Android .This talk will focus on leveraging Kotlin's functional constructs for Android App development.

     

  • Liked S G Ganesh
    keyboard_arrow_down

    S G Ganesh - Functional Programming in Java 8 (with Lambdas and Streams)

    90 mins
    Workshop
    Intermediate

    Java says hello to functional programming with its support for lambdas in Java 8. This talk cover syntax and semantics of lambda functions, moving from external iteration to internal iteration, and how lambda functions can result in shorter and more readable code. If you are new to functional programming and want productivity gains from using Java’s lambda functions, this talk is certainly for you. 

    Using completely hands-on approach (extensive set of sample programs will be shared to all participants), this session covers Java 8's functional programming features for regular work and improve productivity. Special feature: Live demo of solving a programming problem in iterative approach (Java 7 and earlier) versus using Java 8 streams (Java 8).  

  • Liked Pushkar Kulkarni
    keyboard_arrow_down

    Pushkar Kulkarni - Functional Containers - A gentle introduction

    Pushkar Kulkarni
    Pushkar Kulkarni
    Software Developer
    IBM
    schedule 11 months ago
    Sold Out!
    45 mins
    Talk
    Intermediate

    Functional programming has it roots in Lambda Calculus and Recursion Theory. As we start getting deeper into type systems and type theory, another branch of mathematics becomes significant - Category Theory. If, as a programmer, you tried to read and understand Category Theory chances are high that you dropped the book and went back to life! It happened with me. As users of modern programming languages and libraries, we are often unaware of the amount of design concepts the latter borrow from ideas of Category Theory. 

    This talk would give a gentle introduction to three of such functional design patterns, I prefer to call them containers - Functors, Applicative Functors and Monads - keeping the all the abstract math away and focusing on getting introduced to them with very simple code examples in Swift. We will also point out some types in the Swift language and the standard library that conform to these patterns. Finally, we prove how the existence of these concepts could make your code better - how they help achieve separation of concerns, eliminate code duplication and managing side effects. Though languages like Haskell make it very easy to express these concepts, they could be expressed in any modern language with a tad bit of code. 

     

  • Liked Siddharth Kulkarni
    keyboard_arrow_down

    Siddharth Kulkarni - Functional Programming Basics

    45 mins
    Talk
    Beginner

    You must have heard people talk about Functional programming whilst your nod apprehensively, and how cool people do functional programming. You must have heard people talk about functional purity and imperative blasphemy. But what exactly does functional programming entail? Why is it making a comeback? This talk is aimed at providing an objective and practical view of what FP can and cannot do, and how it's nothing to be scared of, what languages support functional style and how it can help alleviate some common programming problems.