Ambesha - Professional Profile
|
|
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
{
public void foo()
{
// content goes here
Console.WriteLine("Parent foo");
}
}
class child : parent
{
public new void foo()
{
// content goes here
Console.WriteLine("Child foo");
}
}
class program
{
public static void Main()
{
child obj = new parent();// 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:51am.
|
|
|
|
|
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.
—SASergey A Kryukov
|
|
|
|
|
Thanks SA, It will definetly helpful for me.
-Ambesha
|
|
|
|
|
|
General
News
Suggestion
Question
Bug
Answer
Joke
Praise
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.