composite

Is the Composite Pattern SOLID?

為{幸葍}努か 提交于 2019-11-30 14:56:06
问题 A Leaf in the Composite Pattern implements the Component interface, including Add , Remove , and GetChild methods that a Leaf is never going to use. This seems to be a violation of the Interface Segregation Principle. So is the usage of Composite Pattern SOLID? link to Composite Pattern: http://www.dofactory.com/Patterns/PatternComposite.aspx 回答1: The real smell in the pattern as depicted in your link and most books is that Component has the methods of a Composite . I think this is probably

Difference between the Composite Pattern and Decorator Pattern?

被刻印的时光 ゝ 提交于 2019-11-29 19:51:55
What is the difference between the Composite Pattern and Decorator Pattern? Phil Wright They usually go hand in and hand. In that using the composite pattern often leads to also using the decorator pattern. The composite pattern allows you to build a hierarchical structure (such as a tree of elements) in a way that allows your external code to view the entire structure as a single entity. So the interface to a leaf entity is exactly the same as the entity for a compound entity. So the essence is that all elements in your composite structure have the same interface even though some are leaf

When should I use composite design pattern?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 19:25:24
I don't understand when I should use composite design pattern . What kinds of benefits will I get from this design pattern? I visited this website but it only tells me about the structure of the design pattern and not the scenarios in which it is used. I hope that it will be beneficial to the programmers like me who are starting to learn design pattern. Quoting from Design Patterns , Use the Composite pattern when you want to represent part-whole hierarchies of objects. you want clients to be able to ignore the difference between compositions of objects and individual objects. Clients will

Imagick: compose with mask

纵饮孤独 提交于 2019-11-29 05:44:01
I try to recreate a script that uses the ImageMagick command "convert" to compose an image. But I want to do the same in PHP using Imagick (version 6.6.2-10). The command is as follows: convert A1.mpc A3.mpc A4.mpc -channel rgba -alpha on -virtual-pixel background -background none -define compose:args=312x26.6776 -compose displace -composite out.mpc I found out that the parameters stand for the following: convert {background} {overlay} [{mask}] [-compose {method}] -composite {result} The PHP Imagick gives me a compose method, but without a mask parameter: http://www.php.net/manual/en/imagick

Composite primary key

穿精又带淫゛_ 提交于 2019-11-29 03:05:33
I am working on the design of a database that will be used to store data that originates from a number of different sources. The instances I am storing are assigned unique IDs by the original sources. Each instance I store should contain information about the source it came from, along with the ID it was associated by this source. As an example, consider the following table that illustrates the problem: ---------------------------------------------------------------- | source_id | id_on_source | data | ---------------------------------------------------------------- | 1 | 17600 | ... | | 1 |

How to do composite with gm node.js?

核能气质少年 提交于 2019-11-28 21:29:19
问题 How to do 'gm composite -gravity center change_image_url base_image_url' with GM Node.js? How to call gm().command() & gm().in() or gm().out() to achieve the above? 回答1: After struggling for an hour, here is my solution for your question: gm composite -gravity center change_image_url base_image_url gm() .command("composite") .in("-gravity", "center") .in(change_image_url) .in(base_image_url) .write( output_file, function (err) { if (!err) console.log(' hooray! '); else console.log(err); });

When are interfaces needed?

会有一股神秘感。 提交于 2019-11-28 16:52:25
(In the context of .NET for what its worth) I tend to not use inheritance and rarely use interfaces. I came across someone who thinks interfaces are the best thing since spit. He uses them everywhere. I don't understand this and hence the questions that follow. I just want a check on my understanding of interfaces. If you are using interfaces everywhere, I'm assuming you can predict the future, your app requirements are nailed down and nothing will ever change in your app. For me, during early development especially, interfaces become a drag. The app is very dynamic through its life. If you

Difference between the Composite Pattern and Decorator Pattern?

此生再无相见时 提交于 2019-11-28 14:44:15
问题 What is the difference between the Composite Pattern and Decorator Pattern? 回答1: They usually go hand in and hand. In that using the composite pattern often leads to also using the decorator pattern. The composite pattern allows you to build a hierarchical structure (such as a tree of elements) in a way that allows your external code to view the entire structure as a single entity. So the interface to a leaf entity is exactly the same as the entity for a compound entity. So the essence is

USB DUAL CDC endpoints for transferring data

眉间皱痕 提交于 2019-11-28 13:12:32
I have emulated two VCPs with only one USB Device. I can send data in one VCP that has the following Endpoint Address. #define CDC_IN_EP 0x81 /* EP1 for data IN */ #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ I would like to know if it's possible to send data in the other VCP with other Endpoint Address like: #define CDC_IN_EP3 0x83 /* EP3 for data IN */ #define CDC_OUT_EP3 0x03 /* EP3 for data OUT */ #define CDC_CMD_EP4 0x84 /* EP4 for CDC commands */ My problem is that addresses others than 0x81 don't allow me to send data over the second

WPF, Prism v2, Region in a modal dialog, add region in code behind

↘锁芯ラ 提交于 2019-11-28 09:14:55
I have a composite WPF application. In one of my modules I want to make a wizard and have the steps show up in a region so I can switch between the steps easier. Originally I had this wizard showing up in a tab region and the nested region worked fine. Now I want to make it into a modal dialog box, but after I open it the inner region never gets registared with the region manager; So I can't add my wizard steps. I was under the impression that the region manager was global, and just adding cal:RegionManager.RegionName="WizardSteps" would do it, but apparently not. If i pass the region manager