AaronErhardt / AaronErhardt.github.io

My personal blog
https://aaronerhardt.github.io
3 stars 4 forks source link

Update factory.md #19

Closed tronta closed 3 years ago

tronta commented 3 years ago

Maybe I didn't get it, but isn't it like this?

AaronErhardt commented 3 years ago

Not really. The FactoryVec stores both widgets and data, but we don't care how it stores the widgets because that's just part of it's implementation. The idea of a factory is to just have a collection that can be treated like a normal Vec for example but also displays its contents in the form of widgets. So the Counter struct stores the value of a single counter but the FactoryVec can store many Counters. Just like a Vec. So the indices are used to index the data not the widgets.

That section should be more clear, I guess.

tronta commented 3 years ago

I think what could help if you could make the different counter variables more specific by renaming them. So the struct counter could be CounterWidget. Then one could be displayed_counter_value. And then the other init_counter_value.

What do you think?

Btw as an excuse, I'm on the phone only right now. But I guess it is also a good challenge for the documentation 😀

AaronErhardt commented 3 years ago

I just had the same thought! I've renames some variables and made the text section more clear. I also updated the advanced_factories example.

Do you think it's clear now?

tronta commented 3 years ago

Would it be also ok to rename the struct to something more precise? So it's clear that it represents the data structure for the whole widget? (If this is correct) And I don't find created_couter also not that self explanatory. Maybe value_for_created_counter? Even if it's long, it would be clearer.

AaronErhardt commented 3 years ago

I'll think about it. Still Counter is just a normal piece of data. The FactoryPrototype trait then defines how to translate this data into widgets (FactoryWidgets). It's similar to the model type, it just stores data and the widgets store the widgets. But I'll think about how this section could be made more clear.

AaronErhardt commented 3 years ago

I think this text section should now be much more clear: https://aaronerhardt.github.io/relm4-book/book/factory.html#the-model I haven't changed variable names yet because I think they are ok and I haven't had a better idea for them.

tronta commented 3 years ago

I also think it is much clearer mow. Only this sentence should be reworked:: Also, it automatically keeps track of all the changes made its data.

Maybe: additionally it keeps automatically track of all its changes.

AaronErhardt commented 3 years ago

I've improved the last sentence before the code example here: https://aaronerhardt.github.io/relm4-book/book/factory.html#the-model

Do you think that makes in more clear?