c# - Is it advisable to have an interface as the return type? -


I have a set of classes with the same task but with different arguments. However, the function of each class can return many objects. Is it safe to set the return type as the interface?

Each class (using all the same interface) is doing this with different business logic.

  Validate secure IMs like return; & Lt; - This is an abstract class in public boole. IsValid () & lt; - It is in an abstract class {return (validateReturnType.GetType () == type (success)); } Public IMessage valid () {if (name.Length & lt; 5) {validateReturnType = new error ("name must be 5 characters or more."); } Other {Valid return = new success ("name is valid."); } Return valid; Return type; }  

Is the return type of the function tested at any loss of the unit? Apart from this, is it considered a bad design that it is necessary to work for them to work for them to succeed? In this example, Valid () should be run before IsValid () or other IsValid () will always return false.

Thank you.

However, the function of each class can return many objects. Is it safe to set the return type as the interface?

This is good practice and normal. For example the way COM was created, it depends heavily on this method

Does any function Testing the returns type of a function

not

Also, is it considered a bad design that the task is to succeed for them Need to do? In this example, valid () must be run before IsValid () or other IsValid () will always return false.

It's okay to work with object-oriented programming paradigm, working with sockets. Example Before you can send and receive data, it is common to have a connect method. .

It is being said that it is good to have less state than a state as a general rule because it is easy to prove that your program is right, for example, for each function It has to be tested which depends on this function, not in one way but in two ways. The potential program grows rapidly in the states. If you have a lot of states, if you are interested in it then take a look at why the state is a bad thing.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -