Thursday, November 5, 2009

The map is not the territory

Today I was attending some time management training but it turned surprisingly interesting. Anyway, it was more about how we function, the concious and subconcious states. Basically, it seems we switch around 40 times to the subconcious state.
Are you fully awake when in the morning you take a shower?
Or does it happen that when you enter the office it clicks to you, how the heck I drove to here?
That's the subconcious baby. It seems the subconcious manages 250 million instructions per minute while the concious just 700... I may be incorrect on these figures but anyway just to emphasize the difference.
I unconciously did a lot of these things... do you ever want to switch to the subconcious state when you want to implement some piece of code?
I do, I put on my ear plugs, listen to some music (I listen to the same music, if I listen to some new album than I switch back to the concious state!), detach from the surroundings and get lost in my coding! That's why I like my job!
I prefer to work in this subconcious state than doing pair programming!
Personally I think I am more productive and deliver better when I work in this state than working in pairs... That's my way of thinking.
Check out this link for more information

Sunday, November 1, 2009

Removing a workspace from Eclipse

Occasionally one wants to remove a workspace from Eclipse.
This is how one can remove it from launching a deleted workspace.

  • Close Eclipse if its running
  • Browse to the folder /configuration/.settings in the Eclipse installation folder (%ECLIPSE_HOME%)
  • Note that .settings is a hidden folder (Ctrl-H in Ubuntu to display hidden files)
  • Open the file org.eclipse.ui.ide.prefs. This is where Eclipse stores workspace information.
  • Just edit the key named RECENT_WORKSPACES
  • Save and restart Eclipse.

Thursday, October 29, 2009

Getting Spring POJOs from external Spring unaware systems

There are cases when one wants to instantiate POJOs from classes that are not Spring aware (like old EJBs).
In such circumstances, one needs to get the Spring application context and retrieve beans from the Spring container.

This is how you do it:

1. Create a class that provides the Spring application context from the container
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
* This class provides an application-wide access to the
* Spring ApplicationContext!
*
* Use AppContext.getApplicationContext() to get access
* to all Spring Beans.
*
*/
public class ApplicationContextProvider implements ApplicationContextAware
{
private static ApplicationContext ctx;

private ApplicationContextProvider(){}

public static ApplicationContext getApplicationContext()
{
return ctx;
}

@Override
public void setApplicationContext(ApplicationContext ctx) throws BeansException
{
this.ctx = ctx;
}
}

2. Wire it in Spring

<bean id="contextApplicationContextProvider" class="com.yournamespace.ApplicationContextProvider"></bean>

3. Get a bean from any other class

SomeBean bean = (SomeBean)ApplicationContextProvider.getApplicationContext().getBean("someBean");

Thursday, October 22, 2009

Building an Agile Team

I have read this article with interest regarding building an Agile Team
Very good points, summarizing everything in two words: building an Agile Team, its all about communication and resources... good resources!
But from experience I would like to add the following point:
What about one tries to build an Agile team with the existing resources?
This is the common scenario were one tries to introduce Agile in an existing technical department.

I think Agile\Scrum is all about common sense. Definitely as stated in the article, communication is what makes the success of an Agile team but also the continuous improvement, sprint after sprint.
And I think that's what makes sprint retrospectives very important. From experience, sprint retrospectives are not given the necessary attention. Sometimes, retrospectives are done for the sake of doing them.

A retrospective should be a 'mini-revolution'.
Pigs should openly speak of what is hindering their velocity and how can improve it like:
  • Software used for the Agile process
  • External forces interfering the team
  • Lacking of particular resources
  • Problems with the current architecture, framework used...and so on.

Monday, September 14, 2009

ASP.Net Setting Text for a Textbox with TextMode = Password

When one sets the Text property in a TextBox with TextMode = Password, the default behaviour is to render the TextBox empty.
Basically for security reasons and that's the normal and correct behaviour.
But and there is always a BUTT, one may want to set the Text in a TextBox with TextMode = Password.
The way to do it is as follows:

txtPwd.Attributes.Add("value", customer.Password);

Tuesday, September 8, 2009

Call JQuery code from ASP.Net server side

A little trick to call JQuery code from the server side.
A typical example is that when one wants to show different panels of a wizard or when a form is submitted successfully, one wants to show 'Congratulations' page.

Basically one just needs to inject the Javascript code in the server side code and JQuery will execute it once it is in control.
Like the following code snippet:

StringBuilder
sb = new StringBuilder();
sb.AppendLine("$(document).ready(function() {");

sb.AppendLine("showForm();");
sb.AppendLine(" });");

Page.ClientScript.RegisterClientScriptBlock(typeof(Page),Guid.NewGuid().ToString(), sb.ToString(), true);

Sidenote, the JQuery document ready function can be in an external javascript file. The above will still work.