|
In an OO component, when you have only one implementation available for an class and that class is not 'published' to other components, is it still advisable to have an interface and work with the interface instead?
I am fully aware of 'programming to...
Answer Snippets (Read the full thread at stackoverflow):
The alternative to that would be to not use the interface and subclass the concrete class....
Creating interfaces for concrete types is a delicate balancing act as you can easily create with the interface as opposed to the concrete class.
|
|
Building a rectangular grape arbor in my backyard and thought Id knock some ideas around about the best way to make vertical 4x4 posts sturdy.
My options, in order of preference, seem to be:
Bury the posts:
Using this method I could afford to use 6x6 ...
Started by shadetree on
, 13 posts
by 9 people.
Answer Snippets (Read the full thread at diychatroom):
Back fill with concrete....
In general, wood should never touch concrete or dirt on it at the bottom.
But those posts will have problems sooner than if not surface mounted .
In concrete, maybe just the corner posts, for stability.
The posts.
|
|
In C# , when I have an interface and several concrete implementations, can I cast the interface to a concrete type or is concrete type cast to interface?
What are the rules in this case?
Thanks
Started by dotnetdev on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Access to the concrete classes which is one major reason to have an interface in the first place (down)cast an interface to a concrete implementation, iff the reference you cast actually is a reference to the specific concrete implementation....
|
Ask your Facebook Friends
|
How would design and organize tests for the concrete methods of an abstract class? Specifically in .NET.
Started by Russell Myers on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
You have to create a subclass that implements the abstract methods (with empty methods), but none of the concrete ignore the overridden abstract methods....
The first thing that comes to mind is to test those methods in a concrete child class.
|
|
Are there some practical programming situations for someone to declare a class abstract when all the methods in it are concrete?
Started by sarav on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
To facilitate implementation of your concrete classes you might want to provide an abstract class providing default behavior for each method....
They cannot be instantiated so if you have an abstract class with concrete methods then it can.
|
|
I'm drawing some UML in which a concrete class inherits from an abstract class which defines a pure virtual method. Is it required to show this method in the concrete class as well? It's implied by inheriting from the abstract class.
Started by Jack BeNimble on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The best guide I know of for UML is UML Distilled by Martin Fowler... .
In fact, in general, don't put any more in the UML than you must have to clarify what you're saying, unless you're (god forbid) trying to generate code from it .
Nope, you don't need to.
|
|
I have class with a forwarding method foo:
void foo( Concrete c, String s ) { c.bar( s ); }
I wish to test that foo in fact forwards. Unfortunately for me, Concrete is a class in a third-party library, and is a Concrete type, not an interface. Thus I ...
Started by tpdi on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
For Concrete like this:
public class ConcreteStub extends Concrete { public int numCallsToBar = 0 , it is more complicated and the answer depends on the complexity of Concrete and your project's use of the Concrete class.
|
|
Hi,
I am learning C++, but I am confused about abstract class and concrete class. Some real world examples would be appreciated.
Started by coming out of void on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
A concrete class is a class an abstract class and make a concrete class....
An abstract class serves class (deriving from Car ) class is a concrete implementation.
An abstract class can't be instantiated whilst a concrete one can.
|
|
Hi,
I read "Concrete types are rarely useful as bases for further derivation" Stroustrup p. 768
How to interpret this? Does it mean that we should get derived class from the base class with pure virtual function? However, I see a lot of code with derived...
Started by skydoor on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The explanation above.
Suppose you with inheritance in mind but a concrete class might not, this could be unsafe.
From concrete classes is often done to reuse some code in that class, which is (now) frowned upon.
|
|
I want to avoid calling a lot of isinstance() functions, so I'm looking for a way to get the concrete class' name for an instance variable as a string.
Any ideas?
Answer Snippets (Read the full thread at stackoverflow):
Instance.__class__.__name__
example:
>>> class A(): pass >>> a = A() >>> a.__class__.__name__ 'A'
<object>.__class__.__name__
you can also create a dict with the classes themselves as keys, not necessarily the classnames... .
|