:spades: C# to JavaScript compiler. Write modern mobile and web apps in C#. Run them anywhere in JavaScript with Bridge.NET. Bridge.NET - Open Source C# to JavaScript Compiler open source c# to javascript compiler and frameworks. it's platform independent and supports popular frameworks like jquery, bootstrap, webgl, qunit and more.

Use Qt-based lib in gtk framework

We're trying to find out how I can use the Qt code we wrote in a gtk-based application. Rumour has it that adapters are possible, in less than 600 LoC, but apparently all links lead to web pages covered in 6 years worth of dust.

So here's the question: how can I create a QCoreApplication that uses the gtk main loop?

Source: (StackOverflow)

Difference between Bridge pattern and Adapter pattern

What is the difference between the Bridge and Adapter patterns? Where i can use each pattern?

Source: (StackOverflow)

Docker: how to connect two bridges

As you know after Docker 1.9 we can create bridges to connect containers.

I have created two custom bridges: bridge A and bridge B

Now I have a container1 on bridge A, and a container2 on bridge B called "mailServer".

The container1 needs to reach container2 by a DNS, how should I do this? Because they are on different bridges so they cannot talk to each other. Do I need a router and can I achieve this by Docker?

This is a new feature of Docker and I didn't find much information. Thanks.

Source: (StackOverflow)

Bridge vs. Adapter Design Pattern

I was questioned by a colleague about the design pattern of my implementation of a WCF windows service in a ASP.net client application and I really could not tell whether it is Bridge or Adapter!

Here is the implementation:

  • I have obtained the service contract
  • Defined a new interface similar to my WCF Data contract
  • I created a WCF client and wrapped it inside the new interface
  • Mapped the new interface operations to the original WCF client (I do some logging/error handling here)

I was always thinking of it as an implementation of Adapter pattern, but really I can not tell why isn't it Bridge!

I have read all the posts here in SO, GoF and wikipedia but it really makes no sense!

From my understanding, Both patterns point at an existing type, both decouple an abstraction from its implementation am I missing a point?

Here's from GoF:

The key difference between these patterns lies in their intents. Adapter focuses on resolving incompatibilities between two existing interfaces. It doesn't focus on how those interfaces are implemented, nor does it consider how they might evolve independently. It's a way of making two independently designed classes work together without reimplementing one or the other. Bridge, on the other hand, bridges an abstraction and its (potentially numerous) implementations. It provides a stable interface to clients even as it lets you vary the classes that implement it. It also accommodates new implementations as the system evolves.

I don't fully understand the above statement,

  1. Does it mean that if I vary the adaptee or change the implementation of the original interface at design time then it is Bridge Pattern?
  2. The differences sounds trivial, Is there any other differences in implementation/abstcation?
  3. How can anyone tell what implementation is used after development?
  4. Can anyone give me a good example of bridge pattern and how it can be changed during software lifecycle?


Again from GoF:

Remember that an adapter makes two existing interfaces work together as opposed to defining an entirely new one.

Does it mean that changing the existing interface so that it can work with another interface is an implementation of Adapter?


Just found this incredible article: Illustrated GOF Design Patterns in C#

This is true Bridge Patter structure:

I was missing the fact that the Bridge pattern lets you combine the different abstractions and implementations and extend them independently enter image description here

Source: (StackOverflow)

Does the Bridge Pattern decouples an abstraction from implementation?

I learned Bridge pattern from different articles and I have implemented that as per my understanding . One thing that is confusing me is bridge pattern says

BridgePattern decouples an abstraction from its implementation so that the two can vary independently

what is meaning of this statement? Is implementation resides at in separate jar ?

what is meaning of vary independently statement ?

considering the provided journaldev article, elaborate the answer.

Any help is greatly appreciated.

Source: (StackOverflow)

Luci (openwrt) wifi bridge client - how to configure?

i need to configure a wireless bridge (something like a wireless switch).

I have TP-LINK TL-WR740N v4.22 with OPENWRT installed and other TP-LINK router with default firmware. I need to do this setup:

Router A (connected to the Internet via WAN port) have IP: and is running DHCP Server

Router B (OPENWRT) is connecting to ROUTER A via WiFi - how to configure interfaces here ?

