Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 25th, 2014, 12:32 pm

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: Polteroutrun: I still think you need to have a concrete benchmark of this! :>I'm unsure about a couple of choices made (e.g., `std::list` -- perhaps `std::vector`, `std::deque`, or `boost::stable_vector` are worth consideration) -- but that's all pointless speculation without a concrete benchmark.Similarly, I also don't see much point in discussing other data structures, like graphs or trees, at this stage -- if we can't have a concrete benchmark with a simple data structure, we're pretty sure going to fail to benchmark the more complex ones. And, since "you can't improve what you can't measure", this will only lead to a failed design that we won't be able to improve upon.I agree. Let's reduce the focus and scope for a moment. Proof-o'-Concept.What I can do is _provide_ the CAD classes, actions on them (rotate, move) and and a realistic test case(s) to test the new design.So, we effectively want is Invoke(<any_action>, <any_object>) ?Are there other requirements as well?Yes * Invoke(<any_action>, <any_object>, ...)* have a dynamic set of objects of various types.I'll see what I can do with benchmarking, (I'll do a simple A-B test ok?) but speed is not the main benefit IMO: I think a non-member deisgn is simpler (leas requirment on the objects) more open and beter maintainable.To make it explicit:Actions: {move, rotate,..}Objects: {square, circle,..}Yes. I sign the contract
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 25th, 2014, 12:40 pm

QuoteOriginally posted by: outrunJust finished a CAD assembly project! An IKEA bed, took me exactly 5 hours.Now, seeing some hands-on experience,1. Put all them components in your heterogeneous container.2. Write a Bill-of-Materials (BOM) to send to warehouse inventory (RTTI)3. If time permits, couple assembly with parts pricing database. (SQL Server) BTW what your bed cost?(Same problem as my previous posted oil distillation tray assembly).
Last edited by Cuchulainn on May 24th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Modern & Effective C++ design ideas

May 25th, 2014, 3:37 pm

QuoteOriginally posted by: outrunJust finished a CAD assembly project! An IKEA bed, took me exactly 5 hours.How many invoke(move,object) calls did you make?
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Modern & Effective C++ design ideas

May 25th, 2014, 4:33 pm

QuoteOriginally posted by: outrunCuch, that looks very similar to what I had indeed! 160 Euro's I think. T4A I did a depth-first-search for a solution. It's basically combining two random selected parts and then realizing 5 steps further down the line that you should have connected that other bit of wood back then.The trick to the random part aggregation strategy is to find the right seed for the random number generator! IKEA should print that in the instructions!
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 25th, 2014, 5:06 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: outrunJust finished a CAD assembly project! An IKEA bed, took me exactly 5 hours.How many invoke(move,object) calls did you make?Not to mention revoke() and collide(). I suppose we need to do a stress-test of the assembly, what?
Last edited by Cuchulainn on May 24th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 25th, 2014, 7:43 pm

QuoteOriginally posted by: outrunCuch, that looks very similar to what I had indeed! 160 Euro's I think. T4A I did a depth-first-search for a solution. It's basically combining two random selected parts and then realizing 5 steps further down the line that you should have connected that other bit of wood back then.How was Euro 160 computed, including lineitem prices and VAT (!! and how cents are rounded/truncated)
Last edited by Cuchulainn on May 24th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 25th, 2014, 8:39 pm

QuoteOriginally posted by: outrunQuoteOriginally posted by: PolterI would also like to get rid of having to select the function, as in the following: invoke(rotate<decltype(c)>, c); invoke(collide<decltype(c)>, c, c); invoke(collide<decltype(c), decltype(p)>, c, p);While it's not worse than previous `rotate_circle` and `rotate_point` (and arguably an improvement -- e.g., no need to copy-paste function definition any more), this would be even nicer: invoke(rotate, c); invoke(collide, c, c); invoke(collide, c, p);maybe it can be done with this syntax?invoke<rotate>(c);invoke<collide>(c, c);invoke<collide>(c, p);.. and then move the rotate/collide template instantiation (via decltype) inside invoke?I am about 90% sure that what Polter want to do can be done with template template parameters. It's very easy. It's like a meta-template.
Last edited by Cuchulainn on May 24th, 2014, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20253
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Modern & Effective C++ design ideas

May 26th, 2014, 3:43 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunQuoteOriginally posted by: PolterI would also like to get rid of having to select the function, as in the following: invoke(rotate<decltype(c)>, c); invoke(collide<decltype(c)>, c, c); invoke(collide<decltype(c), decltype(p)>, c, p);While it's not worse than previous `rotate_circle` and `rotate_point` (and arguably an improvement -- e.g., no need to copy-paste function definition any more), this would be even nicer: invoke(rotate, c); invoke(collide, c, c); invoke(collide, c, p);maybe it can be done with this syntax?invoke<rotate>(c);invoke<collide>(c, c);invoke<collide>(c, p);.. and then move the rotate/collide template instantiation (via decltype) inside invoke?I am about 90% sure that what Polter want to do can be done with template template parameters. It's very easy. It's like a meta-template.Yes me too! Maybe the square of you but still very sure, and it's clearly a template template and also partial specialised (we want the shape type be inferred from the argument)I think in any case you are getting close to a solution. Intuitively, getting that/some extra level of indirection is the way imo.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Modern & Effective C++ design ideas

May 26th, 2014, 10:45 am

rotate(Composite& c, double angle) illustrates one of the challenges of apply functions to elements of a container. Should rotate() operate on the assemblage or only on the elements? And if it operates on the assemblage, the rotate() must iterate once over the container to assess the assembly and then iterate a second time to do the required rotate() and move() to affect the composite rotation.In other words, how do we know if a given composite is just a set of independent objects with no relationships between the objects versus a set of dependent objects with some relationships that should be preserved during rotate()?