Interface Implementation-c sharp

An implementing class is free to mark any or all of the methods from the interface as virtual. Derived classes can then override or provide new implementations, just as they might with any other virtual instance method.

For example, a Document class might implement the IStorable interface and mark its Read() and Write() methods as virtual. The developer might later derive new types from Document, such as a Note type. While the Document class implements Read() and Write to save to a File, the Note class might implement Read() and Write() to read from and write to a database.

Document implements the IStorable-required Read() method as a virtual method, and Note overrides that implementation.

To illustrate the implications of marking an implementing method as virtual, the Run() method calls the Read() and Write() methods in four ways:

  • Through the base class reference to a derived object

  • Through an interface created from the base class reference to the derived object

  • Through a derived object

  • Through an interface created from the derived object

As you have seen previously, virtual methods are implemented polymorphically, and nonvirtual methods are not. It turns out that the interfaces created from these references work just like the references themselves. That is, virtual implementations of the interface methods are polymorphic, while nonvirtual implementations are not.

The one surprising aspect is this: when you call the nonpolymorphic Write() method on the IStorable interface cast from the derived Note, you actually get the Document's Write method because Write() is implemented in the base class and is nonvirtual.

To illustrate calling the methods through an interface that is created from the base class reference to the derived object, create an interface reference named isNote. Use the as operator to cast the Document (theNote) to the IStorable reference:

IStorable isNote = theNote as IStorable;

Then invoke the Read() and Write() methods for theNote through that interface.

if (isNote != null) { isNote.Read(); isNote.Write(); }

RELATED POST
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT

TESTING CONSTRAINTS PART TWO

LIFE CYCLE TESTING

TEST METRICS

Independent Software Testing

Test Process

Testing verification and validation

Functional and structural testing

Static and dynamic testing

V model testing

Eleven steps of V model testing

Structural testing

Execution testing technique

Recovery Testing technique


Operation testing technique


Compliance software testing technique

Security testing technique
Here i am adding the further topics list on software testing subject and the topics may be scattered and you can find under different groups.

MAJOR SYSTEM FAILURES IN THE HISTORY

WHAT IS A SOFTWARE BUG ?

ROLE OF A TESTER

SOFTWARE TESTING INTRODUCTION PART ONE

TESTING INTRODUCTION PART TWO

TESTING INTRODUCTION PART THREE

TESTING INTRODUCTIONS PART FOUR

SOFTWARE TESTING FUNDAMENTALS

SOFTWARE TESTING FUNDAMENTALS PART TWO

SOFTWARE TESTING FUNDAMENTALS PART THREE

No comments:

Post a Comment