KJohn Posted August 19, 2009 Share Posted August 19, 2009 (edited) I am doing an Advanced Software Engineering paper (revolving around Design patterns), and one of the things we do is take turns finding actual code (C#,C++,Java) in the wild (like on Google code search) and discuss it. Please note that this is different from simple example code found on "helpful" websites. My problem is that I am not adept at using Google code search to find what I am looking for since I am looking for something very abstract (pun unintended) - an "idea" if you will. The problem is that rarely is it ever explicitly mentioned that an Abstract Factory is being used in the code as a comment so it can't really be searched for. You can give me a fish: if you can link me to code in the google code repository (which uses the abstract factory pattern), and/or teach me to fish (which is what I really prefer). My presentation on Abstract Factory is over but I do not want the collective effort of compiling examples to weaken because of my inexperience. So if you could help me in some way, I'd be really grateful. Edited August 19, 2009 by Koshy John Link to comment Share on other sites More sharing options...
WolfWorld Posted August 19, 2009 Share Posted August 19, 2009 (edited) Hi, nice to see you again. Did you mean something like this? I am still learning c++ and c# so I am not that strong(only 4 days ago for c# >_< ). I still don't understand the thing myself at all lol. expandcollapse popupusing System; namespace ConsoleApplication1 { class Ab { public interface IForm { void ShowFormName(); } public interface IAbstractFormFactory { IForm MakeForm(); } public class VistaForm : IForm { public void ShowFormName() { Console.WriteLine("Vista Form"); } } public class VistaFormFactory : IAbstractFormFactory { public IForm MakeForm() { return new VistaForm(); } } public class Win7Form : IForm { public void ShowFormName() { Console.WriteLine("Win7 Form"); } } public class Win7FormFactory : IAbstractFormFactory { public IForm MakeForm() { return new Win7Form(); } } public static class Application { public static void Run(IAbstractFormFactory factory) { var form = factory.MakeForm(); form.ShowFormName(); } } public class Program { public static void Main() { IAbstractFormFactory factory; var sys = 0; if (sys == 0) { factory = new Win7FormFactory(); } else { factory = new VistaFormFactory(); } Application.Run(factory); Console.ReadKey(); } } } } Edited August 19, 2009 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
KJohn Posted August 19, 2009 Author Share Posted August 19, 2009 Thanks for the reply. That's the idea but I'm looking for slightly more complex code than that. Where did you find this by the way? Link to comment Share on other sites More sharing options...
WolfWorld Posted August 28, 2009 Share Posted August 28, 2009 Thanks for the reply. That's the idea but I'm looking for slightly more complex code than that. Where did you find this by the way?Sorry, I wrote that See you PM for the download. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now