Driving, Surviving and Thriving Industry Disruption With APIs

A simple online shopping task or purchase used to be extraordinary. That was yesterday’s news. Today companies such as Rogers Communications put live NHL game content in the hands of a mobile user; General Motors gives drivers the ability to start, stop and understand diagnostic information even when remote from the vehicle; and L’Oréal keeps retail partner and shopper loyalty high with fully-integrated product stock and pricing information.These user engagement experiences have lasting effects. They impact the way we live, work and compete. Companies are no longer being compared to the competitors within their own traditional boundaries, but to all organizations that are delivering a great customer experience.Continuous Innovation Through APIsWhat we have learned through industry disruption is that those who compete and are digital disruptors in existing or new industries find new ways to continually innovate. The newly released API research report, “APIs and the Digital Enterprise: From Operational Efficiency to Digital Disruption” uncovered key areas digital disruptors are investing in to adapt and thrive in the new application economy.1. Release engaging apps faster: To deliver optimal digital experiences businesses need to get apps out faster, understand usage sooner and iterate more often. It is not about delivering the most features but the right features in today’s experience driven world. 84 percent of organizations are using or planning to use APIs to speed delivery of revenue enhancing apps.2. Unlock data silos to improve customer experience: Businesses need to tap in to useful data that is often hidden away in silos, accessed very little or never at all. The ability to use information to deliver a more engaging experience across channels based on consumer insights provides a much more convenient and personalized experience that keeps customers coming back. 85 percent of organizations are using or planning to use APIs to deliver new and better customer experiences.3. Expand reach through digital ecosystems: Successful digital organizations must find a way to open up information and expand digital ecosystems. The ability to effectively share information will allow digital disruptors to extend reach and access entirely to new markets. Understanding how to connect and share data will enable companies to capitalize on the network effect ecosystems offer. 84 percent of organizations are using or planning to use APIs to extend their digital reach.L’Oréal: How APIs Drove Consumer Goods InnovationAs the world’s largest cosmetics company, L’Oréal is dedicated to beauty. L’Oréal sought to modernize on a single ecommerce platform in the Americas, with the ability to support any combination of digital, retail and partner channels through a consistent set of APIs. L’Oréal witnessed a 5X increase in the number of application connections without having to expand development teams. In addition, L’Oréal was also able to tap in to the value of customer data, combining it with merchandise to deliver a better customer experience. This took shape with the L’Oréal Makeup Genius app, which delivered an innovative omni-channel virtual experience of trying on makeup. Finally, L’Oréal was able to open and share product data with partners such as Target. This helped reduce operational costs, cutting down inventory overage, while ensuring shelves were filled with accurate pricing. This all was possible through APIs.Why API ManagementSuccessful organizations such as L’Oreal have found API Management necessary for their API projects. The right API Management solution should effectively allow organizations to create APIs and integrate with data, secure and mitigate the risk of APIs, accelerate the development of mobile and IoT apps connecting to APIs and unlock the value of data by engaging in new digital ecosystems. See www.ca.com/api to learn more how CA API Management can help. Read more

Democrat gun control sit-in sparks social media sensation

A blackout of television cameras in the U.S. House Representatives during the Democrats' gun control sit-in may have spurred public interest in the protest as it forced the demonstrators to use social media to broadcast their message.Democrats leapt on Facebook Live and Twitter's Periscope after the cameras, controlled by the House, went dark Wednesday when presiding House officer and Republican Representative Ted Poe declared the chamber not in order during the protest.As Democrats took to alternative forms of video broadcasting, their message gained tremendous momentum from social media. On Twitter, the hashtags #NoBillNoBreak and #HoldTheFloor have been tweeted at least 1.4 million times.Of the roughly 20 members of Congress who remained at the sit-in overnight, 19 of them used Facebook Live for a total combined viewership of 3 million.“It really connected with people out there,” Congressman Scott Peters told Reuters. "This whole phenomenon with [live video] struck a nerve."Peters used the application Periscope, which is connected to the social media platform Twitter, to send out video. “Without that, think about it, it would have been a caucus meeting where we talk to ourselves," he added. In remarks Wednesday outside the Capitol, House Democratic Leader Nancy Pelosi praised how her party harnessed social media."Without you and without the technology of Periscope [the sit-in] would just be a debate in the Halls of Congress unrecorded because they turned off the microphones," Pelosi said. "But we raised our voices. They turned off the cameras and we went to Periscope." Congressman Mark Takano, who began posting live videos from the chamber to his Facebook page Wednesday afternoon and continued to throughout the night, said the social media video helped him connect with constituents."Once I got started with the live streaming I didn’t feel like I could let down the people who were following me,” said Takano. “It was a way to push out a message.”Even C-SPAN, which typically broadcasts footage recorded by the House cameras, picked up live video from four different members of Congress roughly two hours after the House cameras shut down, according to communications director Howard Mortman. It marked the first time the channel broadcast a live social media feed from the House floor. "Something interesting is happening with Facebook Live that's bringing more openness to the political process," said Mark Zuckerberg, CEO of Facebook, in a post to his social media profile Thursday."It's a way to share anything you want with the world using just your phone." (Reporting By Amy Tennery; additional reporting by Angela Moon in New York and Susan Cornwell in Washington; Editing by Andrew Hay) Read more

Folding the Universe, Part II: Abstracting Recursion

