Showing posts with label interface. Show all posts
Showing posts with label interface. Show all posts

Wednesday, March 28, 2018

2,000 Things You Should Know About C#

March 28, 2018

Introduction


It is time for me to slow down to practice data structure and algorithm, and think about how to advance myself as  a C# programmer. One thing I like to do is to learn something quickly. I spent over one hour today to study interface from 2,000 things you should know about C#.

Interface




  • #434 – Interfaces
  • #435 – Implementing an Interface
  • #436 – The Implementation of an Interface Can Be a Subset of the Class
  • #437 – Access Interface Members through an Interface Variable
  • #438 – Benefits of Using Interfaces
  • #440 – A Class Can Implement More than One Interface
  • #441 – Implementing Interface Members Explicitly
  • #442 – Explicit Interface Implementation Allows Duplicate Member Names
  • #443 – An Interface Cannot Contain Fields
  • #444 – Interfaces Can Inherit from Other Interfaces
  • #445 – Differences Between an Interface and an Abstract Class
  • #446 – Deciding Between an Abstract Class and an Interface
  • #447 – Use as Operator to Get At an Object’s Interfaces
  • #448 – Use the is Operator to See if an Object Implements an Interface
  • #449 – You Can Pass an Interface Variable to a Method
  • #450 – Interfaces Should Normally Start with the Letter ‘I’
  • #451 – Implement Interface Explicitly to Simplify How a Class Appears to Clients
  • #454 – Return an Interface as a Return Value from a Method
  • #455 – Define an Interface Based on Existing Members of a Class
  • #456 – Explicitly Implemented Interface Members Are Automatically Private
  • #536 – Using a Generic Interface
  • #537 – Implement a Generic Interface with a Generic Class
  • #612 – Members of an Interface Are Implicitly Public
  • #613 – Interfaces Cannot Contain Static Members
  • #647 – A struct Can Implement an Interface
  • #799 – Interface Members Are Implicitly Public
  • #1,067 – Covariance and Generic Interfaces
  • #1,068 – Generic IEnumerable Interface Is Covariant
  • #1,069 – Contravariance and Generic Interfaces


  • It will take me 2 hours to go over those items.

    Thursday, December 17, 2015

    Book Reading: Effective Java

    Dec. 17, 2015

    Effective Java is such a great book, I had wonderful time to read 1-2 hours while enjoying the travel on train back to my home  town this October, 2015.

    But, Julia had to motivate her more to complete reading the book - at least spend over 10 hours this holiday break to catch up some best ideas about programming.

    Dec. 17, 2015  (20 minutes reading)
    Item 52: Refer to objects by their interfaces (julia's rating 1-10: 10)

    Dec. 18, 2015 ( 2 hours reading 8:00pm-10:00pm)
    Item 23: Don't use raw types in new code
    Item 24: Eliminate unchecked warnings
    Item 25: Prefer lists to arrays
    Item 40: Design method signatures carefully
    Item 45: Minimize the scope of local variables
    Item 46: Prefer for-each loops to traditional for loops

    Dec. 19, 2015 ( 2 hours reading 8:30am-10:30am)

    Item 6: Eliminate obsolete object reference (read the item twice)
    Actions: take sample code, and think about similar example, write a one in C#, check in github
    Notes:
    3 cases for memory leaks:
    1. whenever a class manages its own memory,
    2. caches  - WeakHashMap
    3. listeners and other callbacks
    Careful code inspection or with the aid of a debugging tool known as a heap profiler
    Action item 2: Try heap profiler in C#

    Item 8: Obey the general contract when overriding equals (read again, 30 minutes)

    Further reading:
    WeakHashMap
    http://www.ibm.com/developerworks/library/j-jtp11225/

    Read some code, and then, go back to the book.
    http://www.codeproject.com/Articles/595160/Understand-Liskov-Substitution-Principle-LSP

    http://www.codeproject.com/Articles/648987/Violating-Liskov-Substitution-Principle-LSP

    http://www.codeproject.com/Articles/597870/Liskov-Substitution