Monday, April 2, 2012

如何在Python內使用Singleton方法



# There is an example to do with Singleton in Python def singleton(cls): instances = {} def getinstance(): if cls not in instances: instances[cls] = cls() return instances[cls] return getinstance @singleton class MyClass(): def __init__(self): self.data = "AAA" if __name__ == "__main__": obj_a = MyClass() obj_a.data = "AAAA" print obj_a, obj_a.data obj_b = MyClass() print obj_b, obj_b.data

Big Switch: the SDN Coffee Talks

Big Switch Networks Launches SDN Coffee Talks to Further Educate the
Broader IT Community on Software-Defined Networking (SDN)

the SDN Coffee Talks
http://www.bigswitch.com/sdn-coffee-talks/

如何取得Open vSwitch 上的 datapath id

ovs-vsctl -- get bridge br-int datapath_id

[HowTo] Build up GRE Tunneling on Open vSwitch

// Create a bridge
ovs-vsctl add-br br0

// Build up GRE Tunnel on remote host's ip = x.x.x.x
ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre options:remote_ip=x.x.x.x

In this article, the author explains more info about GRE Tunneling in details.
http://d.hatena.ne.jp/kazuya_ax/20120420/1334928361
The way for him to build GRE Tunneling is as follows:
ovs-vsctl set interface gre0 type=gre options:remote_ip=x.x.x.x options:pmtud=false

Friday, April 11, 2008

Iron Speed Designer

Iron Speed Designer is a .NET web application development tool that can generate your web application straight from your database. You just simply point to an existing database and let the Iron Speed Designer wizards build a sophisticated, database-driven application that's easy to customize and ready to deploy.

If you are a web developer and dedicated in ASP .NET programming, you maybe feel uncomfortable about the information as follows. What I mean is that you probably could not build a .NET web application more better than it if you already have several years work experience with ASP .NET.

Check out these links.

Iron-Speed Designer Web Site:
http://www.ironspeed.com/products/Landing.aspx?c=CP02

Demo Video:
http://www.ironspeed.com/Designer/5.1.0/Videos/5MinuteVideo/5minutevideo.html

Friday, March 21, 2008

SoftRock FM 102.1

After several days in studying hard for the midterm, I finally can take a break and relax a little bit. Meanwhile I feel that this blog is full of too much stuffs about IT field. It should be balanced with other topics.
In Cleveland, SoftRock FM 102.1 is the radio channel I listen to it so often. The songs it plays are almost very popular and favorite for people. It also has web site on the Internet for listening. Click "Listen Live" and enjoy it. Here you go. http://www.wdok.com/

Thursday, March 6, 2008

Google Web Toolkit

If you are familiar with Java programming but not familiar Ajax (Asynchronous JavaScript + XML) , Google Web Toolkit (GWT) is a good choice to deal with Ajax web application.
GWT provides its APIs for developers to write Java code in the program, and then compiles to JavaScript. In the web site of GWT, it gives a lot of features about GWT, and explains how to translate Java code to JavaScript.
Some people may have an question why I need to write Java code instead of JavaScript directly? In my opinion, it is about "software engineering". It may be easy if you only have a small or not so big Ajax application. Once you have more and more projects that need to do, you probably will find that your debugging time is longer than you think and your source code is hard to be reused. Due to these issues above, Google develops this way to deal with Ajax. Using GWT, we can leverage Java's ability and Java IDE tool to build application logic through well-designed object-oriented techniques.

Saturday, March 1, 2008

To promote reusability

To reuse our source code or classes is a hard task specially when we don't think about this in the beginning of analysis or design. Even though we have already done our projects or programs that is not well-designed, we can use some refactoring function inside the IDE tool for us to adjust or arrange our source code, for instance, to extract the interface from classes. But, it is still much better if we know how to promote reusability and do it in the analysis/design phase. In the book, Pro Java Programming 2nd Edition, it provides 2 good principles (Loose Coupling and Strong Cohesion) for reference.

1. Loose Coupling
Coupling means that it refers to the degree to which classes depend upon one another, and two classes that are highly dependent upon each other are considered tightly (or highly) coupled. In other words, they cannot be used alone and also not be used for other classes. There are some examples from this book and I draw the class diagrams to explain the idea.

a.) This diagram shows that these two classes have strong coupling. They refer each other and are Bad-designed.

b.) This diagram shows that it uses an interface "FontListener" to reduce the coupling. "FontProperitesPanel" doesn't need to know who implements the interface "FontListener". It just calls the method "fontChanged()" in the interface, and "SampleTextFrame" that implements the interface will response.

c.) This diagram shows we create a "FontPropertiesFrame" class that extends "SampleTextFrame" that can eliminate "SampleTextFrame"’s references to the "FontPropertiesPanel" class and move them into a subclass of SampleTextFrame.
2. Strong Cohesion
If a class is highly cohesive, it means its responsibilities are closely related and that it’s complete. In other words, the class isn’t cohesive if it contains methods that perform unrelated functions or if some set of closely related functions is split across that class and one or more others.
So, I think that these 2 principles are quite useful when we design our classes structure.