This is a series of articles complementing my book, Functional Programming in Java. The previous article in this series may be found here:Folding the Universe, Part IIn the the previous article in this series, I showed how to write a functional Java program solving the Knapsack problem, which consists of packing a knapsack of a given capacity with items from a collection, while maximizing the knapsack's value, given that each item has a weight and an individual value. Of course, we must not exceed the knapsack capacity. This problem may be applied to dividing any quantity (the knapsack capacity) in parts (the items) while maximizing the value, which might, in some cases, mean minimizing the unused capacity (when the value of each item is proportional to its weight). There are indeed several variants of this problem, the most common two being packing with a single copy of each item and packing with as many copies as wanted of each item. An example of solving this problem in traditional imperative Java may be found here: Knapsack problem/0-1. Please have a look at it before reading this article.The ChallengeAs I said in the previous article, the challenge is to solve the problem while using no variables (only constants) and no control structures, but only using classes and methods, arithmetic operations and comparisons, and Java 8 Function and BiFunction. I showed a bi-recursive version in the previous article, and explained why it was not really usable (at least for lists of items longer that thirty elements). Our new challenge is to write this same program without using recursion at all, except for the folds, which are abstracted in the List class that we have defined. If you haven’t read part I, please do so before reading this article. (Folding the Universe, part I)How to Avoid RecursionTo avoid bi-recursion, we have to memorize the result of each step in order not not have to compute it again and again. It is obvious that when examining an item to see if we should put it in the knapsack, we must consider what we have already put into it in previous steps. What we will do is:Build a list of knapsacks of capacity varying from 1 to the given capacity, in reverse order.For each item in the list:Try to put it in all of the knapsacks. In the previous example, we tested the item weight to see if it would fit in the knapsack. Here, for each knapsack, we will first filter out the items which capacity exceeds the knapsack capacity.Find the knapsack corresponding to index (item.weight - 1) and add the item to it.Find the knapsack of maximum value and add it to the listFrom the resulting knapsack list, select the one with the maximum value. This is the result of the packing.Note that if we add a knapsack to the list, we put it in front of the list. So, the knapsack with the maximum value will simply be the head of the list. This is why we select the knapsack of index (item.weight - 1). This would correspond to an index of i - it.weight if the list was build the other way, where i would be the index of the knapsack we are in.Here is the corresponding code:public static Knapsack pack(List items, int capacity) { final Knapsack zero = empty(capacity); (1) final List result = List.range(capacity + 1, 1).foldRight(List.list(), (i, acc) -> { (2)(3) Knapsack knapsack = items.filter(item -> item.weight <= i) (4) .flatMap(item -> acc.at(item.weight - 1).map(k -> k.add(item))) (5) .foldRight(zero, Knapsack::maxValue); (6) return acc.cons(knapsack); (7) }); return result.head().foldRight(zero, (a, b) -> a); (8) }(1) A "zero" knapsack is created with the given capacity. This is just a convenience to avoid calling the Knapsack.empty() method several times.(2) A list of integers from the given capacity to 1 is built by calling the range method. This method must be added to the List class.(3) This list of integers is mapped to a list of knapsacks. While constructing this list (named acc, for "accumulator", by convention), the previously created knapsacks are available.(4) We filter the items so that we won’t try to insert items with a weight higher than what the knapsack may contain.(5) We look for a previously created knapsack of index item.weight - 1. The List.at(n) method has to be created and it will return optional data, which mean a list of zero (not found) or one (found) knapsack. If this knapsack is found, the item is added to it, which is done by mapping the function k → k.add(item) to the singleton knapsack list.(6) From the resulting list, we select the knapsack with the maximum value.(7) The resulting value is added to the (head of) accumulator. This concludes the function used for folding the list of integers, in (3).(8) Once the list of integers is folded to a list of knapsacks, we just have to select the maximum value, which is automatically the head of the list. As the head method returns a singleton list, we use a "getOrElse" technique to select either the value if it is present, or a default value if not.The technique used here is very well known in functional programming and is called memorization. It consists in keeping access to the previous results instead of recomputing them at each step. This technique is also used in imperative programming. The particularity of the functional programming version is the way the previous results are transported during the fold (in the acc parameter).Implementing the Missing MethodsIn this example, we have used two new methods that are missing in the List class. The range method is a convenience method allowing creating a list of integers from start (included) to end (excluded) if start is lower than end. Otherwise, the list is constructed in reverse order. The fact that start is included and end is excluded is purely conventional. Here is the corresponding implementation in the List class:public static List range(int start, int end) { return start < end ? rangeAsc(list(), start - 1 , end - 1) : rangeDesc(list(), end, start); } private static List rangeAsc(List acc, int start, int end) { return start == end ? acc : rangeAsc(new Cons<>(end, acc), start, end - 1); } private static List rangeDesc(List acc, int start, int end) { return start == end ? acc : rangeDesc(new Cons<>(start, acc), start + 1, end); }The List.at(n) method allows indexed access to the list. It is not very efficient, since it needs time proportional to n, but is is perfectly usable when n is low. Here is the implementation:public List at(int n) { return tail().flatMap(t -> n == 0 ? head() : t.at(n - 1)); }This method is even less efficient since it uses the head method defined in the previous article. We will fix this in the next section.Solving the Real ProblemBeside efficiency, we have a more important issue: our program does not solve our real problem, because it allows using several times the same item. It was done this way for simplification. Now, we can fix this easily:public static Knapsack pack(List items, int capacity) { final Knapsack zero = empty(capacity); final List result = List.range(capacity + 1, 1).foldRight(List.list(), (i, acc) -> { Knapsack knapsack = items.filter(item -> item.weight <= i) .flatMap(item -> acc.at(item.weight - 1).map(k -> k.contains(item) ? k : k.add(item))) (1) .foldRight(zero, Knapsack::maxValue); return acc.cons(knapsack); }); return result.head().foldRight(zero, (a, b) -> a); }(1) We put the element in the knapsack only if it has not yet been used, which simply means that the knapsack does not already contain it.To make this possible, we must add the contains method to the Knapsack class:private boolean contains(Item item) { return items.contains(item); }This method simply delegates to the List.contain(a) method. Guess what this method will be based on? Bingo! A fold:public boolean contains(A a) { return foldLeft(false, (result, b) -> a.equals(b) || result); }Again, this method is not optimized, since it will have to traverse the whole list instead of escaping as soon as a matching element is found.Note that we must define an equals method in our Item class. I will not show it here, since you certainly know how to do this. Moreover, any good IDE will generate it for you. However, to be really complete, we should add a unique ID to the Item class. Forgetting to do so will make it impossible to have two different items with the same weight and value in the list. A very simple way to do this, if the ID is not to be used for anything else, is to generate a UUID and use it for equality:public class Item { public final String name; public final int weight; public final double value; private final UUID id = UUID.randomUUID(); (1) private Item(String name, int weight, double value) { this.name = name; this.weight = weight; this.value = value; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Item item = (Item) o; return weight == item.weight && Double.compare(item.value, value) == 0 && (name != null ? name.equals(item.name) : item.name == null && id.equals(item.id)); (2) } ...A random UUID is generated, and it is used to test equality.Representing the Absence of DataIn this example, we had to represent data that could be present or absent. For example, a method returning the first element of a list could return nothing if the list is empty. Traditional languages use the null reference, invented by Sir Charles Antony Richard Hoare (a.k.a. "Tony Hoare"), which is what he called his "million dollars mistake". The null reference is the plague of programming because it does not compose. This is something it has in common with exceptions (to which it transposes very easily!). This does not mean it is not possible to compose it, but it does not compose transparently by itself. The programmer has to handle it separately through some control structures.In the previous article, we saw that it was perfectly possible to use a list to represent optional data. Absence of data is represented by an empty list, and data is represented by a singleton list. The main problem is that there was no mean to differentiate a normal list from a singleton list. The good thing is that it is very easy to compose both.Another possibility is to use a special class to represent singleton lists. We might call this class Option. It will be identical to the List class, with two main exceptions: there is no cons method (since we can’t add elements) and the folding methods generally do not take a function argument. It could however take one, but it would in most use cases be the identity function, which is why it is most often implemented without this function argument. This method will then simply return either the included value, if it is present, or the "zero" value if not. Of course, the "zero" value will have a more explicit name such as default, but this (like names in general) is irrelevant. Here is a minimal Option class:public abstract class Option { public abstract B foldRight(B identity, BiFunction f); public Option map(Function f) { return foldRight(none(), (a, option) -> some(f.apply(a))); } public Option flatMap(Function> f) { return foldRight(none(), (a, option) -> f.apply(a)); } public Option filter(Predicate p) { return foldRight(none(), (a, option) -> p.test(a) ? some(a) : none()); } public A getOrElse(A defVal) { return foldRight(defVal, (a, b) -> a); } private static class None extends Option { @Override public B foldRight(B identity, BiFunction f) { return identity; } public String toString() { return "None()"; } } private static class Some extends Option { private final A value; private Some(A value) { this.value = value; } @Override public B foldRight(B identity, BiFunction f) { return f.apply(value, identity); } public String toString() { return String.format("Some(%s)", value); } } @SuppressWarnings("rawtypes") private static Option NONE = new None(); @SuppressWarnings("unchecked") public static Option none() { return NONE; } public static Option some(A a) { return new Some<>(a); } }What Option Changes to Our ExampleUsing Option to represent optional data instead of a list brings some benefits in the sense that a program is often easier to read if we can easily distinguish between true lists (which can contain any number of elements) and singleton lists representing optional data (which can only contain zero or one element). By the way, the difference is not always visible, since type may sometimes be inferred, such as when chaining methods. Here is our pack method using Option instead of List for optional data:public static Knapsack pack(List items, int capacity) { final Knapsack zero = empty(capacity); final List result = List.range(capacity + 1, 1).foldRight(List.list(), (i, acc) -> { Knapsack knapsack = items.filter(item -> item.weight <= i) .sequence(item -> acc.at(item.weight - 1).map(k -> k.contains(item) ? k : k.add(item))) (1) .map(list -> list.foldRight(zero, Knapsack::maxValue)) (2) .getOrElse(zero); (3) return acc.cons(knapsack); }); return result.head().getOrElse(zero); (4) }(1) The flatMap method can’t be used, since it produces a List Here, we produce an Option, but this would not be visible if we had kept the name flatMap for the method. We will of course have to define the Option.sequence method.(2) The map method is called on an Option, but it is difficult to see by looking at the code!(3) Getting the value (if present) or a default value (if not) is done through the getOrElse method. We changed the name to follow conventional usage although it is implemented through a fold!(4) We can simplify getting the value or default value from the resulting Option.The map and getOrElse method can be seen in the previous listing of the Option class. You can see that Option is really a List. The problem happens when a list is mapped with a function returning an Option. When we were using a list for optional data, the function was returning a List, so we ended with a List>. Getting a List instead was just a matter of using flatMap instead of Map. With Option, we end with a List. So we have to create a method for this. We will put it in the List class. By convention, this method is called sequence. In order to better mimic the List.flatMap method, we will also add a convenience sequence method taking a function returning an Option as its argument:public Option> sequence(Function> f) { return sequence(map(f)); (1) } public static Option> sequence(List> list) { return list.foldRight(Option.some(List.list()), (oa, acc) -> map2(oa, acc, (a, b) -> b.cons(a))); (2) } public static Option map2(Option a, Option b, BiFunction f) { return a.flatMap(av -> b.flatMap(bv -> Option.some(f.apply(av, bv)))); (3) }(1) This method is a simple convenience allowing applying the function and calling sequence in a single operation that mimics the List.flatMap method.(2) The sequence method uses a foldRight (to preserve the list order) and a utility method map2 transforming a BiFunction into a BiFunction, Option, Option>(3) This is a very common idiom in functional programming. If you have trouble to understand it, you should insist until you succeed. It is not complicated. The first flatMap give access to the value contained in the first Option (av). The second nested flatMap does the same for the second Option, producing the value bv. We can apply the function to these two values, producing a C. As we want an Option, we just wrap it into an Option.Some.Note that the map2 implementation is not optimal. We must take the value out of the first Option, thus using flatMap. But we are not forced to do the same with the second. An alternate (and far more common) solution is to map the second option with the function:public static Option map2(Option a, Option b, BiFunction f) { return a.flatMap(av -> b.map(bv -> f.apply(av, bv))); }ConclusionWe have now completed our functional Knapsack example. If you compare to traditional imperative Java (for example Knapsack problem/0-1), you may think that the functional version is not shorter. This is true. You may also think it is not easier to understand. This is totally subjective. I found it cristal clear and I have trouble to understand the imperative version. But this is because I am used to functional programming, and I am reluctant to read imperative programs.So what are the benefits of the functional programming version? The main benefit is that we have abstracted a great deal of the program in classes (List and Option) that may be reused for solving other problems. Of course, Java has also List and Optional. Just try to write the same program with these classes and see for yourself. The real result is that beside the business code (the Item class and most of the Knapsack class), our program is less that ten lines long. As you know, the shortest the code, the fewer the bugs.Of course, there is plenty of room for optimization. We will look at some in a next article, while trying to solve a different problem. In the meantime, if you are interested in more advanced techniques about the subject, have a look at my book: Functional Programming in Java. Read more

