Content deleted Content added
Improved the C# Example and added comments. |
→C# example: add image |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 31:
}}</ref>
== C#
[[File:Non-virtual interface pattern.svg]]
<syntaxhighlight lang="c#" line="1">
public abstract class Saveable
Line 37 ⟶ 39:
// The invariant processing for the method is defined in the non virtual interface.
// The behaviour so defined is inherited by all derived classes.
// For example, creating and committing a transaction.
public void Save()
{
Line 44 ⟶ 47:
}
//
// This behaviour can be customised as needed by subclasses.
// For example the specific implementation of saving data to the database.
protected abstract void CoreSave();
}
Line 57 ⟶ 61:
protected override void CoreSave()
{
Console.WriteLine($"Saved customer {
}
}
|