97-things-every-x-should-know
97 Things Every Programmer Should Know

Updated a month ago

Harshdeep Mehta (@harshdeep21) started discussion #2

3 years ago · 0 comments

Open

The ??? parameter isn't some new fancy elvis operator, it's asking should I email or snail-mail the item? The context needed to answer this question no longer exists. We have could captured the method of shipment in a boolean or enum and then use an if-then-else to fill in the missing parameter. Another solution would be create two classes that both extend Item. Let's call these DownloadableItem and SurfaceItem. Now let's write some code. I'll promote Item to be an interface that supports a single method, ship. To ship the contents of the cart, we will call item.ship(shipper). Classes DownloadableItem and SurfaceItem will both implement ship.

Missing Opportunities for Polymorphism (Edit this file)

Typo Correction

We could have captured the method of...

No comments on this discussion.


to join this conversation on GitBook. Already have an account? Sign in to comment
Notifications

You’re not receiving notifications from this thread.


1 participant