Skip to main content

Posts

Showing posts from June, 2012

The difference between emulation and simulation?

Explain by Using as an example. You want to duplicate the behavior of an old HP calculator, there are two options: You write new program that draws the calculator's display and keys, and when the user clicks on the keys, your programs does what the old calculator did. This is a  Simulator You get a dump of the calculator's firmware, then write a program that loads the firmware and interprets it the same way the microprocessor in the calculator did. This is an  Emulator The  Simulator  tries to duplicate the  behavior  of the device. The  Emulator  tries to duplicate the  inner workings  of the device. More examples, For Emulation, You may know something about the case between Google and Oracle. In Brief, google implemented the same APIs(For Android) the java library provided to Java Developers to development Java applications. We can call it JRE Emulation Library. Also, in Google's  GWT, it did similiar thing(weird that Oracle did not sue Google For this

Method stub, in computer programming

A  method stub  or simply  stub  in  software development  is a piece of code used to stand in for some other programming functionality. A stub may  simulate  the behavior of existing code (such as a  procedure  on a remote machine) or be a temporary substitute for yet-to-be-developed code. Stubs are therefore most useful in  porting ,  distributed computing  as well as general software development and  testing . An example of a stub in  pseudocode  might be as follows: BEGIN Temperature = ThermometerRead(Outside) IF Temperature > 40 THEN PRINT "It's HOT!" END IF END BEGIN ThermometerRead(Source insideOrOutside) RETURN 28 END ThermometerRead The above pseudocode utilises the function  ThermometerRead , which returns a temperature. While  ThermometerRead  would be intended to read some hardware device, this function currently does not contain the necessary code. So ThermometerRead  does not, in essence,  simu

Mockito

fowarded from  http://monkeyisland.pl/2008/01/14/mockito/ Mockito I’m a  mockist  but existing mock frameworks just don’t appeal to me. They spoil my TDD experience. They harm code readability. I needed something better. That’s why I came up with  Mockito . Syntax Here is a what I think about mocking syntax: Let’s keep it simple: interactions are method calls.  There is no point in building sophisticated mocking language for method calls in Java. There is already a language for that. It’s called Java. The less DSL the better.  Interactions are just method calls. Method calls are simple, DSL is complex. No Strings for methods.  I spent more time reading code than writing it. Therefore I want the code to be readable. String literals pretending to be methods cannot compete with actual method calls. Even IDEs decorate literals differently so my mind will always adopt the real method call quicker than any literal trying to impersonate a method. No anonymous inner classes.  Th

Eclipse DemoCamps Juno 2012/Vancouver

This is the second time I attended Eclipse DemoCamps. The last time was in 2009 and hold in UBC. This time, they hold in the Camp in Vancouver Public Library, which is one block from my Company. One of the Sponsor(SpringSource) provided very nice food and drink for the Supper. I enjoyed the Sushi and Pop alot. We had a free communication during the break and i am glad to meet with the people from tasktop and SpringSource(the source of my favor Spring Framework). SpringSource also leaked their maybe next generation IDE, but I just can not leak here :) I also got a very nice Spring OEM USB disk, which is gorgeous for me as I am a Spring Fan. I am happy with this Camp. Go Eclipse Go.

SQL SERVER 2012 AND VISUAL STUDIO 2010 COMPATIBLE ISSUE

This morning, I realized that my visual studio was fully broken. I can not see any contents in the solution explorer(for the codes) and server explorer(for the db). Oh my God. Thanks google, I find solution below. After installed the  Microsoft SQL Server Data Tools, every went well. Cheers. http://sqlblog.com/blogs/aaron_bertrand/archive/2011/11/21/sql-server-2012-the-data-tools-installer-is-now-available.aspx http://msdn.microsoft.com/en-us/data/hh297027

Regular Expressions

A regular expression is notation for specifying a set of strings. e.g., the set of all valid email addresses or the set of all binary strings with  an even number of 1s. There are five basic operations for creating regular expressions, as below, Operation Regular Expression Yes No Concatenation aabaab aabaab every other string Logical OR (Alternation) aa | baab aa baab every other string Replication (Kleene closure) ab*a aa aba abba ε ab ababa Grouping a(a|b)aab aaaab abaab every other string Wildcard a..a abba abaa aa aaaaa Concatenation : the simplest type of regular expression is formed by concatenating a bunch of symbols together, one after the other, like  aabaab . This regular expression matches only the single string aabaab . We can perform simple spell checking by using the concatenation operation. For example, we could form the regular expression  niether  and then for each word in a dictionary check whether that word matches the regular expression. Presumably

The difference betwen Hibernate saveOrUpdate and merge Method

SaveOrUpdate: session.saveOrUpdate( someDetachedCat ); This is used to Reattach detached data. Reattachment is the process of taking an incoming entity instance that is in detached state and re-associating it with the current persistence context. The method name update is a bit misleading here. It does not mean that an SQL UPDATE is immediately performed. It does, however, mean that an SQL UPDATE will be performed when the persistence context is flushed since Hibernate does not know its previous state against which to compare for changes. Unless the entity is mapped with select-before-update, in which case Hibernate will pull the current state from the database and see if an update is needed. Provided the entity is detached, update and saveOrUpdate operate exactly the same. Merge: Cat theManagedInstance = session.merge( someDetachedCat ); Merging is the process of taking an incoming entity instance that is in detached state and copying its data over onto a new instance