Menu

IOS Developer Malaysia

August 6, 2016 - IOS Developer
IOS Developer Malaysia

So lately I’ve been experimenting with an infinitely more lightweight method to bring the advantages of functional programming to ios developer Malaysia: a mix of the running Java library which supplies support for list procedures like map, filter and fold, and also the Gradle Retrolambda wordpress plugin which backports Java 8’s lambda syntax to Java 6 (and earlier) through some clever compiler magic.

Setup is essentially as easy as adding a couple of lines to your build.gradle file and adding an addiction around the Functional Java library – full particulars take presctiption the project’s Github pages.

Now let’s look again at our example situations pointed out above:

Producing a summary of contributing factors a person has read more often than once, together with counts for the amount of articles with that contributor they’ve read.

This is how that may try looking in crucial classic Java style:

Here is the running implementation, thanks to the running Java library and Java 8 lambda syntax:

IOS Developer Malaysia

IOS Developer Malaysia

There’s a couple of things worth leaving comments on here. First of all, the imperative version uses mutable condition to trace the contributor counts – this can be a common supply of bugs cheap we cure it within the functional version is indeed a improvement.

Advertisement

Next, the imperative version is notably more difficult. We’re utilizing an intermediate data structure (the HashMap) and 2 separate loops filled with if claims. This will make ios developer Malaysia a great deal harder to determine instantly exactly what the intent from the code is.

It’s not only harder to see the imperative version however it was harder to create too – you will find a number of various ways it might have been implemented and thus there is lots of upfront intending to consider the benefits and drawbacks of various approaches. Using the functional style, once you understand to consider problems when it comes to list changes there’s only one method to carry it out. The answer becomes so apparent you barely need to consider it whatsoever.

Facebooktwittergoogle_plusredditpinterestlinkedinmail