riccardoNovaglia / jbrains-pos

0 stars 0 forks source link

An example of a "structural name" #3

Open jbrains opened 6 years ago

jbrains commented 6 years ago

https://github.com/riccardoNovaglia/jbrains-pos/blob/5482f8ffb79e9e228b57eb3717fc6421ffcd0d8c/src/main/scala/pos/PointOfSale.scala#L13

This is not necessarily a problem, but this function name looks like a "structural name" to me. (See http://blog.thecodewhisperer.com/permalink/a-model-for-improving-names for more information.) What might happen if you tried to improve this name?

riccardoNovaglia commented 6 years ago

I agree, I cringed as I wrote it, but couldn't think of a better version at the time. As you mentioned in the videos I thought of the idea of using a guard, but I think I'd like even more the idea that this class doesn't actually receive invalid barcodes in the first place, so if the barcode is empty my pos class is not even called. I guess it depends if displaying a message when the barcode scanned is empty is a hard requirement or something we can discuss.

jbrains commented 6 years ago

I address this issue later in the course. In the meantime, you can think about what might be missing that would encourage you to fix this problem, and then also what would have to happen for you to need to build the missing thing.