Einstein 2.0: gravitational waves detected for a second time

CAPE CANAVERAL, Fla.,  The ground-breaking detection of gravitational waves, ripples in space and time postulated by Albert Einstein 100 years ago, that was announced in February was no fluke. Scientists said on Wednesday that they have spotted them for a second time.The researchers said they detected gravitational waves that washed over Earth after two distant black holes spiraled toward each other and merged into a single, larger abyss 1.4 billion years ago. That long-ago violent collision set off reverberations through spacetime, a fusion of the concepts of time and three-dimensional space.These gravitational waves were observed by twin observatories in the United States late on Dec. 25, 2015 (early on Dec. 26 GMT). The detectors are located in Livingston, Louisiana, and Hanford, Washington.The first detection of gravitational waves was made in September and announced on Feb. 11. It created a scientific sensation and was a benchmark in physics and astronomy, transforming a quirky implication of Einstein's 1916 theory of gravity into the realm of observational astronomy.The waves detected in September and December both were triggered by the merger of black holes, which are regions so dense with matter that not even photons of light can escape the gravitational sinkholes they produce in space. The merging black holes that set space ringing in December were much smaller than the first pair, demonstrating the sensitivity of the recently upgraded Laser Interferometer Gravitational-wave Observatory, or LIGO, facilities."We are starting to get a glimpse of the kind of new astrophysical information that can only come from gravitational-wave detectors," said Massachusetts Institute of Technology researcher David Shoemaker. The black holes that triggered the newly detected gravitational waves were eight and 14 times more massive than the sun, respectively, before merging into a single, spinning black hole about 21 times more massive than the sun. The equivalent of one sun's worth of mass was transformed into gravitational energy.The Louisiana site detected the waves first and the Washington state detector picked up the signal 1.1 milliseconds later. Scientists can use the timing difference to calculate a rough idea of where the black holes merger occurred. Scientists say the second detection confirms that pairs of black holes are relatively common.  "Now that we are able to detect gravitational waves, they are going to be a phenomenal source of new information about our galaxy and an entirely new channel for discoveries about the universe," Pennsylvania State University astrophysicist Chad Hanna said.The research, presented at the American Astronomical Society meeting in San Diego, will be published in the journal Physical Review Letters. (Reporting by Irene Klotz; Editing by Will Dunham) Read more

