[ https://issues.apache.org/jira/browse/OFBIZ-6298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14511179#comment-14511179 ]
Ron Wheeler commented on OFBIZ-6298: ------------------------------------ http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/ is one tutorial. If you google "java stream tutorial" you will find lots of entries. I am not sure how collections are used in OFBiz but there was some talk of using a factory to encapsulate creation of collections. There may be a case for providing high level functions that encapsulate some operations on collections using streams as part of the classes delivered by the factory. If you combine this with the new Java 8 ability to add code to interfaces, there may be some interesting possibilities to reduce the amount of code required in OFBIz and to hide some of the complexity of dealing with the myriad of OFBiz entities. The classes produced by the factory would share the same interface but have some methods overridden in the classes to provide the class specific behaviour. I have started to use Streams in other applications that I have written and they do reduce the amount of code required. They do lock you into Java 8 but so does Oracle's short term view of Java 7- OES this year. I have only started to look at rewriting some of the interfaces in my applications to add default methods to the interfaces. This has a lot of potential for my application since it has a lot of classes that share processing patterns to implement plug-ins that are configured at runtime using Spring. It seems to have the potential to make creation of custom plug-ins a lot easier since a new plug-in might only have to override one or two methods to implement new functionality. I would be surprised if this did not apply to OFBiz as well since many business processes have similar flows but require some special processing for different entities within the same family. The ability to pass methods as arguments also should help in these cases as well. If there is an effort to look at collections, it seems that it would be a good time to look at Java 8 since the whole nature of collections is changed and Java 8 does optimization that is not possible in Java 7 without adding a lot of complexity (parallel processing with multi-core optimization). > Java collection use optimized > ----------------------------- > > Key: OFBIZ-6298 > URL: https://issues.apache.org/jira/browse/OFBIZ-6298 > Project: OFBiz > Issue Type: Improvement > Components: ALL COMPONENTS > Affects Versions: Trunk > Reporter: Nicolas Malin > Assignee: Nicolas Malin > Priority: Minor > Labels: collection, performance > > With the javolution collection cleaning (OFBIZ-5169,OFBIZ-5781) , we need to > realize a second pass to control what instantiation would be better. > For List between LinkedList, ArrayList > {quote} > Using ArrayList, rather than LinkedList, as a default is a good approach > because ArrayList will work better in most situations (in terms of > algorithmic runtimes and memory footprints). > However I think it is important to wisely choose ArrayList or LinkedList > based on the context, because sometimes a linked list may be a better choice: > I am not saying we should do it now and we can tackle this at a later moment, > possibly focusing only on list that can be very big and analyzing their usage > to see if array or linked list is better; it would be also nice, when we use > ArrayList, to see if we can predict the capacity of the list and allocate it > at creation: if we can do this we will have a more predictable memory usage > and less unpredictable peaks under heavy load (when the array capacity is > reached and the array is copied to a new one with double capacity). > {quote} > more documentation on : > * > https://docs.oracle.com/javase/tutorial/collections/implementations/list.html > * > http://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist > For Map between HashMap and LinkedHashMap : > {quote} > Javolution Map Iterators return items in insertion sequence (HashMap does > not), so any code relying on the original insertion order must use a > LinkedHashMap. > {quote} > * > http://stackoverflow.com/questions/2889777/difference-between-hashmap-linkedhashmap-and-treemap > If you detect an optimization, please comments this issues -- This message was sent by Atlassian JIRA (v6.3.4#6332)