PC A - Connected by wire to Router B - should obtain IP from Router's A DHCP server.

How to configure it?

Source: (StackOverflow)

AbstractFactory Versus Bridge Pattern

I have just learned the Bridge Pattern and its intent : Decouple an abstraction from its implementation so that the two can vary independently.

But why couldn't just an AbstractFactory do the same thing ?

I know that an AbstractFactory can create a particular bridge but my question concerns usage of AbstractFactory instead Bridge for decoupling Abstraction and Implementation.

Could you please explain me the real difference between AbstractFactory and Bridge Pattern?

Source: (StackOverflow)

bridge pattern vs. decorator pattern

Can anybody elaborate the Bridge design pattern and the Decorator pattern for me. I found it similar in some way. I don't know how to distinguish it?

My understanding is that in Bridge, it separate the implementation from the interface, generally you can only apply one implementation. Decorator is kind of wrapper, you can wrap as many as you can.

For example,

Bridge pattern

class Cellphone {
Impl* m_OS;         // a cellphone can have different OS


Decorator pattern

class Shirt {
Person * m_p;           //put a shirt on the person;


Source: (StackOverflow)

Bridge- vs Strategy-Pattern

I know, this question was asked many times, but I did some research and still don't get it, probably you can help me out: As stated many times, the UML is almost the same. Also the implementation and idea is more or less the same: Instead of sub-typing, you define an Interface, which encapsulates some logic and let's it pass to an abstract. So, even the Microsoft-Blog guys

https://blogs.msdn.microsoft.com/gyanjadal/2015/01/05/difference-between-strategy-and-bridge-patterns/ says:

The simple answer is “They are similar but different”. The implementations are similar but the intentions are different. To give an analogy, a city bus and school bus are both similar vehicles, but they are used for different purposes. One is used to transport people between various parts of the city as a commuter service. The other is used for transporting kids to schools.

"If it sounds like a duck and looks like a duck but it intends to be a swan, it can be either of them", which is what I read here.

Since I still did't get it, so I digged deeper:


This Thread also doesn't add anything new, except:

They both look the same on the surface to me as well. The main difference I see is the fact that in the Bridge pattern, the abstraction is PART OF the object, but in the Strategy pattern the abstraction is performed BY the object.

But, if we read the definition of strategy:

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

There is nothing defined, how the Strategy is applied. It could also easily be an Interface on the Abstract, exactly the same the common Strategy-Implementation as LINQ-Orderby etc.

Another interest take on the topic is here:


The mainpart from this excourse:

You say "Strategy" when you want to vary behavior, and you do so not by writing different objects but by introducing a class heirarchy. You say "Bridge" when you expect that you will vary both the interface and the implementation. In both cases you're providing flexibility for a changing implementation; in a Bridge, you're also expecting the interface to change.

Is this probably the main-difference? Since the Implementor and the Abstraction are so loose coupled, I can change the Interface of the Implementor and the Abstraction doesn't have to care? That sounds reasonable, but wouldn't then have the Abstraction to change as well, since they are kindahow connected? Wouldn't that destroy all other principles like Information hiding and DRY?

I also looked at many many examples, which I don't add here for the sake of place, and I couldn't find an Example of either of those patterns I couldn't change to fit the other one. Be it via an Interface-Property or just an Parameter.

Did I miss anything here? Does probably anyone have a REAL-LIFE example of "I wanted to use Strategy, but the Bridge did just fit better", or visa versa, example?

Edit: Why do I justify an own Thread for this Topic (again)? First of all, the accepted answer of the mentioned Thread is the following

As I understand it, you're using the strategy pattern when you're abstracting behavior that could be provided from an external source (eg. config could specify to load some plugin assembly), and you're using the bridge pattern when you use the same constructs to make your code a bit neater. The actual code will look very similar - you're just applying the patterns for slightly different reasons.

I already provided in the previous explanations, that abstracting behavior from external source is exactly the definition of Strategy- and Bridge-Pattern.


and you're using the bridge pattern when you use the same constructs to make your code a bit neater.

Also the strategy pattern makes the code way neater, since it abstracts an whole building block away, thus thightens the Code quite a bit.

I think anyone, who read the whole topic sees, that there is more on this topic just than this 2 sentences.

Source: (StackOverflow)

How to set a specific (fixed) IP address when I create a docker machine or container?

When I create my container, I want to set a specific container's IP address in the same LAN.

Is that possible?

If not, after the creation can I edit the DHCP IP address?

Source: (StackOverflow)

docker: how to get veth bridge interface pair easily?

i have 2 containers by docker, and bridge like this:

root@venus-166:~# docker ps
CONTAINER ID        IMAGE                                         COMMAND                CREATED             STATUS              PORTS                      NAMES
ef99087167cb        images.docker.sae.sina.com.cn/ubuntu:latest   /bin/bash -c /home/c   2 days ago          Up 21 minutes>22223/tcp   night_leve3         
c8a7b18ec20d        images.docker.sae.sina.com.cn/ubuntu:latest   /bin/bash -c /home/c   2 days ago          Up 54 minutes>22223/tcp   night_leve2 

bridge name bridge id       STP enabled interfaces
docker0     8000.72b675c52895   no      vethRQOy1I

How can i get which container match veth* ?

ef99 => vethRQOy1I or ef99 => vethjKYWka


I know it works by ethtool, but is there any better way?

Source: (StackOverflow)

__bridge not needed for method arguments?

As we know, with ARC we need a __bridge to convert an id to a void *:

void *t = (void *)self;           // ERROR: Cast of ... requires a bridged cast
void *t = (__bridge void *)self;  // CORRECT

So are C function calls:

void f(void *t) {

f((void *)self);           // ERROR
f((__bridge void *)self);  // CORRECT

I think this should hold for methods as well, and indeed this Beginning ARC in iOS 5 Tutorial gives the following example, and says that the __bridge is needed:

MyClass *myObject = [[MyClass alloc] init];
[UIView beginAnimations:nil context:(__bridge void *)myObject];

However, today I accidentally dropped a __bridge in a method call in one of my programs, and the code compiled and ran without any issue. The __bridge in the above sample seems to be unnecessary:

[UIView beginAnimations:nil context:(void *)myObject];  // COMPILED OK

Is this right? Is the __bridge really unnecessary in this case? Or removing it changes what the code means?

Source: (StackOverflow)

Define struct that is treated like a class in Swift

In Swift a String structure is also treated as a class object like when using the NSCoder encodeObject(_:forKey:) method. I do know that String is directly bridged with the objective-c class, NSString, but is there a way to make a custom struct that behaves similarly? Perhaps bridge it to a custom class? I want to be able to do something like this:

struct SortedArray <Value: Comparable> {}

// Would I need to create a bridge between 
// SortedArray and NSSortedArray? Can I even do that?
class NSSortedArray <Value: Comparable> : NSObject, NSCoding {
    required init?(coder aDecoder: NSCoder) {}
    func encodeWithCoder(aCoder: NSCoder) {}

class MyClass : NSObject, NSCoding {
    private var objects: SortedArray<String> = SortedArray<String>()
    required init?(coder aDecoder: NSCoder) {
        guard let objects = aDecoder.decodeObjectForKey("objects") as? SortedArray<String> else { return nil }
        self.objects = objects
    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(objects, forKey: "objects")

Source: (StackOverflow)

How to forward source IPs to Docker containers without letting Docker mess with iptables

if you run something (e.g. nginx) in a Docker container and publish one of the exposed ports to the outside world (like docker run -p 80:80 nginx) then Docker will

  • expose the port to the public
  • set up iptables so that if something connects to the container through the Docker network bridge (NAT) then nginx will still know the proper source IP
  • ! open the firewall to that port completely

I don't want to allow anyone to connect to the published port, but Docker messes that up. So I relaunched the Docker daemon with --iptables=false that allows me to manage the firewall myself. However, nginx now only sees the bridge ( as the source address.

How can I keep control over the firewall and still forward the source IP address to the container?

Source: (StackOverflow)

How do the Proxy, Decorator, Adapter, and Bridge Patterns differ?

I was looking at the Proxy Pattern, and to me it seems an awful lot like the Decorator, Adapter, and Bridge patterns. Am I misunderstanding something? What's the difference? Why would I use the Proxy pattern versus the others? How have you used them in the past in real world projects?

Source: (StackOverflow)