Tag: develop

An Infinite loop in Java, but not to everyone!

One of the things, after all these years, that keeps me fascinated about coding, it’s finding curiosities in a few lines of code that make me think for a while!

public class JavaPearls {

    public static void main(String… args){

        Integer a = new Integer(10);

        Integer b = new Integer(10);

        for(;a<=b && b <= a && a != b;)




The not so ACID transaction properties

If you work with Database Servers you know that ACID its not implemented/active by default! And if you have it implemented you have a really poor performance on your database server!

Lets examine each one of these properties:

A = Atomicity

Definition by wikipedia: “Atomicity requires that each transaction is “all or nothing”: if one part of the transaction fails, the entire transaction fails, and the database state is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors, and crashes.


– “… and the database state is left unchanged“. Unless you configure your database server with ISOLATION LEVEL SERIALIZABLE this is not true. By default most SGBD are configured with Read Commited, with allows some changes like phantom reads.

C = Consistency

Definition by wikipedia: “The consistency property ensures that any transaction will bring the database from one valid state to another. Any data written to the database must be valid according to all defined rules, including but not limited to constraintscascadestriggers, and any combination thereof.”

RIGHT for schema state, WRONG for value state (explained in atomicity above)

I = Isolation

Definition by wikipedia: “The isolation property ensures that the concurrent execution of transactions results in a system state that could have been obtained if transactions are executed serially, i.e. one after the other. Each transaction has to execute in total isolation i.e. if T1 and T2 are being executed concurrently then both of them should remain unaware of each other’s presence

WRONG! Only in dreams! its possible, yes, but in the way you encounter DEADLOCKS and Poor performance. If you want a performance database server you must drop the isolation to the lowest level possible! Its the price to pay for having fewer locks in the middle of your transactions.

D = Durability

Definition by wikipedia: “Durability means that once a transaction has been committed, it will remain so, even in the event of power loss, crashes, or errors. In a relational database, for instance, once a group of SQL statements execute, the results need to be stored permanently (even if the database crashes immediately thereafter).”

RIGHT! Well, I give this one, and I’m glad I could, what was a database server without it! 😉 However, actual high performant database servers have some kind of memory cache where there is a risk of loosing data, but, as far as my knowledge goes, it only happens in some NoSql databases… I hope…

Complex or Complicated

Usually these are words used as synonymous, when in fact they are orthogonal between them.

When we are talking about “complicated”, we are explaining something about linearity. Something is “simple” or “complicated”. What does this mean? Let’s see an example:

Something “simple”: understanding how a bicycle works. I think we don’t need to a genius for this, you analyze the “simple” engine and after some minutes (hopefully seconds) you’ve figured it out!

Something “complicated”: How a clockwork works. If you try to analyze it, you will have to think and analyze the mechanics for a long time, write a lot, until you figure out how the watch works, and how all those components fit together to give you an “accurate” time. It’s a task that’s its possible, takes some time, but you can analyze it linearly until you find the solution that explains it 100%.

Click image below to follow to a site explaining how this works!

Terminology of the geartrain

The image should be perceived has trying to show a complex system, but its not, it’s just very complicated, but with a 100% detailed explanation how the engine works!

So, we have Simple and Complicate, as 2 grades of linearity.

How about “Complex”?

When we say “Complex”, we are talking about behavior, not linearity. We can take several degrees of behavior but let’s analyze 3 very understandable:

“Predictable”: Something that we can predict, we could not understand it totally, but we know how it responds: For Instance: I jump, and gravity pushes me down again. Do I understand gravity? Something in school…. but…. its invisible and pushes me down! 😉

Complex: Something that we can somehow predict but sometimes arises some unexpected behavior.  For instance: Social interactions in a small company, home, software projects with several components in different tiers. Or Poker, a game with rules, but not predictable.

Chaotic: Like complex systems, but with plenty unexpected behavior factors. For instance: Events in  a big city. weather sometimes is complex and sometimes chaotic.

So, I hope in the future when someone use the word  complex knows that’s its different from complicated. Saying complicated means I just need tools and time to figure it out, and complex I could have tools and time and take my whole life and not discover or even completely predict the system.


Hopefully in future posts dive deeper on this subject. It’s a very popular one in software team leading.

Silverlight 4–StackPanel, Scrollbars, effects, others….sometimes its better not!

I really like Silverlight 4, and in the last months I ‘ve developed a Silverlight App which communicates with WCF which by the way talks to Sharepoint 2010 and Sql Server 2008R2. Well, with all this complexity, as you may guess I had to learn a lot about handlind strange bugs and problems…

Below, some of them with my solutions… a few more in later posts.

Stackpanel & Grid

You have a Grid with scrollbars, but they don’t show when data reach the bottom of the window or panel.

If you have a Grid inside a Stackpanel, see a way to remove the Stackpanel. You can use a DockPanel for instance.

AutoCompleteBox & Popup Window

When you use a AutoCompleteBox the dropdown window appears on the upper left corner of your popup window.

See if you are using Effects and remove them. It’s a well know bug… maybe at this time its fixed… or not..

ChildWindow and DialogResult

You want to call a ChildWindow as a DialogBox and collect the final DialogResult.

It will not work, because Silverlight uses an Async model. You need to create a delegate (which will point to a “local” method that will handle the result), pass it on the constructor and inside the childwindow, when you are ready to exit, call the “delegate” method and then exit.

PS: If you need an example give me a call…


You will have some forms and communications to outside Silverlight, for instance WCF.

Please use, MVVM or similar pattern, you will need if your Silverlight app grows. I had to refactor my app, because I didn’t follow this pattern from the beginning.

You can find more about this pattern here:

Bad Behavior has blocked 93 access attempts in the last 7 days.

Hyper Smash