Back to Threads
Avatar
May 14

This One Thing Could Make Or Break Interface Design Nets Policy. - OpenSIPS Trunking Solutions

Overview

It's important for a. net library to find a balance between stability for existing users and innovation for the future. Read also: What The Redwood County Sheriff Doesn't Want You To Know (Jail Roster)

This One Thing Could Make Or Break Interface Design Nets Policy. - OpenSIPS Trunking Solutions

When your class is not sealed you have to take the possibility of a class being inherited into account. Read also: The Slayeas Leak: A Whistleblower's Explosive Claims You Need To Hear

This One Thing Could Make Or Break Interface Design Nets Policy. - OpenSIPS Trunking Solutions

Especially when changing existing classes this can make things much more difficult. Read also: OMG! Urfavbellabbys New Video Is Hilarious – And It's Already Viral!

Making a class sealed is a breaking change, you always unseal classes.

Interface segregation is slightly different to srp in that while a class should do one thing, that thing may be represented by more than one method.

Those methods can be grouped into roles (or just one role) and each role gets its own interface.

I've had to defend this position more than once and objectively, this preemptive creation of interfaces is the most damaging aspect, in my estimation.

I look at c# source and i often find that every class has an interface and every interface maps to exactly one class.

One strong recommendation i've come across in the past is never break an interface.

But doesn't this produce a messy design such as idocument, idocument2, idocument3, idocument4, idocument5, idocument6 etc, as seen in the mshtml com library?

If your design includes empty interfaces that types are expected to implement, you are probably using an interface as a marker or a way to identify a group of types.

If this identification will occur at run time, the correct way to accomplish this is to use a custom attribute.

Doing so would break implementations of the interface.

You should create a new interface in order to avoid versioning problems.

Except for the situations described in these guidelines, you should, in general, choose classes rather than interfaces in designing managed code reusable libraries.