composition

React.js: Composing components to create tabs

故事扮演 提交于 2019-12-03 16:48:03
问题 I’m trying to make a tabs component. TabsSwitcher and TabsPanel must be separate components so they could be used anywhere in DOM, e.g. TabsSwitcher doesn’t have to be followed by TabsPanel. To make it work, I need to somehow connect these components. Furthermore, TabsSwitcher must be able to tell TabsPanel when a tab was clicked. /** @jsx React.DOM */ var TabsExample = React.createClass({ render: function() { var tabs = [ {title: 'first', content: 'Content 1'}, {title: 'second', content:

How to prioritize different catalogs in MEF?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 15:35:08
I have a AggregateCatalog that contains an AssemblyCatalog and a DirectoryCatalog. I want them to work like this: If both catalogs can find an export, choose the one from the DirectoryCatalog. If neither of them can find an export, then just leave the import to be null. If only one of them can find an export, then just use that export to fill the import. How can I achieve something like this? You can achieve point 1. and 3. by putting the catalogs in different export providers, and then passing the export providers to the CompositionContainer constructor in order of priority like this: var

Chain functions in different way

心已入冬 提交于 2019-12-03 14:15:32
Scala functions has following methods for chaining: fn1.andThen(fn2) fn1.compose(fn2) But how can be written this case: I have function cleanUp() which has to be called always as last step. And I have a bunch of other functions, like that: class Helper { private[this] val umsHelper = new UmsHelper() private[this] val user = umsHelper.createUser() def cleanUp = ... // delete user/ and other entities def prepareModel(model: TestModel) = { // create model on behalf of the user } def commitModel() = { // commit model on behalf of the user } } And some external code can use code something like this

How can I compose an Entity Framework query from smaller, resusable queries?

北城以北 提交于 2019-12-03 14:09:07
I have a few (fairly redundant) queries in my app that are something like this: var last30Days = DateTime.Today.AddDays(-30); from b in Building let issueSeverity = (from u in Users where u.Building == b from i in u.Issues where i.Date > last30Days select i.Severity).Max() select new { Building = b, IssueSeverity = issueSeverity } And: var last30Days = DateTime.Today.AddDays(-30); from c in Countries let issueSeverity = (from u in Users where u.Building.Country == c from i in u.Issues where i.Date > last30Days select i.Severity).Max() select new { Country = c, IssueSeverity = issueSeverity }

Publishing Non-Thread Safe Object Fields in a Thread-Safe Manner

烂漫一生 提交于 2019-12-03 13:39:34
I've got a problem with Java concurrency. Yes, I looked at questions with almost the exact same title, but they all seemed to be asking subtly different things. Yes, I've read Java Concurrency in Practice . Yes, I can see why it's the defacto reference for the topic. Yes, I've read the section specifically on publishing fields in thread-safe classes. Yes, I'm still going to ask a concurrency question on Java regardless of the fact that I know someone will simply point me to that book. This has me stumped though -- I know that you can easily publish mutable primitive fields in a thread-safe

Using self-defined Cython code from other Cython code

若如初见. 提交于 2019-12-03 12:32:59
I am currently trying to optimize my Python program and got started with Cython in order to reduce the function calling overhead and perhaps later on include optimized C-libraries functions. So I ran into the first problem: I am using composition in my code to create a larger class. So far I have gotten one of my Python classes converted to Cython (which was difficult enough). Here's the code: import numpy as np cimport numpy as np ctypedef np.float64_t dtype_t ctypedef np.complex128_t cplxtype_t ctypedef Py_ssize_t index_t cdef class bendingForcesClass(object): cdef dtype_t bendingRigidity

Difference between dependency and composition?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 12:00:23
问题 Definitions taken from here Dependency Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. When one class contains the other class it this happens. Composition Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence

python: inheriting or composition

烂漫一生 提交于 2019-12-03 11:34:06
问题 Let's say that I have class , that uses some functionality of dict . I used to composite a dict object inside and provide some access from the outside, but recently thought about simply inheriting dict and adding some attributes and methods that I might require. Is it a good way to go, or should I stick to composition? 回答1: Inheritance is very often abused. Unless your class is meant to be used as a generic dictionary with extra functionality, I would say composition is the way to go. Saving

Haskell Polymorphic Recursion with Composed Maps causes Infinite Type Error

随声附和 提交于 2019-12-03 08:44:06
What is the right way to create a function that can dynamically create composed map? This results in an error (also happens with fmap): createComposedMaps list = accumulate list map where accumulate (x:xs) m = accumulate xs (m.map) accumulate [] m = m The list is irrelevant, it's just there to count the number of compositions. The error I get back is about "cannot construct infinite type": Occurs check: cannot construct the infinite type: a2 ~ [a2] Expected type: (a2 -> b1) -> a2 -> b1 Actual type: (a2 -> b1) -> [a2] -> [b1] Relevant bindings include m :: (a2 -> b1) -> c (bound at dimensional

Java GC: top object classes promoted (by size)?

喜夏-厌秋 提交于 2019-12-03 08:34:54
Please let me know what is the best way to determine composition of young generation memory promoted to old generation, after each young GC event? Ideally I would like to know class names which are responsible say, for 80% of heap in each "young gen -> old gen" promotion chunk; Example: I have 600M young gen, each tenure promotes 6M; I want to know which objects compose this 6M. Thank you. JT. There is no easy way to do this, however, I have recently been analyzing memory performance of large java apps, and can share some experience. Here is how I found what objects are being promoted to old