Home > Net >  Attribute name repetition interface method is how to deal with it?
Attribute name repetition interface method is how to deal with it?

Time:09-25

Want to know how to deal with interface method attribute name repetition is? How to find the article, most of the processing, but I want to know is
1. How to avoid, this should be avoided, compare if either alone write all interfaces, or more than one person write interface separately, there is always may wish, such as the interface of a property name, interface attribute has a name b
2. If unavoidable, then inherited after more than one interface, how do you know if there's a moniker does not implement? All choose "show that implement the interface"?

CodePudding user response:

Don't need to worry about don't need you to worry about things

The same common type, name,

Name, type the same show implementation

Why you don't need to worry about, because we are CTRL +. Let the ides generate its own, the IDE will choose how to implement
Unlike blog garden powder, blog garden like with all sorts of things, the ans of actual production is not tangle at all, is a normal human thinking, we obtained conforms to the human is true, why not for his head every day into the machine's

Here, CTRL +. Generated by machine, the ans for normal smoothly, without breaking thinking,

CodePudding user response:

That is CTRL +. Choose "implementing an interface is a matter of"? Because I don't know whether there are in the interface name repetition, need a an interface to see just know

CodePudding user response:

Can not also explicitly implementing an interface?

CodePudding user response:

refer to the second floor gudamzero response:
that is CTRL +., choose "implementing an interface" is just a matter of? Because I don't know whether there are in the interface name repetition, need a an interface to see just know


We said, the first is accord with human logical thinking,

That what is called conforms to human logic, such as type, name, normal human logical thinking: they are a thing, so don't need you tube whether they have same name

If violation of logical thinking, type, name, but different logic, so as human beings, I'll ask you to refactoring, modify one of the logic to ensure that no conflict (or merging public interface),
If there are integration of third party, unable to reconstruct changes, so can only display implementation,

So: we actually generated, not entangled with the code, technologies, we truly consider is logical, as long as the logic does not conflict, we whether his namesake or do not wish, if logic conflict, can submit report submission requirements of refactoring, couldn't submit the report showed

CodePudding user response:

Are all interfaces, the parent of A is B, B can not Name attribute, because B has the same characteristics with A
Using object-oriented method to think

CodePudding user response:

As long as the name meaningful, I think in the interface name repeat nothing wrong ah.
Such as interface IStudent has a property Name (other attributes such as gender, grade, age is not to say), IPlayer also have an attribute Name (just don't say what other properties such as grade, integral), the realization of the two interface class has a Name attribute is ok, and it is meaningful, students have names, players also have a Name, use the Name of a student interface to get Name is zhang SAN, use the player's Name is zhang SAN, this does not conflict, and is in line with the actual situation.
Such as the school basketball team members of this class is designed, can realize the two interfaces, an instance name is zhang SAN, it can use the student in the class interface to get the name, in the sports arena, players can use interface to get the name.

  •  Tags:  
  • C#
  • Related