factory

Persisting time ojects as entities instead of value types?

烈酒焚心 提交于 2019-12-13 17:14:50
问题 I'm using Joda Time DateTime to handle date and time. I persist objects of this kind using the class PersistentDateTime bundled in the jodatime hibernate code. I have large collections of DateTime objects, and I currently persist them in the following way (an excerpt of an hibernate mapping file follows): <set name="validInstants" sort="natural"> <key column="myobject_id"/> <element column="date" type="myproject.utilities.hibernate.types.PersistentDateTime"/> </set> Doing so, i.e. storing

Joshua Bloch #Item 1: Consider static factory methods instead of constructors

我的梦境 提交于 2019-12-13 13:52:17
问题 This is related to creating and destroying objects from the book 'Effective Java' by Joshua Bloch Item 1: Consider static factory methods instead of constructors This method translates a boolean primitive value into a Boolean object reference: public static Boolean valueOf(boolean b) { return b ? Boolean.TRUE : Boolean.FALSE; } Note that a static factory method is not the same as the Factory Method pattern from Design Patterns [Gamma95, p. 107]. The static factory method described in this

Using boost factory to produce products on demands C++

孤者浪人 提交于 2019-12-13 07:24:40
问题 What confused me is that I don't want to create a object with a pointer like 'Product_ptr productA', are there some other methods? Another questions is that all my products use DoSomething(), but I also want to add different attributes to different products, how to achieve this? Thanks for your suggestions!! 回答1: Generally you cannot avoid pointers in C++ when dealing with dynamically created objects. You have to manage and pass ownership for such objects which is naturally done with pointers

How can I configure a Factory with the possible providers?

断了今生、忘了曾经 提交于 2019-12-13 03:23:54
问题 I have three assemblies: "Framework.DataAccess", "Framework.DataAccess.NHibernateProvider" and "Company.DataAccess". Inside the assembly "Framework.DataAccess", I have my factory (with the wrong implementation of discovery): public class DaoFactory { private static readonly object locker = new object(); private static IWindsorContainer _daoContainer; protected static IWindsorContainer DaoContainer { get { if (_daoContainer == null) { lock (locker) { if (_daoContainer != null) return

Using factory and http in Angular JS

核能气质少年 提交于 2019-12-13 00:38:22
问题 I am just getting started with angular and saw that you can define a factory to use in multiple controllers. I have the below code, which is returning my result in the 'success' method fine. But not outside of the function. I have a feeling its to do with async, but I'm not too sure how to go forward with it, if it is that. Any help would be appreciated, so thanks in advanced. var abyssApp = angular.module('abyssApp', []); abyssApp.factory('abyssData', function($http) { var result, products =

Swift Generic Factory: Bug?

吃可爱长大的小学妹 提交于 2019-12-12 21:55:36
问题 Investigating Swift generics, and stumbling on some really odd behaviour... should I file a radar, or am I misunderstanding something here? Tested with Swift 1.2 beta. Code speaks best, simple implementation which constrains the factory to instantiating BaseClass and derived classes: /// Testing factory pattern to instantiate BaseClass and derived class BaseClassFactory { // Always returns an instance of BaseClass, even if the constant or // variable storing the result is explicitly typed(

Django FactoryBoy: fill modelfield with choices throws error

自古美人都是妖i 提交于 2019-12-12 16:31:53
问题 I am working on a factory for a model and I am trying fill a field that has a list of choices. When I attempt to create an object with the Factory where I attempt to fill in a random choice from the choice list, an exception is thrown: TypeError: 'choice' is an invalid keyword argument for this function Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/factory/base.py", line 551, in build return cls._generate(enums.BUILD

Axis SecureSocketFactory - Setting the constructor attributes

China☆狼群 提交于 2019-12-12 12:27:52
问题 I have a customer SecureSocketFactory set to be used by Axis when making an https connection using the following property: AxisProperties.setProperty("axis.socketSecureFactory", "com.metavante.csp.model.manager.mobilepayments.MonitiseSSLSocketFactory"); When this class is instantiated by Axis, the constructor with a Hashtable (attributes) is called. I see the timeout attribute is set in this table. Is there anyway to set more values in this? I would like to be able to configure the Socket

Parameterized Factory & product classes that cannot be instantiated without the Factory

故事扮演 提交于 2019-12-12 11:15:45
问题 I'm working on implementing a Factory class along the lines of what is proposed in this response to a previous question: Factory method implementation - C++ It's a Factory that stores a map from strings to object creation functions so I can request different types of objects from the factory by a string identifier. All the classes this factory produces will inherit from an abstract class (Connection) providing a common interface for connections over different protocols (HTTPConnection,

Dependency injection in factories

六月ゝ 毕业季﹏ 提交于 2019-12-12 08:54:23
问题 I'm really new to DI, but I really want to try using it. There's something I don't understand. Here's a simple pseudocode of a factory, I'm using a lot. class PageFactory { public function __construct(/* dependency list */) { ... //save reference to the dependencies } public function createPage($pagename) { switch ($pagename) { case HomePage::name: return new HomePage(/* dependency list */); case ContactPage::name: return new ContactPage(/* dependency list */); ... default: return null; } } }