Naked Data in OOP (webinar #22)

Поделиться
HTML-код
  • Опубликовано: 26 сен 2024

Комментарии • 7

  • @emanueltrandafir8756
    @emanueltrandafir8756 Год назад +1

    Michael Feathers once said that OOP done right looks like functional programming.
    The example you are giving here, where you would like only the "encapsulator" object to have special privileges/access to the encapsulated object it is something used in FP: the functions are wrapping each other and the data is being passed through by calling the "encapsulated" function or by returning the result: no global (or mutable) variables. What do you think?
    For example, the code from 26:50 would look like this:
    task = farewell(verboseDiff(diff(secretd(), guest()), 5));
    run(task);

    • @yegor256
      @yegor256  Год назад

      I think Michael Feathers is right. The language we designed recently is object-oriented, but looks very much like a functional one: www.eolang.org

  • @HenriOrgan
    @HenriOrgan 7 лет назад +1

    @yegor256 Thank you!
    About the example of the button (10:00). You said: "label" is an attribute of "Button". Yes, I agree, but you don't pass the label to "new Button()". Technically, the label attribute is not about the state of the button, because your constructor has no parameters.

  • @Strategiusz
    @Strategiusz 6 лет назад

    25:55 omg, so the perfect OOP code looks like Lisp? And the objects are organized in a composition like a tree? I think the problem lays in the fact that tree is very restricted and stiff structure and harder to design than some random graph.
    Protection of data for anyone except the parent-object (the super-object that owns the component-object) is not necessary. It can depend on programmer how he organizes those objects and flow of data. Same with Ruby's attr_accessor. I don't use it anymore, just attr_reader sometimes (I think setters are worse than getters).

  • @ChrisAthanas
    @ChrisAthanas Год назад

    This nuanced subject is still lost on so many
    Fake OOP is totally dominant and it restricts the mind by fooling programmers into not exploring true OOP

  • @hectorvallsmondragon
    @hectorvallsmondragon 7 лет назад

    Hi, Yegor. I understand that semantically the URI.getPort() method is not a getter (no matter if internally it's part of state) and Point.getX() definitely is. There is a real need to get the port from a URI object, and it's ok to use the method since it's not a getter. But what about Point.getX()? For the same reason, we will need the X coord. from a Point. Is it ok to make this method public even being a getter? Is in this case when printers have to be used?

    • @siZeOf2011
      @siZeOf2011 7 лет назад

      inside Point we have field X, which known already in constructor, so we just extract it from object.
      inside URI we store only URL, we don't store port inside separated field, so weed need do some calculations for extracting port from stored data and it's behavior, not just getting data
      if we need set URL and port, than, i think, we create some URIWithPort, store inside URI and int, than we implement methods of some IUriBehavior and manage work with encapsulated data..... It's not very good way, because URIWithPort turn into stupid PDO, but easiest way
      P.s. sorry if i wrong, hope Yegor fix me and suggest better way :-)
      P.p.s. thank you for webinar :-)