Hi Guys
Factory method is explained in the following website. I couldn’t understand it. I wish to know the meaning of the factory method. Anyone knows please explain.
http://www.c-sharpcorner.com/UploadFile/rmcochran/instantiationFactory06232007153242PM/instantiationFactory.aspx
Thank you
Posted Oct 10, 2007, 4:03 PM
In the article (website address is given above) there is a following part:
In this scenario, when we want to "new-up" our class, we call it through the static method as follows:
Number objTwo = Two.New();
The following code would not compile because the New() factory method now returns a "Number" object and not a "Two" object:
Two objTwo = Two.New();
There is an error. Two objTwo = Two.New(); must come instead of Number objTwo = Two.New();
And Number objTwo = Two.New(); must come instead of Two objTwo = Two.New();
I wish to know whether I am correct or not. Please confirm it.
Posted Oct 10, 2007, 2:41 PM
Thank you, Alan
AlanPosted Oct 10, 2007, 2:27 PM
Well, a factory is a building in which something is manufactured en masse rather than individually.
A factory method manufactures objects. Instead of using the constructor to create the object yourself you ask the factory method to do it for you.
I don't think the name signifies anything more profound than that.
Posted Oct 10, 2007, 1:29 PM
Is there any specific reason for naming it as “Factory Method”?
Posted Oct 8, 2007, 8:39 AM
Initially it gave me trouble I don’t know why. Now it is okay. Thank you very much for the explanation, Alan.
AlanPosted Oct 8, 2007, 6:31 AM
Posted Oct 8, 2007, 5:49 AM
Let me say Microsoft Word file “A” in the folder1 and Microsoft Word file “B” in the folder2. Whether it is possible to link A and B. Note that here the files are in different folders. If it is different method please tell me.
AlanPosted Oct 8, 2007, 5:28 AM
I'm not entirely sure what you're asking though you can certainly create links within Microsoft Word documents, using a similar approach to how we create them on here.
Type in the text for the link and select it.
Right-click the text and select Hyperlink.
In the text box which opens up, enter the url for the link and click Insert.
Posted Oct 7, 2007, 7:39 AM
I wish to know whether it is possible to link Microsoft Word document in different folders. If it is possible please tell me.
AlanPosted Oct 6, 2007, 6:09 PM
First type in the name of the link (i.e. the text that you want to be underlined), and then select it.
Now in the tool bar click on the Create Link button (ball and chain symbol), type the url for the link into the box that opens up and press OK.
For example, if I've typed in the url correctly, this link will take us to the C# Corner home page.
If you know HTML, you can also add a link by switching from Design to HTML view and typing in name of link.
Posted Oct 6, 2007, 11:28 AM
When click the following one (this one is above) relevant website is displayed.
Illustrated GOF Design Patterns in C# Part I: Creational
Anyone tell me please how to create this link.
Posted Oct 1, 2007, 10:24 PM
Thank you very much for your explanation and giving me the website address, Jan
Jan MontanoPosted Oct 1, 2007, 9:32 PM
In programming, there is what we call "Design Patterns" and Factory Method is one. Simply put, Factory Method defines an interface for creating an object and lets subclasses decide which class to instantiate.
This is useful when we are not yet sure what kind of objects to create.
To give you more of an idea, here's an article: Illustrated GOF Design Patterns in C# Part I: Creational
I hope this won't confuse you more.