Thursday, July 17, 2008
In order to succeed as a team, in any sort of team, you have to follow this basic principle, which has been applied and maybe is accepted universally.
The principle is simple.
- Appoint a Leader
- Leader makes council with the team
- Leader makes a decision
- Team supports leader in his or her decision
Its that simple. In this way, an organization, a team, a family, or a company can move forward. Every decision that you need to make, is done in this manner. The team will work together for the best solution, but in the end the leader needs to make a decision. Once that leader makes a decision, the team needs to move forward WITH the leader.
This means, the leader doesn’t necessarily dictate, but he or she has gathered input from the team and made a decision. Then they will have to choose a solution and go with it. If the team continues to argue and fight over the decision, progress will be slow. I believe this applies in families too. There has to be a decision maker in the family, for example that is appointed for financial decisions, and then having a discussion or gathering input from the family is great, but in the end one person has to make the decision, and the family needs to be supportive, even if they don’t all agree with it. However, this applies in normal circumstances and there are caveats. There might be some cases where it would be unethical for team members to support a plan if its morally wrong or it goes against everything inside them and they feel it’s a plan headed for disaster.
It pains me that time and time again I see this happen – the leader makes a decision and the team continues to question him at every step of the way – “Why are we doing this”, “Why are we doing this”, and “why are we doing this” instead of understanding that they were appointed for this role (they might be your boss for example) and they are ultimately responsible for the decision, you need to do your job and support them. I have seen some cases where I questioned my manager because I didn't see the wisdom in the decision he made, but in the end it turned out he was right and it was just my foresight wasn't as far as his... So I learned my lesson, be patient, and be a team player.
As a team member, sometimes I have to swallow my feelings and say, “okay I don’t think this is the smartest decision and my idea is actually better, but I will go with you on this”.
From a developers perspective, you can think of this as requirements. Your boss gives you the requirements, you implement it. How you implement is up to you, but you won’t be able to proceed if you start arguing about the requirements. Requirements are requirements, once they are agreed upon, please continue.
So in normal circumstances, if you want to succeed, get a leader, and help him with his decisions, but in the end.. Respect the decision he makes and go with it. (He or she, that is).
The best team isn't necessarily the one with the best players, it's the one that plays together the best.
Thursday, July 10, 2008
My experiences with outsourcing including tips on how to save millions of dollars or waste them.
Friday, July 04, 2008
Some tips on securing your PHP and how you can get hacked (hax0red) if it's not on.
Tuesday, June 17, 2008
If you are running a Web Site Project, yet you still want to have a build number somewhere in your application, this article will explain how you can create a simple tool to have an auto-increment build number and execute it using CruiseControl.NET
Link to a nifty tool on building regular expressions
Thursday, May 22, 2008
When unit testing on your database, you will run into a common problem.
Rolling back.
So you want to do some unit tests, and then you want to reset your database back to the nice squeaky clean version that doesn't have half failed unit tests.
So how can you do this?
There are many ways to achieve this.
The best way I found (requires Win XP SP2 or Windows Server 2003) is to use Roy's Unit Testing Rollback Attribute. Simply inherit his class, add a "DataRollback" attribute, and you are good to go. Using some complicated Interception logic and Enterprise Services (COM+) it rolls back all the database work that was done. It's super easy to implement. Here is some sample code that shows you just how easy it is. You just have to download XtUnit (an extension to NUnit) to do this. (Full source code available)
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using TeamAgile.ApplicationBlocks.Interception.UnitTestExtensions;
using NUnit.Framework;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
namespace DBTest
{
///<summary>
/// Test roll back functionality.
///</summary>
[TestFixture]
public class RollbackTest : ExtensibleFixture
{
[Test, DataRollBack]
[Category("Database")]
public void TestInsert()
{
//this method will be performed inside a COM+ transaction
//this requires windows XP SP2 or better
//Windows Server 2003 works as well.
string strCnn = "your_conn_string";
Guid random = Guid.NewGuid();
string sqlI = string.Format(@"insert into log4net (message,date,thread,level,logger) values ('{0}',getdate(),'{1}','Debug','Test')", random.ToString(), System.Threading.Thread.CurrentThread.GetHashCode());
SqlHelper.ExecuteNonQuery(strCnn, CommandType.Text, sqlI);
string sqlS = string.Format(@"select count(*) from log4net where message='{0}'", random.ToString());
int rowcount = (int)SqlHelper.ExecuteScalar(strCnn, CommandType.Text, sqlS);
Assert.That(rowcount > 0, "Cannot find {0}", random.ToString());
}
}
}
This test passes successfully. What does that mean? The insert and select worked perfectly fine. After that, I did a query and found the database to be clean. So the rollback worked too.
There are also other ways to skin this cat (i.e. to achieve this goal). One is to use Spring Framework and extend their Unit Testing class (AbstractTransactionalSpringContextTests), and they will handle rolling back everything. Here is an article on this topic, but unfortunately I was not able to make it work for me due to some odd reason. Here's hoping you have better luck. If you don't have any transactions, and your code is wired to use Spring, it's still also very easy, you just need to call TransactionManager.Rollback.
You can also try to achieve this using Nested Transactions if you have existing transactions implemented via Spring. But then you have to set up checkpoints and stuff like that.
I have some other ideas on how to achieve this that I will post later, God willing.
Thursday, May 08, 2008
This is a very shallow comparison of my experiences with PHP and ASP.NET
Don’t take this as a religious war or something, the idea is just some basic comparison.
Here is a summary: If you are choosing which technology to use to build an application, use .NET. You will get more bang for the buck. With the same effort you will be able to build a much more rich user interface.
My Disclaimer: Keep in mind there are a lot of great libraries and tools for PHP which I never got to use, I just had a simple PSPad text editor and my handy PHP web site. I really wanted some “Intellisense” style code completion but I could not get it to work with PHP since I couldn’t find a decent IDE (i.e. editor)
However, it all depends on your requirements. For example, if you are selling something that most of your customers will be on a shared linux hosting environment, then why would you use .NET ? A good example is the software Clipshare, which is a clone of Youtube. The sites purchasing this product are mainly shared hosting customers who have PHP but not .NET. And Mono (.NET port on Linux) is not yet stable or popular enough to use.
I did some PHP programming before I started doing .NET fulltime. Before then I couldn’t say much about it, but after working with .NET for a few years now, I have much to say.
.NET does a very good job in handling the whole life cycle. With PHP you have to do it manually. For example, there is no such concept of “Postback” with PHP. This is such a basic thing that you can easily check with .NET to see if the page has been submitted and what button was pressed. For example if your “btnSubmit” was pressed, it will call btnSubmit_Click. With PHP, you have to do this manually. Not to mention how mish mashed your PHP page can be in terms of mixed code and style/HTML elements.
How about caching? I wanted to implement caching with PHP and I had a fun time, I had to check if the cached output file existed, and then if so, then check how old it is, and so on... Yeah okay again maybe there are some nice components already done for this, but I didn’t have to look very hard to do it with .NET, I simply added a CacheDependency on an XML file (or whatever the case was), and BOOM! It regenerated the file whenever necessary.
How about reusable components? With .NET you can create ASCX (Custom Controls) that you can place within a page that expose certain properties and the control itself maintains its state, can have buttons, etc, etc.
How about master pages (i.e. templates) in .NET? Again, super cool reusability! You can create pages with repeatable parts, with headers, footers, all sorts of fun stuff.
I can go on and on... but in general, the more I use .NET, the more impressed I am with it. However, what makes it not-so-practical is how expensive Windows Server hosting is. In summary .NET kicks butt!
Monday, May 05, 2008
How adding a little bit of security can stop most hackers.
Wednesday, April 30, 2008
If you have crazy function overloads all over the place where you have to pass a transaction object and it seems to be never ending, here is a solution for you using the Spring.NET framework which is freely available and open source.
Tuesday, April 29, 2008
Two interesting examples as to how you can solve many problems not just in coding but in your life too by applying the principles of unit testing. This post gives you something to think about in regards to unit testing and why to use it in a more broad perspective.