If I never ever created an interface

  • Thread starter Thread starter csharper
  • Start date Start date
C

csharper

I think that there must be some problem with my OOP design. But, then
how do I get more intuitive about creating interfaces? Any two cents
to share? Thanks.
 
Not only can you have a valid OOP program in which you have never
declared an interface, you can have a valid OOP program in which you
never even _use_ an interface.

Which is not to say that I can say for sure your interface-less program
is a good OOP program.  But it's possible.

As for how you can "get more intuitive about creating interfaces", I
don't really know how to answer that in a specific way.

In general, you "get more intuitive" about all programming topics by
practicing, a _lot_.  The more you write C# programs, the more you will
find yourself in situations where it makes sense to declare some
particular common functionality as a type for polymorphic behavior, but
where there is no default implementation per se, and where the
functionality doesn't fit into the "is a" mold (i.e. the kinds of
situations where one would be inclined to declare an interface).

And of course, the more you find yourself in such situations and
practice handling them, the more "intuitive" you will "get" regarding
such situations.  :)

Pete

Yes, I am sure extensive practice will help a lot. Maybe it helps to
read about the design of decoupled, cohesive applications?
 
I think that there must be some problem with my OOP design.

If you are designing frameworks / reusable class libraries: yes.

If you are creating apps: maybe not.
But, then
how do I get more intuitive about creating interfaces?

Interfaces and various factory style mechanism is one of the
best ways to decouple code.

To get started then you should always ask if the code is
independent of other stuff:
* can I change from SQLServer to Oracle with only changes
in one component?
* can I change from databas eto XML with only changes
in one component?
* can the component be used in desktop apps, web apps and
windows services?
etc.etc.

To be able to answer yes, then you will end up using
interfaces!

Arne
 
If you are designing frameworks / reusable class libraries: yes.

If you are creating apps: maybe not.

I like to develop multi-tiered applications and I'd like to make the
layers as decoupled as possible.

Interfaces and various factory style mechanism is one of the
best ways to decouple code.

To get started then you should always ask if the code is
independent of other stuff:
* can I change from SQLServer to Oracle with only changes
   in one component?
* can I change from databas eto XML with only changes
   in one component?
* can the component be used in desktop apps, web apps and
   windows services?
etc.etc.

To be able to answer yes, then you will end up using
interfaces!

Arne

Those are good questions to ask.



Good questions to
 
Back
Top