Linked Questions

32 votes
10 answers
8k views

For example,I had seen some codes that create a fragment like this: Fragment myFragment=new MyFragment(); which declares a variable as Fragment instead of MyFragment , which MyFragment is a child ...
ggrr's user avatar
  • 5,893
7 votes
5 answers
2k views

Some times I see an object instantiated this way. ICustomer oCustomer = new Customer Obvious but the Customer class is implementing ICustomer interface in this example. Are there any advantages of ...
Howls Hagrid's user avatar
6 votes
9 answers
4k views

For the fields that you have as encapsulated members of a class, does it make sense to declare their type to be of the interface that you are using? For example: public class PayrollInfo { private ...
Paul Richards's user avatar
3 votes
4 answers
597 views

According to Is "avoid the yo-yo problem" a valid reason to allow the "primitive obsession"?, I should define "price" like this: public class Main{ private Price price; } ...
aacceeggiikk's user avatar
3 votes
4 answers
545 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type possible, so for example: public interface Fruit{ }...
wcminipgasker2023's user avatar
0 votes
3 answers
272 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type as possible. However, I found that a situation ...
wcminipgasker2023's user avatar
1 vote
2 answers
275 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), when creating objects, I should declare the most abstract type, eg : Map hashMap=new HashMap(). ...
wcminipgasker2023's user avatar
2 votes
3 answers
271 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare most abstract type when possible, for example, suppose I'm using an UI ...
wcminipgasker2023's user avatar
0 votes
1 answer
196 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I should declare the most abstract type as possible. However, in some cases I remember, ...
wcminipgasker2023's user avatar
0 votes
2 answers
216 views

According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type possible, but the question is about template class ...
wcminipgasker2023's user avatar