Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Challenges and approach for Refactoring into Java8

 
Ranch Hand
Posts: 227
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Technically our code base is sitting on underlying JAVA8 Run time but it doesn't contain any of the java 8 features.

To take advantage of it ,What would be your suggestions and advises as to How we need to approach this through
Refactoring/Re engineering exercise.
 
Author
Posts: 161
31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't answer this question without asking another question: why do you want to refactor your code base? You say you want to take advantage of the Java 8 runtime, but what does this mean?

If you have a code base using many anonymous classes that could be replaced with lambdas or method references, there could be a small benefit, in some cases. But I don't think you would ever notice the difference. Being functional is a great advantage in terms of safety, testability, and reusability, at the development stage. It often also leads to a much better architecture. But this does not mean that you can't write safe an easy to maintain programs, with a good architecture, in imperative programming. Writing good programs is difficult in imperative programing, but it is also difficult in functional programming. The main difference is that writing BAD programs is much easier in imperative programing, which leads many programmers into thinking that FP is more difficult. So you will gain the most by applying FP to average programmers, because very good programmers will most often write good programs, even imperative ones. (This is why I like functional programming so much!)

In any case, I would suggest not refactoring your code base if you don't need to. Just start applying functional principles to your new developments. When interfacing to legacy code, you will encounter some problems that you will be able to solve either by refactoring only as much as needed, or by implementing minimal functional wrappers around imperative libraries.

Another use case, regarding legacy code, is if you have to make it evolve. In such case, it might be better to rewrite some parts, and you should take advantage of functional programming as much as possible. Otherwise, the only reason to rewrite imperative programs that works well into functional ones is fun. This might be a very good reason for programmers. Not sure you boss will appreciate it though!

And remember you don't have to change everything at first. Start by clearly separating functions (meaning functional methods) from effects.  Insure referential transparency. Use final members as much as possible. Avoid closures by using additional parameters. This is a good start to write safer programs.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic