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
-
crisz82368y@Grom He created the class AddressBook, he created the method addContact(BufferedReader br), he invoke readLine() for each field, but inside the class instead of outside. What if tomorrow another programmer wants to use that class?
-
crisz82368yPolymorphism is when a class can assume more shapes according to what you want to do. If you create a class which fits only on your code, you're violating polymorphism, aren't you?
-
LLAMS37488yi see where you are coming from now. sounds like AddressBook should really either be an interface or implement an interface that declares the method. the problem isnt so much that the code is inside the class. Just that its the only concrete implementation. But thats ok sometimes. We dont always know what parts of our system are gonna need to change. So sometimes its best to just use the simplest implementation, and then build in abstractions like interfaces etc. when we know that a particular module is susceptible to change or will be extended in future. If you try to build all your abstractions right away you end up with an over-engineered implementation.
Tomorrow I'll have my Java exam. Teacher sent us a code example and I analyzed it, it works correctly but it's full of mistakes about polymorphism. I'm fucking afraid
undefined