Skip to main content

All Questions

0 votes
0 answers
561 views

What is the Best Practice for handling multiple Entities that behave identically?

Because I have multiple entities with unique fields, I need multiple repositories for each one even though each Entity will be handled exactly the same. What is the best way to handle these separate ...
dbrewster's user avatar
  • 139
0 votes
3 answers
270 views

Java Inheritance Problem

I have the finance application where we can have different types of transactions, like balance enquiry, funds transfer, and pin change etc. Now the Transaction is a base class, and there are specific ...
rahul sharma's user avatar
28 votes
7 answers
10k views

Polymorphism case study - Design pattern for morphing?

Imagine two classes: class Person { MarriedPerson marry(Person other) {...} } class MarriedPerson extends Person { } The idea is that a Person is automatically "morphed" to type MarriedPerson ...
1453's user avatar
  • 429
3 votes
2 answers
178 views

When covariance becomes an issue, how can I restructure my code and still be clean?

Suppose I have the following interfaces, GameObject and Enhance. GameObject: public interface GameObject { void prepare(); void use(); void cleanup(); } Enhance: public interface ...
user avatar
0 votes
3 answers
2k views

Are objects that can pass more than one IS-A test really polymorphic?

A number of tutorials on polymorphism state that "Any object that can pass more than one IS-A test is considered to be polymorphic." I wonder what they mean by that, and if that's even a true ...
wolfrevo_kcats's user avatar
6 votes
2 answers
6k views

What is the process of determining which method in a class hierarchy should execute known as?

I thought I understood inheritance and polymorphism, but I was given this question, and I can't, for the life of me, figure out what the proper answer is or what they're trying to get at: The ...
user3533767's user avatar