Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
neeno31464yAnd if you say that coherent business logic is not needed here because he's just aiming to teach the basics I'll fucking strangle you to death.
Coherent business logic IS important so that the student understands the use cases for whatever you're teaching and also shows the advantages of X over Y for use cases like Z.
My classmates all think this is bullshit too, even the absolute newbs, because they see that using generic types here has no advantage. I just hope they don't dismiss generics as "subtyping but worse"... -
Root797674yThe generic cart should take
products, coupons, and combos (groups of products with metadata)and work correctly with all of them. That’s a better generic, and a very common real world case.
I also really like your example of reimplementing ArrayList. Everyone should do that for their languages’ sugary features so they understand how they work and why they are implemented the way they are. -
neeno31464y@Root I'm not sure I understand what you mean. Why make them generic parameters? That way you wouldn't be able to create new coupons and combos at runtime, you'd have to recompile the program.
Related Rants
I bring you all another gem from my computer science course, this time from my OOP class.
The first assignment we made for this class was a simple CLI shop, where you would have basically three main classes:
- A Product class that you extend to create different types of products.
- A Cart class that manages a list of products (basically an ArrayList<Product>) and has some useful methods
- A CLI class to display a simple interface to the user and call methods on a Cart.
Basic OOP stuff, so far so good.
Then for our second assignment the teacher asked us to make Cart a generic class, where you would say Cart<Bagel> and you would only be able to put bagels in it. This makes absolutely no fucking sense, this is not a good use case for generic types since
1) you would never limit your customer's cart to one type of product at compile time.
2) in Cart, you have to cast the generic type to Product to extract any information from the product, like when getting product prices to calculate the total price, so might as well use a fucking ArrayList<Product>
I'm just saying what he's asking us to do has (to our fictional shop's business logic) absolutely no advantage over subtyping.
Also, why the fuck teach generic constraints when you can just tell your students "just cast T to Product", right?
Like fucking hell, couldn't you spend like 10min to come up with a decent assignment that actually teaches generic types the right way? ffs
And just so no one can say "but wut simple assignment would you give to teach students generic types?", here's a simple and much, much better alternative: implementing your own ArrayList. Done. Can't get much better than that, it's a legit use case and teaches you the basics.
Sorry man, you're a great person, you really are, but you suck as a teacher.
rant
oop
college
assignment
retarded
generics
dumb