abstract-factory

Abstract Factory and Inversion of Control resolve at runtime

早过忘川 提交于 2019-12-10 15:32:54
问题 I have the following class and interface structure and I'm having a hard time trying to get the code to do what I need. public interface IUserManager { int Add(User user); } public class UserManagerA : IUserManager{} public class UserManagerB : IUserManager{} In this example I'm using Ninject as the IoC container but I'm open to changing it if some other container resolves the issue: This is inside my NinjectWebCommon.cs : void RegisterServices(IKernel kernel) { string userRole = CurrentUser

What are disadvantages of Abstract factory design pattern?

回眸只為那壹抹淺笑 提交于 2019-12-10 05:24:27
问题 As usual to build the project with different design patterns, architects always prefer the advantageous view of that particular design pattern. But sometimes it need to understand what should be the violation area and disadvantages in terms of future extension of project. I am using Abstract factory design pattern now a days. I understood it but unable to figure out its disadvantages,its limitations, where it will get fail. can somebody please explain me this another view of Abstract Factory

Is Factory method more suitable for frameworks and Abstract facory for Library?

丶灬走出姿态 提交于 2019-12-09 04:23:23
Both Abstract Factory and Factory method patterns are creational design patterns which solves the object creation issues in different scenarios. As per GOF Factory Method pattern Define an interface for creating an object, but let the subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclass. My Understanding : Motive of the Client is to get a method present in the base Factory class get executed which is dependent upon an object whose concrete class is not known now (In such a case, either during providing the software to client, it will be

Abstract Factory vs Factory method: Composition vs Inplement? [duplicate]

喜欢而已 提交于 2019-12-08 08:24:51
问题 This question already has answers here : Factory, Abstract Factory and Factory Method (3 answers) Closed 5 years ago . I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem I can't understand. One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass

Is Factory method more suitable for frameworks and Abstract facory for Library?

放肆的年华 提交于 2019-12-08 05:47:20
问题 Both Abstract Factory and Factory method patterns are creational design patterns which solves the object creation issues in different scenarios. As per GOF Factory Method pattern Define an interface for creating an object, but let the subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclass. My Understanding : Motive of the Client is to get a method present in the base Factory class get executed which is dependent upon an object whose concrete

Castle Windsor Typed Factory Facility equivalents

与世无争的帅哥 提交于 2019-12-05 22:59:45
问题 do any other .NET IoC containers provide equivalent functionality to the typed factory facility in Castle Windsor? e.g. if I am using an abstract factory pattern in a WPF application: public class MyViewModel { private IAnotherViewModelFactory factory; public void ShowAnotherViewModel() { viewController.ShowView(factory.GetAnotherViewModel()); } } I don't want to have to create a manual implementation of IAnotherViewModelFactory for every type of ViewModel I wish to show, I want the container

When linking, is there something between “grab what you need” and “grab all” (-Wl,--whole-archive)?

假装没事ソ 提交于 2019-12-05 10:50:10
I have this library which involves some static initialization code which needs to run before main() . It all works well if you just compile all of the translation units together, but it doesn't work if I provide a static library ( .a file) and have users link their application against it - the linker simply ignores the symbols which do my static initialization. Alternatively, I can make the linker pick up everything in the static library, if I specify the -Wl,--whole-archive option to GCC, i.e. specify the --whole-archive option to GNU link. But is there some middle ground? Can I mark some

Using abstract factory as injectionfactory in Unity?

混江龙づ霸主 提交于 2019-12-04 23:51:07
问题 I have an abstract factory registered for injection in some controller instances. Can I register that abstract factory and use it as an injection factory? This is what I have: public interface ILevelFactory { Levels Create(); } .RegisterType<ILevelFactory, LevelFactory>() .RegisterType<Levels>(new InjectionFactory((c) => StaticLevelFactory.GetLevels())) Desired situation: .RegisterType<ILevelFactory, LevelFactory>() .RegisterType<Levels>(*** look up and use ILevelFactory ***) In short, I want

Castle Windsor Typed Factory Facility equivalents

一世执手 提交于 2019-12-04 05:12:42
do any other .NET IoC containers provide equivalent functionality to the typed factory facility in Castle Windsor? e.g. if I am using an abstract factory pattern in a WPF application: public class MyViewModel { private IAnotherViewModelFactory factory; public void ShowAnotherViewModel() { viewController.ShowView(factory.GetAnotherViewModel()); } } I don't want to have to create a manual implementation of IAnotherViewModelFactory for every type of ViewModel I wish to show, I want the container to take care of this for me. AutoFac has a feature called Delegate Factories , but as far as I can

Abstract Factory, Factory Method, Builder

半世苍凉 提交于 2019-12-03 02:54:14
问题 It may seem as if this is question is a dupe, but please bear with me - I promise I've read the related posts (and the GOF book). After everything I've read, I still don't have it clear when to use an Abstract Factory, a Factory Method, or a Builder. I believe it will finally sink in after I see a simple example of a problem which is best approached by, say, a builder and it would be clearly silly to use, say, an abstract factory . Can you provide a simple example where you would clearly use