Комментарии:
Best explanaition, thanks
ОтветитьGreat Lessons!
ОтветитьThanks, Arjan!
Ответить"Can you think of a software library that's badly designed in terms of coupling and cohesion?" - Mine? 🤣
Ответитьyou look similar to john green
ОтветитьTop dank je🎉
ОтветитьArjuna of programming
ОтветитьThumbs up for leaving all the little typos etc. in the video. Everyone runs into that :) Great video! Though, my two cents about naming, as it's all about refactoring anyways: I guess the class names could have been chosen a bit better. VehichleInfo is not descriptive. It doesn't tell me immediately, that it e.g. doesn't include a license number or der thumber of wheels on the car. A bit better would be VehicleType. And the same for Vehicle. VehicleRegistration would be more precisely describing, what it actually does.
ОтветитьYour variable names are wrong. The tax_percentage is not percentage, then it would be e.g. 5, not 0.05. The variable should be named something like tax_fraction. Also "Tesla model 3" is not a "brand", it is a model, the brand is just "Tesla".
But you are right about the exampel. Programming teaching used to start with "Algorithms and data structures". Now many people think that just creating some classes for things and passing objects back and forth is the solution. For most conventional types of applications and software, organizing our data into proper data structures to enable clean and efficient processing is the key.
Your presentation of cohesion and coupling was very clear! However, I noticed that the refactored code is about 50% longer than the original. We also went from 2 classes and 3 methods to 4 classes and 11 methods (counting constructors). I believe the pure amount of code is also an important factor in maintainability.
ОтветитьI think I have to think through my Django application which is a headache.
ОтветитьYou call them metrics, but cannot compute them? 🤔
ОтветитьUnfortunately you perpetuate the habit of declaring instance fields in outside of your init method. This is a bad habit IMO since this kind of declaration suggests that these variables are actually class fields instead of instance fields. Todays Arjan would probably use dataclass anyway.
ОтветитьI just got a pretty project idea, how about visualizing a code to see it's degree of cohesion and depth of coupling chains?
Any idea if something similar to this already exists?
I hate python but I watched the video anyways because nowadays almost nobody talks about cohesion and coupling. As you stated, the concepts shown apply to any language since they are abstract, language independent ones. Grats!
Ответитьcohesion -> "atomicity of purpose"
ОтветитьYou are the best!!!
ОтветитьThank you Arjan for sharing your knowledge in such easy and clear way, appreciate
ОтветитьGreat video Arjan.
One question:
1. def create_vehicle():
return Vehicle(id, license_plate, self.vehicle_info[brand])
2. def add_vehicle_info(self, brand, electric, catalogue_price):
self.vehicle_info[brand] = VehicleInfo(brand, electric, catalogue_price)
Aren't this classes/methods too coupled with Vehicle and VehicleInfo?
Thanks 😜😜
Sir, you are really amazing teacher. Your teaching style is very explicit and clear. But there are several other parts of the programming world I would like to learn from you, and these are (mentioned based on my interests)
1) Data Structure and Algorithms
2) Programming along with any GUI Library (I prefer tkinter)
3) Also teach us about Databases (SQL , NoSql (mongoDb etc))
Thank you Sir, I hope, We'll be blessed with these videos in future.
Great video! However, I do have one question. Why do you define datatypes in the function? This does not have any meaning in Python.
ОтветитьThank you, Arjan. Superb content.
ОтветитьThanks!
ОтветитьYou won't find a carbrained dutch every day. Why, Arjan?
Ответитьgreat slogan: never stop explaining
Ответитьthank you for the great review
ОтветитьImmensely helpful and well explained! Thank you so much...looking forward for more 😃
ОтветитьDear Arjan, thank you for sharing such a detailed and thoughtful video. I loved how you explain the though process of improvement. It's hard to find such content out there. Please keep going. I look forward to studying all of your catalogue (see what I did there!) ;)
Ответитьperfect
ОтветитьGreat content , I just saw two videos and falling in love with the channel .
Is the playlist sorted or it contains independent videos ?
Excellent video. Thank you very much for this serie.
ОтветитьDon't put things in classes when it is not needed. If you don' t use the instance 'self', then just have the function on the module level. Writing everything in classes just tells us you come from Java, and don' t yet fully understand what the purpose of Modules is in Python.
ОтветитьTack!
ОтветитьVehicleInfo - instead of this class, we could have created a Brand class and it's subclasses with diff brands i.e. Volkswagen would be subclass of Brnad, etc., &these suclasses would have attributes like name, tax, catalogue_price, electric, etc., and in main create a function according to the brand name, create objects of that brand. is it a better option or not? sorry for asking such silly question...
ОтветитьOne interesting concept to add to this:
We could define the string we print as the return value of the _str_ method of the class instead.
Then in print method of the class put print(self).
That way we can both print the str with a call to print or get the str as an output to write somewhere else with str(instance)
This is great for very quick drinking games. Take a shot everytime Arjan says vehicle.
ОтветитьAbsolutely outstanding video Arjan! I've been coding Python for ~5 years and always saw these techniques in play but never really knew where they were coming from. Looking forward to the rest of the series.
ОтветитьSuper thankful of this content!
ОтветитьThis is some really good quality video. You covered so many concepts , thanks
ОтветитьWhat is the reasoning behind specificying types to the class attributes line 5`brand: str` VS to the instance attributes `__init__(self, brand: str, ...)`. When should you do which?
ОтветитьCould you do a video on helper funcs like using a utils class or module or moving some code into a _func in a class? I've never seen any good guidance on this but I tend to feel like some of the sorting/formatting code I write is just clutter.
ОтветитьArguably, add_vehicle_info should not fall under Vehicle Registry (which is supposed to only process new registrations) but under a separate module that posts to the vehicle_info database. It would also be convention to add _ infront of generate_vehicle_id and generate_vehicle_license to indicate private methods.
ОтветитьGood channel with very very good content!! Keep sharing your knowledge like this Arjan!!! Thanks so much!!!
ОтветитьIm really happy to have found this channel, I'm really enjoying this Better Python Code playlist!, thank you!
ОтветитьNice video Arjan!
ОтветитьGreat video!
If we want to go further, we can create abstract class and give an object VehicleRegistry to the application and thus increase the decoupling
We can also create another class to compute financial stuff like prices, taxes and even reduction and thus increase coupling.