Skip to main content
deleted 265 characters in body
Source Link
Ed James
  • 1.3k
  • 1
  • 10
  • 14

Abstract classes are useful when you need to enforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes where I wanted to create a fixed set of behaviours for an entire class hierarchy.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already existsexist and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition. For a hierarchy of Types, extension methods provide a means to extend behaviour without having to open the entire hierarchy for modification. Extension

However, extension methods can implement scenarios that depend only on certain interfaces (roles) that are implemented (played) by a potentially wide varietyunable to access private implementation, so at the top of candidate classes. This is a very flexible way of buildinghierarchy, if I need to encapsulate private implementation behind a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classespublic interface then an abstract class would be the only way.

Abstract classes are useful when you need to enforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes where I wanted to create a fixed set of behaviours for an entire class hierarchy.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exists and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition of behaviour. Extension methods can implement scenarios that depend only on certain interfaces (roles) that are implemented (played) by a potentially wide variety of candidate classes. This is a very flexible way of building a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classes.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exist and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces. For a hierarchy of Types, extension methods provide a means to extend behaviour without having to open the entire hierarchy for modification.

However, extension methods are unable to access private implementation, so at the top of a hierarchy, if I need to encapsulate private implementation behind a public interface then an abstract class would be the only way.

deleted 224 characters in body
Source Link
Ed James
  • 1.3k
  • 1
  • 10
  • 14

Abstract classes are useful when you need to enforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes where I wanted to create a fixed set of behaviours for an entire class hierarchy.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exists and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition of behaviour. Extension methods can implement scenarios that depend only on certain interfaces (roles) that are implemented (played) by a potentially wide variety of candidate classes. This is a very flexible way of building a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classes.

Abstract classes are useful when building a framework for other parties to extend. A good example is the CSLA.NET framework where the programmer derives all business objects from a set of highly functional abstract classes.

Abstract classes are useful when you need to enforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes where I wanted to create a fixed set of behaviours for an entire class hierarchy.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exists and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition of behaviour. Extension methods can implement scenarios that depend only on certain interfaces (roles) that are implemented (played) by a potentially wide variety of candidate classes. This is a very flexible way of building a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classes.

Abstract classes are useful when building a framework for other parties to extend. A good example is the CSLA.NET framework where the programmer derives all business objects from a set of highly functional abstract classes.

Abstract classes are useful when you need to enforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes where I wanted to create a fixed set of behaviours for an entire class hierarchy.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exists and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition of behaviour. Extension methods can implement scenarios that depend only on certain interfaces (roles) that are implemented (played) by a potentially wide variety of candidate classes. This is a very flexible way of building a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classes.

added 730 characters in body
Source Link
Ed James
  • 1.3k
  • 1
  • 10
  • 14

Extension MethodsAbstract classes are unableuseful when you need to provide Properties, leavingenforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes as the only waywhere I wanted to provide default behavior forcreate a propertyfixed set of behaviours for an entire class hierarchy.

AbstractApplying extension methods to an interface is useful for applying common behaviour across classes allow or enforce, throughthat may share only a common interface. Such classes may already exists and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition of behaviour. Extension methods can implement scenarios that depend only on certain interfaces abstract and(roles) that are implemented virtual keywords, the overriding(played) by a potentially wide variety of default behaviorcandidate classes. Such enforcementThis is not provided by Extension Methodsa very flexible way of building a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classes.

Edit: Down vote with no comment. What's wrong with this post? If it's wrong in any way, I'd likeAbstract classes are useful when building a framework for other parties to knowextend. A good example is the CSLA.NET framework where the programmer derives all business objects from a set of highly functional abstract classes.

Extension Methods are unable to provide Properties, leaving abstract classes as the only way to provide default behavior for a property.

Abstract classes allow or enforce, through use of abstract and virtual keywords, the overriding of default behavior. Such enforcement is not provided by Extension Methods.

Edit: Down vote with no comment. What's wrong with this post? If it's wrong in any way, I'd like to know.

Abstract classes are useful when you need to enforce the basic shape and behaviour of a class hierarchy. Once inherited there's no escaping your abstract class. I'd use abstract classes where I wanted to create a fixed set of behaviours for an entire class hierarchy.

Applying extension methods to an interface is useful for applying common behaviour across classes that may share only a common interface. Such classes may already exists and be closed to extensions via other means.

For new designs I would favour the use of extension methods on interfaces for the flexible composition of behaviour. Extension methods can implement scenarios that depend only on certain interfaces (roles) that are implemented (played) by a potentially wide variety of candidate classes. This is a very flexible way of building a domain model; keeping your classes fairly dumb and providing scenarios that play across domain classes.

Abstract classes are useful when building a framework for other parties to extend. A good example is the CSLA.NET framework where the programmer derives all business objects from a set of highly functional abstract classes.

deleted 1039 characters in body; added 109 characters in body
Source Link
Ed James
  • 1.3k
  • 1
  • 10
  • 14
Loading
added 533 characters in body
Source Link
Ed James
  • 1.3k
  • 1
  • 10
  • 14
Loading
Source Link
Ed James
  • 1.3k
  • 1
  • 10
  • 14
Loading