In the lab: six innovations scientists hope will end malaria

ARUSHA, Tanzania (Thomson Reuters Foundation) - After being abandoned as too ambitious in 1969, global plans to eliminate malaria are back on the agenda, with financial backing from the world's richest couple, Bill and Melinda Gates, and U.S. President Barack Obama.The Gateses aim to eradicate malaria by 2040 by doubling funding over the next decade to support the roll out of new products to tackle rising drug resistance against the disease.Their goal of permanently ending transmission of the disease between humans and mosquitoes is more ambitious than the Sustainable Development Goal of ending epidemic levels of malaria by 2030.They are also supporting a push to create the world's first vaccine against a parasite.Six innovations scientists are working on are:* New insecticides: Mosquitoes are becoming resistant to insecticides used to spray inside homes and in bed nets."There is no current insecticide that doesn't show insect-resistance at the moment," said Jed Stone, a spokesman for the UK-based Innovative Vector Control Consortium (IVCC).Indoor spraying of walls with insecticide -- which was used to wipe out malaria in the United States in the 1940s -- has fallen by 40 percent since 2012 due to resistance to older products and the high cost of newer ones. The IVCC is developing three new insecticides for use in indoor sprays and bed nets that kill insecticide-resistant mosquitoes. "The insecticides are virtually ready but it will take about five years to finally develop them," Stone said, adding that this largely involves registration with regulators. * A single-dose cure: A pill that would wipe out all parasites in the body could be available by 2019, the Gates Foundation says.Human trials of one candidate are planned following successful tests on mice, published in 2015. Existing drugs have to be taken for three days with the risk that people do not finish their medication, contributing to the development of drug-resistant malaria. They also only kill parasites at the asexual-stage where they cause fever but not at the sexual-stage where they are picked up by mosquitoes in blood.* Insecticide-treated wall liners: Scientists hope insecticide-treated wall liners, which look like wallpaper, will be more effective than spraying people's homes with insecticide every three to eight months. The wall liners kill mosquitoes that rest on them and can last for three years. Tanzania's National Institute for Medical Research is testing wall liners in 6,000 homes to see if they protect people from malaria. Results will be published in 2017.* Insecticide-embedded clothing: American soldiers have been wearing combat uniforms treated with permethrin, a synthetic insecticide, since 2010 to protect them against insect-borne diseases.The U.S. government's Walter Reed Army Institute of Research will test the effectiveness of treated combat uniforms and repellent creams in July on Tanzanian soldiers who often catch malaria when working at night as peacekeepers.* A vaccine: This is a big one, given vaccines success in eliminating smallpox, polio and measles in many countries. More than 30 malaria vaccines are under development. The Mosquirix vaccine, discovered in 1987, is a decade ahead of other candidates but, to date, it only halves the number of bouts of malaria young children suffer.The World Health Organization is seeking funding for a pilot program to administer Mosquirix to 400,000 to 800,000 African children. The results will be used to make a decision on whether to use the vaccine more widely. * GM mosquitoes: Scientists have genetically modified (GM) mosquitoes by adding genes that block the development of the malaria parasite inside the insect and prevent it from being transmitted to people.Scientists have also genetically modified mosquitoes to make them infertile, so that they die out. But many are cautious about the unforeseen consequences of this."When people imagine a malaria end game scenario, GM mosquito technology would be incredibly powerful because it doesn't rely on a robust health system in order to go in and disrupt transmission of the parasite," said Martin Edlund, chief executive of Malaria No More, referring to war-torn countries like South Sudan.The International Center for Journalists and Malaria No More provided a travel grant for this report (Reporting by Katy Migiro; Editing by Katie Nguyen; Please credit the Thomson Reuters Foundation, the charitable arm of Thomson Reuters, that covers humanitarian news, women’s rights, trafficking, property rights and climate change. Visit news.trust.org to see more stories.) Read more

Older Post