ghazalghorabi / TDA553-lab1

0 stars 0 forks source link

CRITICAL: Duplicated storage code between CarShop and CarTransporter #37

Closed martinjonsson01 closed 1 year ago

martinjonsson01 commented 1 year ago

It seems you've still got some duplicated code between these two classes. You have implemented an interface on the two classes, but that doesn't eliminate any duplicated code. You need to use composition (just like you did with turbo), where you put the common storage code in a class that you can delegate to.

The storage implementation in CarShop seems a lot more reasonable than the one in CarTransporter, so I'd suggest you use that one in the class you delegate to.

https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarShop.java#L35-L44 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarTransporter.java#L62-L70 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarShop.java#L46-L50 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarTransporter.java#L79-L82 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarShop.java#L78-L81 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarTransporter.java#L84-L87 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarShop.java#L83-L86 https://github.com/ghazalghorabi/TDA553-lab1/blob/01f3360df2ab6d8a3dae4522fac81312009bb5d9/src/CarTransporter.java#L89-L92

martinjonsson01 commented 1 year ago

This is good enough, but I think a lot more common code could be moved to your Loading class.