Skip to main content
deleted 4 characters in body
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39

The design pattern you are looking for is the adapter pattern (wikipedia).

The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface...

One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. This would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the base abstract class.

In practice though,In practice for performance reasons I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

The design pattern you are looking for is the adapter pattern (wikipedia).

The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface...

One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. This would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the base abstract class.

In practice though, for performance reasons I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

The design pattern you are looking for is the adapter pattern (wikipedia).

The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface...

One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. This would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the base abstract class.

In practice for performance reasons I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

added 195 characters in body; deleted 7 characters in body; added 24 characters in body
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39

The design pattern you are looking for is the adapter pattern (wikipedia). One

The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface...

One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. Of course thisThis would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the base abstract class.

In practice though, for performance reasons I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

The design pattern you are looking for is the adapter pattern (wikipedia). One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. Of course this would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the abstract class.

In practice though, I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

The design pattern you are looking for is the adapter pattern (wikipedia).

The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface...

One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. This would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the base abstract class.

In practice though, for performance reasons I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

more detail
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39

The design pattern you are looking for is the adapter pattern (wikipedia). One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions. To

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. Of course this would only work if you weren't planning on switchedswitching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the abstract class.

In practice though, I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

The design pattern you are looking for is the adapter pattern. One way to implement the adapter pattern is to create a generic interface for the vector class, and then you could derive classes from it that call the correct functions. To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. Of course this would only work if you weren't planning on switched Vector classes at runtime.

In practice though, I'd rather rely on refactoring tools to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

The design pattern you are looking for is the adapter pattern (wikipedia). One way to implement the adapter pattern is to create a generic interface (abstract) for the vector class, and then you could derive classes from it that call the correct functions.

To switch between the concrete derived classes you could use a typedef. e.g. you would define

typedef VectorDirectX Vector

or

typedef VectorOpenGL Vector

and then you would only use Vector in your code. Of course this would only work if you weren't planning on switching Vector classes at runtime.

If you did need to switch between them at runtime you could use a factory, which would create the required class and return a pointer/reference to the abstract class.

In practice though, I'd rather rely on refactoring tools (e.g. Visual Assist) to rename functions and classes unless I'm working on a massive project or there's a legitimate reason why the classes would need to frequently change.

Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39
Loading