Practical uses of interfaces in c
Download
1 / 8

Practical Uses of Interfaces in C# - PowerPoint PPT Presentation


  • 221 Views
  • Updated On :

Practical Uses of Interfaces in C#. By Kevin S. Goff. Who is Kevin S. Goff?. Founder and Principal Consultant: Common Ground Solutions 18 years experience - NET/SQL Server/Crystal Reports/Visual FoxPro 2005 Microsoft .NET MVP for C#

Related searches for Practical Uses of Interfaces in C#

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Practical Uses of Interfaces in C#' - braeden


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Who is kevin s goff l.jpg
Who is Kevin S. Goff?

  • Founder and Principal Consultant: Common Ground Solutions

  • 18 years experience - NET/SQL Server/Crystal Reports/Visual FoxPro

  • 2005 Microsoft .NET MVP for C#

  • Author of “The Baker’s Dozen” series in CoDe Magazine(Productivity Tips for .NET, Crystal Reports, and T-SQL)

  • Speaker at 2005 DevTeach, MSDN CodeCamp, .NET User Groups

  • Common Ground Framework for .NET (free framework)

  • Awards/citations from the Dept. of Agriculture/large corporations

  • www.commongroundsolutions.net / [email protected]

  • My Blog: http://www.TheBakersDozen.net

Uses of Interfaces - Kevin S. Goff


Definition of an interface l.jpg
Definition of an interface

  • Interface is a contract that guarantees how a class will behave, and what properties and methods the class will contain. 

  • When you create an instance of a class that implements the interface, you can be assured that the class will contain  every PEM that the interface defined. 

  • Think of the interface as the bullet point list of what will be in the class.

Uses of Interfaces - Kevin S. Goff


Definition of an interface4 l.jpg
Definition of an interface

  • OK…SO WHAT???

  • What does that gain me???

  • A popular INETA speaker has told people that they don't need to know about interfaces…

Uses of Interfaces - Kevin S. Goff


Three examples of interfaces l.jpg
Three examples of interfaces

  • Distributed computing (remoting)

  • Generic Data Binding

  • Reusable data maintenance forms

  • All examples use the Common Ground Framework for .NET (my free framework)

Uses of Interfaces - Kevin S. Goff


Distributed computing remoting l.jpg
Distributed computing (remoting)

  • Example: Login Authentication (must validate user ID/PW, via back-end objects)

    • IUserObject (one method, parms, and result)

    • Server side:

      • Methods that will be called via remoting must inherit from System.MarshalByRefObject

      • public class UserObject : CGS.Business.cgsBaseBusinessObject, Masonry.Interfaces.IUserObject

      • public class cgsBaseBusinessObject : System.MarshalByRefObject

      • Must register the object to be called via remoting through the registered TCP Channel

        TcpServerChannel Tcps = new TcpServerChannel(nTCPPort);

        ChannelServices.RegisterChannel(Tcps);

        RemotingConfiguration.RegisterWellKnownServiceType

        (typeof(Masonry.Server.BusinessObjects.UserObject),

        "UserObject" , WellKnownObjectMode.Singleton);

    • Client side (we don’t have the code, but we have interface and TCP port #

      • Create instance of interface object

        IUserObject oUserObject;

        ClientRemoteAccess oRemoteAccess = new ClientRemoteAccess();

        oRemoteAccess.tInterface = typeof(IUserObject);

        oRemoteAccess.cServiceName = "UserObject";

        oUserObject = (IUserObject)oRemoteAccess.GetAccessObject();

        string cXMLResultSet = oUserObject.ValidateUser(oGlobals.cUserID, oGlobals.cUserPassword, oGlobals.nDataBaseKey);

Uses of Interfaces - Kevin S. Goff


Generic data binding l.jpg
Generic Data Binding

  • Data bound controls work differently

    • Textbox is bound to different property than a checkbox, and a combobox has more properties

  • Define data binding interface

    • Define interfacenamespace CGS.Interfaces { public interface IBoundControl (BindControl, DtSource, DcSource)

    • Implement interface (PEMs) in data-bound controls

      • Textbox, combo box (additional properties), checkbox

      • Implements props of the interface, plus the BindControl method

      • Each BindControl behaves a little differently, but it doesn’t matter

  • On a form or container, we can loop through controls and bind easily

    ((IBoundControl)oControl).BindControl();

Uses of Interfaces - Kevin S. Goff


Reusable data maintenance forms l.jpg
Reusable data maintenance forms

  • Generic data maintenance form:

    • public interface IDataMaintenanceForm

    • public interface ICriteriaContainer

    • public interface IResultContainer

    • public interface IEntryContainer

Uses of Interfaces - Kevin S. Goff


ad