ksundberg / CS5500

Course project for CS5500 at Utah State University
GNU General Public License v2.0
2 stars 11 forks source link

Material density #33

Closed sharpTrick closed 9 years ago

ostlerc commented 9 years ago

Here is a potential solution: use std::pair<Point, Point> instead. If you are concerned that the data needs to not be modified, then you have a couple ways to go about it. 1. make your parameters be const correct: ie. const std::pair<Point, Point>&, 2. pass by value as Point has a copy/assign constructor and modifying copied data won't affect the caller.

tefu commented 9 years ago

@ostlerc Please no abstraction shaming. You're nitpicking on style.

Here is a potential solution: use std::pair<Point, Point> instead.

RectangularPrism already works under the semantics of having a length, width, and height. If you threw a typedef std::pair<Point, Point> RectangularPrism in there (after making a Point class, of course) any caller would have to know the first Point represents an XYZ coordinate, while the second represents length, width, and height. This is confusing.

The article isn't saying getters and setters are bad to use; it's bashing languages like C++ and Java for making them idiomatic. Admittedly, C++ gives you much more freedom to avoid them (e.g. with C-style structs or STL tuples), but if all we're cutting down on is a few getters in an offhanded class, why bother?

ostlerc commented 9 years ago

I was invited to post a potential solution, I fail to see how it is shaming to peer review and provide feedback. I realize that the feedback is undesired and will stop doing so.

sharpTrick commented 9 years ago

It is I who has written that particular class. @ostlerc and @tehul, thank you for your peer reviews and constructive feedback. I have not had many opportunities to receive feedback on my coding which may or may not be apparent in my style or the lack there of. You both seem to be quite skilled in program fu, I have no doubt more skilled than myself. You have both provided very enlightening perspectives which is more than I could ask for.

@ostlerc thank you for your potential solution, I was really curious about how to achieve a solution without quaziClass offenses. Your solution is indeed a good one. My mind is definitely stuck in a "everything is an object"-java paradigm and I could obviously use all as many differing opinions as I can get.

I think I will leave the code unchanged at this point, my reason being that I believe that in it's current state it has optimal readability which I believe in turn makes optimal usability.

Again, thank you for your reviews. If nothing else this was a good learning experience for me.

tefu commented 9 years ago

No problem, but I'm not that great of a programmer, lol. This project's my first time coding in C++ in over a year.

tefu commented 9 years ago

@ostlerc Yeah, that was bad of me, you're right. It wasn't shaming in any way. Just feedback. I apologize.