I gotta say I'm kinda jealous of the newcomers who are getting into programming / computer science today. Only ten years ago this quality in a lesson was not available to me on YT or similar platforms ~FOR FREE~. Big up for the outstanding video!
Go lang is statically typed and it does allow for implicit interfaces. It''s because Kotlin is statically typed using a nominative type system. This is why it why you need to explicitly specify the relation.
Thanks Robert - that's a great clarification... it's not just the static typing. TIL Go is structurally typed! Might have to play with that at some point 👍
Go and Typescript are both structurally typed and Kotlin uses a nominal type system, but all of them are statically typed. This is something people rarely talk about, maybe a video about it would be nice!
There's a mistake in Chapter 13 in the Waiter's UML box: Waiter+ + prepareEntree(name: Entree): Entree? Should be: + prepareEntree(name: String): Entree?
So for proxy classes or to implement the proxy object pattern I can't use the class delegation, one has to manually forward every function call to whatever is the current proxy implementation. 😢
Hey Moamen! Man, thank you so much for the SuperThanks! I'm excited about growing the channel and the community - and your support is a big encouragement!
About the ackwardness of IVehicle and Vehicle. It's pretty obvious here why this naming is suboptimal. All of the cars are Vehicles. Yet the thing called Vehicle is just one example of a vehicle. Why is that one called a Vehicle but not the others? The interface should be called Vehicle and this Base subclass should get a name fitting your domain. Since this is just an example you might end up with a name like BaseVehicle but in a well defined domain this would have a better name.
In the example at 9:05, it's important to note that raceCar2 isn't a Junker; it's a RaceCar that wraps a Junker (line 36). It delegates speed and accelerate() to the Junker (lines 27-28), but it provides its own implementation of makeEngineSound() (line 29). This is roughly the same idea as if RaceCar were to inherit from Junker and override only makeEngineSound().
Hey, thanks for commenting! Yes, it can look unnatural - mostly because it's easiest for us to map our notions of real-world object relationships onto software models - for example, RaceCar "is a" Vehicle, and Vehicle "has a(n)" engine. Many of us learned that kind of mapping early on, and plenty of successful software systems have been largely designed around it. It's helpful because one of the most important characteristics of code is for a human to readily understand it. That shouldn't be our only lens, though. There are additional characteristics (flexibility, performance, scalability, security, etc.) that we should consider, and to understand those, we have to ask what it is that we gain or lose by constructing the relationships one way compared to another (e.g., inheritance vs. composition, recursion vs. iteration, and so on). That's what I hoped to achieve in this video - to demonstrate that inheritance can also be expressed with object composition or class delegation, and to consider the trade-offs involved with each approach.