instantiation

DDD - Aggregate Root - Example Order and OrderLine

╄→尐↘猪︶ㄣ 提交于 2019-12-04 21:37:17
问题 I am trying to get my hands dirty learning DDD (by developing a sample eCommerce site with entities like Order , OrderLines , Product , Categories etc). From what I could perceive about Aggregate Root concept I thought Order class should be an aggregate root for OrderLine . Things went fine so far, however I am confused when it define a create order flow from UI. When I want to add an order line to my order object, how should I get/create an instance of an OrderLine object: Should I hardcode

When instantiating a (sub)Class, is there any difference in what “type” you declare the object as?

人走茶凉 提交于 2019-12-04 17:19:08
Say I have a Class called ParentClass and a Class called ChildClass The ParentClass is abstract and the ChildClass extends the ParentClass per Java terminology. Furthermore, the ParentClass has a constructor which takes an int as a parameter. Now in another class I want to instantiate the ChildClass . I have tried the two below ways: ChildClass obj1 = new ChildClass(5) ParentClass obj2 = new ChildClass(5) Java allows me to use any of the two above ways. My question is, is there actually any difference? Can I use the two, interchangeably if I want to ? Both work, and both create the same object

PHP: How to instantiate a class with arguments from within another class

三世轮回 提交于 2019-12-04 17:12:42
问题 I am in a situations where i need to instantiate a class with arguments from within an instance of another class. Here is the prototype: //test.php class test { function __construct($a, $b, $c) { echo $a . '<br />'; echo $b . '<br />'; echo $c . '<br />'; } } Now, i need to instantiate above class using below class's cls function: class myclass { function cls($file_name, $args = array()) { include $file_name . ".php"; if (isset($args)) { // this is where the problem might be, i need to pass

Conditional instantiation of verilog module

浪子不回头ぞ 提交于 2019-12-04 10:41:53
问题 Is it possible to instantiate a module conditionally in verliog ? example : if (en==1) then module1 instantiation else module2 instantiation 回答1: From IEEE Std 1364-2001 : 12.1.3.3 generate-conditional A generate-conditional is an if-else-if generate construct that permits modules, user defined primitives, Verilog gate primitives, continuous assignments, initial blocks and always blocks to be conditionally instantiated into another module based on an expression that is deterministic at the

Can I use decltype (or something similar) for explicit template instantiation without signature duplication?

假如想象 提交于 2019-12-04 09:51:15
I want to instantiate template<typename T> void foo( T& t, SomeType some_parameter, AnotherType another_parameter, EtcType yet_another_parameter, AsYouCanTell this_is_a_very_long_signature); that is, a function with a long signature. Now, I know how to do this: template void foo<int>( int& t, SomeType some_parameter, AnotherType another_parameter, EtcType yet_another_parameter, AsYouCanTell this_is_a_very_long_signature); But I have to duplicate the signature. Also, what if want specific instantiation for 5 different types - do I copy it 5 times? Doesn't make sense... I was thinking maybe I

difference between server.createObject and createobject in asp classic

别来无恙 提交于 2019-12-04 09:37:56
according to http://msdn.microsoft.com/en-us/library/ms524620.aspx you should use server.createObject If you are already familiar with VBScript or JScript, note that you do not use the scripting language's function for creating a new object instance (CreateObject in VBScript or New in JScript). You must use the ASP Server.CreateObject method; otherwise, ASP cannot track your use of the object in your scripts. but some other folks think that server.createObject implies an overhead that most times could be avoided http://classicasp.aspfaq.com/components/should-i-use-createobject-or-server

Can I use methods of a class without instantiating this class?

你说的曾经没有我的故事 提交于 2019-12-04 08:55:59
问题 I have a class with several methods and there is no constructor among these methods. So, I am wondering if it is possible to call a method of a class without a creation of an instance of the class. For example, I can do something like that: NameOfClass.doMethod(x1,x2,...,xn) In general I do not see why it should be impossible. I just call a function which does something (or return some values). If it is possible, what will happen if the method sets a value for a private variable of the class.

How do I instantiate a class in android which is also an activity?

徘徊边缘 提交于 2019-12-04 05:35:47
问题 In android, how can I create a constructor for a class which is also an Activity ? My problem is, I want to have two activity classes (estimateFare and Mapping) which both send data to a an activity class ( CalculateFare ). Mapping takes the data from real time network info, whereas estimateFare takes data from user input. I want CalculateFare to be able to use the data from either class to perform the calculation, although I have run into trouble with the onCreate method and the constructor

why i cant instantiate objects inside a switch-case block

不打扰是莪最后的温柔 提交于 2019-12-04 03:45:17
my code has 3 classes n_hexa,n_octa,n_bin. The code is here switch(choice) { case 1: cin>>n; n_hexa nx(n); break; case 2: cin>>n; n_octa no(n); break; case 3: cin>>n; n_bin nb(n); break; } on compiling it gives a message " crosses initialisation of n_hexa " for line of n_octa If you want to have temporary objects inside a case, you'll need to scope them properly. switch(choice) { case 1: { cin>>n; n_hexa nx(n); break; } case 2: { cin>>n; n_octa no(n); break; } case 3: { cin>>n; n_bin nb(n); break; } } Try declaring the variables above the switch command: n_hexa nx; n_octa no; n_bin nb; switch

Can I use C++ class members initialized in the initializer list, later in the list?

允我心安 提交于 2019-12-04 03:24:38
问题 I am rewriting some code to eliminate global variables and made a class constructor/destructor handle cleanup of some third party library resources, but I am concerned about some code which initializes one member from another member in the class initializer list. class MyPodofoDocument { public: // generates pdf to stream MyPodofoDocument(std::stringstream *pStringStream) : device(pStringStream), document(&device) { } private: PoDoFo::PdfOutputDevice device; PoDoFo::PdfStreamedDocument