To those confused this is almost the same as getter & setter in classes. Or in simplier terms a wrapper script to view & edit the fields in a struct. Because you won't allow the program to directly view or manipulate its value.
For anyone interested in the average vector thing. You should really set a flag to update the average next time the get avg method is called to reduce the overhead for entering or removing data from the vec
Inheritance is important! Without it, the language im developing wouldnt work! If i can first debug my read instruction, and then make a "brain", and fix objects, i can rewrite itself in itself. That would be great!
It's not an OOP language by any means. It's just better C. C also has structs and library files can be used to hide function implementation. But this isn't OOP
You don't understand the essence of OOP then. Technically C can be used for OOP. It's just that some languages make this easier. And some don't even run without forcing OOP in your mouth.
Great video! One request, when you go into dynamic dispatch: I have a problem on how to deal with mock objects in tests. For example on the raspberry I try to test against mocked SPI and pins traits. But somehow injecting a dependency and accessing the mock functions (like expect, return, times etc.) is impossible, I don't get how dynamic upcasting works. Or do I need a generic struct? Help! =)
Hmm .. Iv'e been OOP-ing for a lifetime now. It seems that it kinda has all that is needed. Usually inheritance for me is 1 or 2 levels deep. I still prefer recomposition so... why make it more complicated? What I am very found of are interfaces. ... But there are traits. With a bit of discipline it is workable but it can turn into a clusterfuck especially with an unreadable language like rust.
So it's 2 years later, is this proposal accepted? It's common case when you encapsulate the behavior based on some state, because of traits can not define data properties to be implemented for Struct/Enum the only way is to use getter/setter methods instead, and then care which of them should public or private
Naah, very poor algorithm: just take a few very large i32 numbers and add them... Your _total_ in update_average() is itself an i32, so what will happen very quickly? Better idea: instead of the average, store the _sum_ as an i64 in the first place. Every time you add an i32, just add. Every time you remove, substract. Calculate the average only when requested. OK, store it as well so that it is only recalculated when a change has happened, otherwise return the stored value.
📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
"It's *so* different, I had to pause recording and get a haircut before I could talk about it."
content idea: going over the changes in the just released rust 2021 edition. i think would be a nice video.
Great idea!
I loved the joke about the video pausing and haircut.... Bogdan, you are a great teacher!
To those confused this is almost the same as getter & setter in classes.
Or in simplier terms a wrapper script to view & edit the fields in a struct. Because you won't allow the program to directly view or manipulate its value.
Nice job! Thanks!
Previously you mention that you worked with TS and JS. It will be interesting to hear what are you using rust for
I'm not using Rust for anything particular at the moment but I plan on doing backend development in Rust. WebAssembly as well.
Same for me. I Wanna try it on the battlefield
For anyone interested in the average vector thing. You should really set a flag to update the average next time the get avg method is called to reduce the overhead for entering or removing data from the vec
Also you could use a moving average, so you don't have to iterate through the array every single time a value is added
Man, I love the way you're explaining things, very good!
You do realize he's mostly just reading the words on the book?
Inheritance is important! Without it, the language im developing wouldnt work! If i can first debug my read instruction, and then make a "brain", and fix objects, i can rewrite itself in itself. That would be great!
Gave this video a huge hug :]
the haircut joke was good though
It's not an OOP language by any means. It's just better C. C also has structs and library files can be used to hide function implementation. But this isn't OOP
You don't understand the essence of OOP then. Technically C can be used for OOP. It's just that some languages make this easier. And some don't even run without forcing OOP in your mouth.
thanks, it was helpful to see the code example
Great video! One request, when you go into dynamic dispatch: I have a problem on how to deal with mock objects in tests. For example on the raspberry I try to test against mocked SPI and pins traits. But somehow injecting a dependency and accessing the mock functions (like expect, return, times etc.) is impossible, I don't get how dynamic upcasting works. Or do I need a generic struct? Help! =)
No helpful replies to followers? =(
You implement functionality through a trait, the mock object provides its own implementation, then you use a trait object to use call the trait api
Hey Rusty, are you currently working as a Rust developer? What type of programming were you doing before systems programming? Thanks bro
I always preferred Composition anyway...
Good luck sir🤞.
how to choose between : rust golang kotlin for entreprise systems (business intelligence erp crm mrp gui marketing web... )
That’s a bachelor pad if I’ve ever seen one.
lol. the haircut part 🤣
Hmm .. Iv'e been OOP-ing for a lifetime now. It seems that it kinda has all that is needed. Usually inheritance for me is 1 or 2 levels deep. I still prefer recomposition so... why make it more complicated? What I am very found of are interfaces. ... But there are traits. With a bit of discipline it is workable but it can turn into a clusterfuck especially with an unreadable language like rust.
Yow bro can also include in part2 of OOP chap17 the rust implementation of state pattern. It's really confusing. Thanks much bro. much
Yup that video is coming up next!
The haircut 😂
So it's 2 years later, is this proposal accepted? It's common case when you encapsulate the behavior based on some state, because of traits can not define data properties to be implemented for Struct/Enum the only way is to use getter/setter methods instead, and then care which of them should public or private
you can create modules which inherit from a parent module, right?
is IMPL the same as CLASS in other languages?
A registered for the cheatsheet, buy didn’t receive one :-)))
Still in the works. You'll receive an email once it's done!
where is sync and send trait video ??
Your missing the self.update_average(); in the add function :) Good Video's!
Damn, dude, that haircut joke, lmao)
Why was this topic so late in the video's?
Sir please make your rust community on discord/matrix. please we really really need it. Thank you :)
Naah, very poor algorithm: just take a few very large i32 numbers and add them... Your _total_ in update_average() is itself an i32, so what will happen very quickly?
Better idea: instead of the average, store the _sum_ as an i64 in the first place. Every time you add an i32, just add. Every time you remove, substract. Calculate the average only when requested. OK, store it as well so that it is only recalculated when a change has happened, otherwise return the stored value.
Too much of anything is bad and using OOP has limits, so rust makes OOP optional which is much better than other languages
Are you me?
1. Bogdan ✔
2. Ukraininan ✔
3. TS/JS Develepoer ✔
4. Want to use Rust for backend ✔
...
🤔
🤔
3 and 4 true
3 and 4
Do you also pronounce it shtruct?
6:01lol
gg