Giter Club home page Giter Club logo

Comments (16)

yegor256 avatar yegor256 commented on August 16, 2024

@pgermosen I don't think Streams is a good idea in OOP, in general

from cactoos.

yegor256 avatar yegor256 commented on August 16, 2024

@pgermosen as for "predictable" -- I didn't understand. Can you give an example?

from cactoos.

pgermosen avatar pgermosen commented on August 16, 2024

Of course, streams are not oop , but is easy of use.

this example ?

new ForEach(
  new ArrayAsIterable("how", "are", "you"),
  i -> System.out.printf("Item: %s\n", i)
)

jdk 9 forEach in a collection

I understand better this, than the oop approached

List.of("how","are","you").forEach(i-> System.out.printf("Item: %s\n", i) )

from cactoos.

akryvtsun avatar akryvtsun commented on August 16, 2024

@pgermosen from my experience streams and other message driving architectures motivate split data and methods of its processing.

from cactoos.

pgermosen avatar pgermosen commented on August 16, 2024

Yes that is a motive of use.

But what i want to make a point is the following points for a new api to take in account

  • is easy of use
  • readability

the example of To sort a list of words in the file

List<String> sorted = new SortedList<>(
  new IterableAsList(
    new TextAsLines(
      new InputAsString(
        new FileAsInput(
          new File("/tmp/names.txt")
        )
      )
    )
  )
);

for me has the same readability than

if (x==true){
if (n==false){
}
if (y==x){
}else{
if (h==s){
}
}
}

from cactoos.

akryvtsun avatar akryvtsun commented on August 16, 2024

@pgermosen I'm not sure traditional declarative code will be more clear and shorter for this specific task. Moreover, I'm not sure IterableAsList in needed here at all.

from cactoos.

pgermosen avatar pgermosen commented on August 16, 2024

I think api that can be read like this, is clearer(not necessary shorted, sometimes extra text for clarity is a better)
Example 1

    new FileAsInput(
               new File("/tmp/names.txt")
        ).toText().readLines().toSortedList();

Example 2

    new FileAsInput(
               new File("/tmp/names.txt")
        ).toText().readLinesThat(value -> value.contains("Hello") ).toSortedList();

from cactoos.

yegor256 avatar yegor256 commented on August 16, 2024

@pgermosen this "fluent" interface (.toText().readLines().toSortedList()) is very imperative. We want to stay declarative. That's why we need new objects instead of method chaining.

from cactoos.

akryvtsun avatar akryvtsun commented on August 16, 2024

@yegor256 it's quite declarative. The problem is different: it's always hard to support these fluent things combining smth new from individual objects and using inheritance.

from cactoos.

pgermosen avatar pgermosen commented on August 16, 2024

What is more important
clear and easy code for the using developers using the library/framework
or
to be hard to support the fluent api.

from cactoos.

yegor256 avatar yegor256 commented on August 16, 2024

@pgermosen fluent interface is easy to use only because it's your habit to use it. Also, if you want it, there are plenty of libraries that do exactly the same as Cactoos, but in a traditional way.

from cactoos.

fabriciofx avatar fabriciofx commented on August 16, 2024

@pgermosen Do you agree with this solution? If yes, could you close this issue? If not, could you explain why not? Thanks for your attention!

from cactoos.

andriyshevchenko avatar andriyshevchenko commented on August 16, 2024

Don't you like the regular foreach yet present in java language? No lambdas needed. Dont make things too complex.

from cactoos.

llorllale avatar llorllale commented on August 16, 2024

@pgermosen can we close this issue? Our README states the motivations and design principles behind cactoos, and your request is unfortunately incompatible with them.

from cactoos.

llorllale avatar llorllale commented on August 16, 2024

@pgermosen closing due to inactivity

from cactoos.

0crat avatar 0crat commented on August 16, 2024

The job is not in WBS, won't close the order

from cactoos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.