Readability strongly depends on case, sometimes it is better, sometimes
worse.
Additionaly it is also a matter of personal preference.
Paralelization is easy, Just use
https://docs.oracle.com/javase/8/docs/api/java/util/stream/BaseStream.html#parallel--

But there is a trap. All invocations use the same thread pool. And it
doesnt work nicely with exceptions.

Debugability myabe an issue. Stack traces are also more chatty.




niedz., 29 sty 2023, 16:06 użytkownik Eric Bresie <ebre...@gmail.com>
napisał:

> My understanding is the Stream/lambda usage provides a "functional" way of
> doing things, (some say) better readability, and provides opportunities for
> parallel processing (i.e. the internal mechanisms leverage the
> multi-core/process artifactures a little better if I understand correctly).
>
> Eric Bresie
> ebre...@gmail.com
>
>
> On Sun, Jan 29, 2023 at 8:56 AM Laszlo Kishalmi <laszlo.kisha...@gmail.com
> >
> wrote:
>
> > As of readability and debug-ability, I'm sorry to say but old-school
> wins.
> >
> > It starting to look like when you found the hammer everything seems to
> > be a nail...
> >
> > On 1/29/23 02:21, Łukasz Bownik wrote:
> > > I can't help it!!!!
> > > It's stronger than me!!!!!
> > >
> > > AAAAAARGH!!!!!
> > >
> > > ;););););)
> > >
> > >
> > >      toURLs(Stream.of(prjs).
> > >                flatMap(this::toArtifacts).
> > >                flatMap(this::toLocations).
> > >                collect(toList());
> > >      }
> > >
> > >      private Stream toArtifacts(Project prj) {
> > >
> > >          return Stream.of(findArtifactsByType(prj, ARTIFACT_TYPE_JAR));
> > >      }
> > >
> > >      private Stream toLocations(Artifact a) {
> > >
> > >          return Stream.of(a.getArtifactLocations());
> > >      }
> > >
> > >
> > >
> > > On Sun, Jan 29, 2023 at 9:44 AM Svata Dedic <svatopluk.de...@gmail.com
> >
> > > wrote:
> > >
> > >> And what about old school
> > >>
> > >>           List<URI> uris = new ArrayList<>(prjs.length);
> > >>           for (Project p : prjs) {
> > >>               for (AntArtifact a :
> > >> AntArtifactQuery.findArtifactsByType(p,
> > >> JavaProjectConstants.ARTIFACT_TYPE_JAR)) {
> > >>
>  uris.addAll(Arrays.asList(a.getArtifactLocations()));
> > >>               }
> > >>           }
> > >>           return toURLs(uris);
> > >> ? Streams and lambdas are very modern, fancy and cool, but if it ever
> > >> comes to debugging are just pain in the ass.
> > >>
> > >> -S.
> > >>
> > >> On 29. 01. 23 6:59, name name2 wrote:
> > >>> toURLs(
> > >>> Arrays.asList(prjs).stream().flatMap(
> > >>>       (prj) -> Arrays.asList(
> > >>>               AntArtifactQuery.findArtifactsByType(prj,
> > >>> JavaProjectConstants.ARTIFACT_TYPE_JAR)
> > >>>       ).stream()).
> > >>>       flatMap((a) ->
> Arrays.asList(a.getArtifactLocations()).stream()).
> > >>>       collect(Collectors.toList())
> > >>> );
> > >>>
> > >>> to
> > >>>
> > >>> toURLs(
> > >>> Arrays.stream(prjs).flatMap(
> > >>>       (prj) -> Arrays.stream(
> > >>>               AntArtifactQuery.findArtifactsByType(prj,
> > >>> JavaProjectConstants.ARTIFACT_TYPE_JAR)
> > >>>       )).
> > >>>       flatMap((a) -> Arrays.stream(a.getArtifactLocations())).
> > >>>       collect(Collectors.toList())
> > >>> );
> > >>>
> > >>>
> > >>> Its ProjectClassPathModifier.java
> > >>>
> > >>> 8 files changed:
> > >>>
> > >>>      -
> > >>>
> > >>
> >
> extide\gradle\src\org\netbeans\modules\gradle\loaders\ExtensionPropertiesExtractor.java
> > >>>      -
> > >>>
> > >>
> >
> groovy\groovy.editor\src\org\netbeans\modules\groovy\editor\api\parser\GroovyParser.java
> > >>>      - ide\db\src\org\netbeans\api\db\explorer\ConnectionManager.java
> > >>>      -
> > >>>
> > >>
> >
> java\java.project\src\org\netbeans\api\java\project\classpath\ProjectClassPathModifier.java
> > >>>      - nb\autoupdate.pluginimporter
> > >>>      -
> > src\org\netbeans\modules\autoupdate\pluginimporter\Installer.java
> > >>>      -
> > >>>
> > >>
> >
> test\unit\src\org\netbeans\modules\autoupdate\pluginimporter\InstallerTest.java
> > >>>      - o.n.upgrader\src\org\netbeans\upgrade\AutoUpgrade.java
> > >>>      - test\unit\src\org\netbeans\upgrade\AutoUpgradeTest.java
> > >>>
> > >>>
> > >>> Can i make PR or not?
> > >>>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
> > >> For additional commands, e-mail: dev-h...@netbeans.apache.org
> > >>
> > >> For further information about the NetBeans mailing lists, visit:
> > >> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
> > >>
> > >>
> > >>
> > >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
> > For additional commands, e-mail: dev-h...@netbeans.apache.org
> >
> > For further information about the NetBeans mailing lists, visit:
> > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
> >
> >
> >
> >
>

Reply via email to