DEV Community

CodingBlocks

Episode 1 – I is for Interface

The good, the bad, and the ugly side of interfaces. We list some minor gripes, their limitations, and some strange gotchas as well as some tips for how we like to (mis|ab)use them. Download the episode on iTunes or Stitcher. Show Notes Duration: ~44m What Are Interfaces? 0:00 - 5:21 Interfaces are a contract Interfaces imply a can-do relationship Differences between interfaces and abstract classes Interfaces as Guardrails Related Post: Interfaces as Guardrails More information and examples on the "interfaces are guardrails" and "baking it in" concept: http://www.codingblocks.net/podcast/programming-with-interfaces/ Naming Conventions 05:21 - 09:16 Interface conventions use hungarian notation, begin  "I" Show up "mid-directory" in IDE's Related Post: Interface Naming Conventions We programmers tend to have a few OCD qualities, discussion here on interface naming conventions: http://www.codingblocks.net/podcast/interface-naming-conventions/ Interfaces Limitations 09:16 - 19:36 Constructors Anonymous classes Static classes Adapter Pattern as workaround Related Post: What if interfaces...? Fun take on what it might look like if interfaces supported constructors, statics, and anonymous classes: http://www.codingblocks.net/programming/what-if-interfaces/ Begging for Feedback 19:36 - 19:55 We'd love to hear your comments and honest feedback, contact us at comments@codingblocks.net! Explicit Interfaces 19:55 - 29:37 What are explicit interfaces? Avoid when possible Explicit method implementation is marked private Cannot be called by a derived type Favor interface inheritance over modifying public interfaces Related Post: The Dark Side of Interfaces Closer look at a few of the pit falls and confusion around explicit interfaces. http://www.codingblocks.net/programming/the-dark-side-of-interfaces/ Baking it in 29:37 - 35:23 Enforcing logic through grammar Interface Segregation Principle Refactor without changing underlying code Reduce testing dependencies Enable easy mocking Debugging 35:23 - 39:40 Debugger's not so great with interfaces Tip/Tricks 39:40 - 43:36 Right click the using section to alphabetically sort and remove unused "using" directives Ctrl-Period shortcut adds required "using" directives or auto-generate interface stubs on classes Route Debugger and WebApi Route Debugger provides tons of information about routes Thanks for checking out the podcast. We'd love to hear your honest feedback in your iTunes review or at comments@codingblocks.net.

Episode source