Oct 1 2011

Team We

Even when I have been the sole developer in a class, interface, module, library, or feature I try to always report progress as “We.” For defects and issues it’s always easy to point out the fault and personalize the problem when it was caused by someone else. Avoid naming names or singling out an individual. Saying “Your broke this” doesn’t make you look better or solve the issue. Restate it as “This was broken by this change list you committed on this date while trying to resolve this other issue.” Don’t personalize blame or fault, and provide as much information as you can gather to better solve the issue. Don’t stop when you find something is broken, or when you find who broke it, find out why it was broken in the first place, and if at all possible suggest viable solutions.

A few days ago, a engineer called me over for some help. He immediately started making using accusatory language as if I had committed some crime. “There is a bug and you wrote this so you did it and you didn’t do it well because there is a bug.” He was pointing to 20 lines of code that I had written over a year ago in a much larger feature whose requirements had changed over time and because of his tone and desperation in his voice I could tell he was lost just dropped the anchor of blame wherever he could. I tried to get focus to the task at hand an not my code and asked a series of questions, what does the system do now? What should the system do? Does this always happen? What is unique when there is an error? Using this approach we found the issue in 10 minutes without staring down the code or focusing who wrote what method.


Sep 30 2011

Avoid overloading Meaning to Existing Database Column

I’ve always found that when defining a database table it is always best to create a integer primary key, even if a unique key such as social security number, ISBN, or some other business value. Recently I had to go through the unpleasant process of updating a database table and associated scripts, resources, and code that had used a business attribute as the primary key but because of business requirements it was no longer unique and had grown to have different meanings. Because your business requirements will change, don’t use business attributes as primary keys for you database design. In addition, don’t overload attributes to more than one meaning. For example, the database that I was working with had a database column called Sequence that functioned as the primary key, the line number, and a workflow execution order to process the data. It is a source of confusion and bugs to overload one attribute to so many different meanings.


Sep 29 2011

Find the Current Working Directory in Java

There are times when you don’t have full control of the location where your Java application runs from. This could happen because the application is installed in a location other than the one recommended by the installer, or because it ran from the IDE, or some other reason. For whatever reason, if you need to find the current working directory where your Java application runs there are two different approaches. The first approach is to use the File class and the current directory symbol to find the current directory. Remember that the single period “.” represents the current directory and two periods “..” represents the parent directory.

   String currentPath = new File(".").getCanonicalPath();

Unfortunately, using the File class throws an IOException. There is another approach that does not throw an exception and returns the same absolute path to the current directory where the Java application is running from.

   String currentPath = System.getProperty("user.dir");

Sep 28 2011

Copy Records From One Database To Another

Most applications require a database of some sorts, and when working with a database you most likely will have a production, development, and test database to work with in addition to backups. A common problem I found is that sometimes I want to move rows of data for a particular database table between the different databases I work with. For example, I found I need to copy a subset of data from a table from the production database to the test database so that I had good data to test with. A typical approach is to create a backup from the production database and restore it as a test database, but if you just want to copy a subset of rows from a particular table that approach is overkill.

In SQL Server, you can use a insert statement to insert new rows in a database where you select and filter the data from a different database. This is also true for other database vendors but the SQL might be slightly different.

To further illustrate this, imagine I have a database table blog_posts in a production database called BlogProduction and a test database is called BlogTest and they both reside on the same SQL Server instance. From SQL Server Management Studio or SQLCMD or from where ever you run your SQL statement you can run the following statement.

INSERT INTO blog_posts
SELECT * FROM BlogProduction.dbo.blog_posts

If you run the above statement from the perspective of the BlogTest database, you are will insert all the records from the blog_posts table in the BlogProduction database into the blog_posts table in BlogTest. The above example, assumes the database owner is dbo. It is not required to name the database owner and the following does the same.

INSERT INTO blog_posts
SELECT * FROM BlogProduction..blog_posts

You can also add a where clause to the select statement to filter out certain data to insert to your current database.

INSERT INTO blog_posts
SELECT * FROM BlogProduction..blog_posts
WHERE id > 100

In this way, you can move data from different database tables from different databases.


Sep 16 2011

Create SQL Server Database and Database Tables From a File

When working with a database, it’s is always handy to develop a series of scripts to backup, restore, create, move databases around. As of late, I’ve been working with SQL Server a lot so I’ve come to appreciate the sqlcmd utility.

You can run the sqlcmd utility from the command line and run a input sql script and capture the output in a file. The input sql script file can run any sql statement, such as creating a new databases, views, tables, or procedures. You can also restore and backup any given database or whatever else you require.

To run the sqlcmd utility and have it read a file, createTables.sql, you can run something like the following from your command line, of course if you have SQL Server Management Studio and sqlcmd installed.

sqlcmd -S localhost -d dbName -U user -P password -i createTables.sql -o output.out

Sep 12 2011

Retweet August 2011

From time to time I just blast tweets about software development, project planning, team dynamics, or whatever else comes to mind. Here is a synopsis of recent tweets and rants. If you want to follow the conversation follow me at techknow and/or juixe.

Software Development

  • More code, more problems.
  • Code. Money. Respect.
  • Code war is the new cold war.
  • The programer-designer is the philosopher-king or our time.
  • Give a man a fish and he’ll eat for a day. Teach a man to gold farm and he’ll eat for a lifetime.

Team Leadership

  • When the world is flat and information freely available there is a premium on creativity.
  • There is no such thing as free lunch, especially if it’s lobster.
  • Give a silicon valley startup founder a lemon and he’ll make a social networking site for people that like lemonade.

Product Placement

  • I hope Twitter doesn’t become the next MySpace.
  • There is no i in Apple.
  • Google is buying Motorola for $12.5 Billion. Google is also developing a autonomous car, so in a few years it might buy Ford.
  • It’s not Thanksgiving, so why did Google pay so much for a moto turkey?
  • AT&T charges for services you use and most importantly for services you don’t, and they sell you out to the feds on top of that.
  • I know that many G+ users are still in the early adopter stages of denial, but honestly, Google does not know how to do social right.

Quote

  • Money is a terrible master but an excellent servant. – P.T. Barnum
  • Wall Street is now a huge mathematical game of chess where individual companies are just pawns. – Mark Cuban
  • Search is dead. What people want is an answer. … You don’t need Trip Advisor, you don’t need Yelp. – @Jason, #TWiST 171

Questions

  • Got Woot?
  • You think Papa Murphy’s is related to Papa John’s?
  • Has Flash lost it’s fizzle?
  • If G+ was spun out of Google as an independent company it would be valued at $50 billion.
  • What company will be around in 25 years, Apple, Zynga, Facebook, Google, eBay, Microsoft, …???
  • Now they are making movies in 4D… What is next, 7D?
  • If this is your third startup, are you really still a starting up?
  • I just want to know, why are those birds so angry?

Randumb

  • When life gives you bullshit, make lemonade.
  • Untangling headphones in the dark.
  • Current Status: somewhere between FML and IDGAFF.
  • Zoned out from being on the zone for so long.
  • The future is retro.
  • Don’t trust your shit to chance.
  • MTV has as much expertise to produce MTV’s Music Awards as the History Channel’s has to produce Ancient Aliens.
  • It’s ironic how many people misuse the word irony.
  • Even though I haven’t gone back to school for a while now, I can’t resist a good Back To School sale!
  • I tired of Shark Week. When will they have Turtle Week or Salamander Week?
  • If Teenage Mutant Ninja Turtles were to be created now they would have been known as Angry Turtles.
  • Total Retargeting
  • Shift+Happens