
|
Here is a open question for my new friends in the world of OOPS. Can Parent class objects instantiated by child class?
The answer is NO!
lets take a simple example in C# language:
class parent
{
void foo()
{
// content goes here
}
}
class child:parent
{
new void foo()
{
// content goes here
}
}
class program
{
static void main()
{
parent obj = new child();// getting error here
obj.foo();
}
}
for more query related this topic please let me know here.
or visit http://ambeshdevloper.blogspot.com/2012/09/can-child-parent-objects-instatiated-by.html[^]
Thanks,
Ambesha
|
|
|
|

|
Please visit here for complete code reference: http://ambeshdevloper.blogspot.com/2012/09/can-child-class-objects-instantiated-by.html
modified 28 Sep '12 - 1:51.
|
|
|
|

|
In my view Singleton pattern is obsolete in today’s era... harder to get any implementation
|
|
|
|

|
Do we really think that Design pattern play an important role in Software life cycle?
|
|
|
|

|
Yes and no. I personally think that the role of design patterns is highly exaggerated. But it's important that each developer knew all major patterns. I would recommend studying of all of these:
http://ambeshdevloper.blogspot.com/2012/09/can-child-class-objects-instantiated-by.html[^].
But how about using them? Some developers heavily rely on the patterns they know without critical thinking and, importantly, without clear understanding of the nature of the problem they are solving. Such developers tend to stuff their software with nearly all they know. Nothing can be a good substitute for a developer's brain. I think, it's important to go from the specific problem to the solutions, and, ultimately, to some generalized approach. Very often, especially in non-trivial problems requiring considerably non-trivial code design, a new patterns are to be created, or, even more typically, the ideas of existing code pattens are effectively used, but with some twists or in combination. This is the real art of programming, not knowing a big number of patterns by heart…
In my opinion, it's even more important to know anti-patterns and be able to identify them in real life:
http://en.wikipedia.org/wiki/Anti-pattern[^].
Thank you for interesting question and reasonable doubts.
—SA
Sergey A Kryukov
|
|
|
|

|
Thanks SA, It will definetly helpful for me.
-Ambesha
|
|
|
|