Data Visualization Articles

http://dougmccune.com/blog/2011/04/21/visualizing-cyclical-time-hour-of-day-charts/comment-page-1/#comment-210950
http://dougmccune.com/blog/2011/04/26/visualizing-time-with-the-double-time-bar-chart/comment-page-1/#comment-210951

Advertisements

User Experience Desktop Context for Applications

I have a serious question.

For a specific enterprise vertical. Would the desktop environment context work better for overall improvement in user experience and user effectiveness. Something that you would see on a graphical desktop environment? A Task Bar that holds the tabs or buttons for the open applications and documents, folders on the desktop will store respective information.

For example, if there is a folder called Mail, I double-click on it, I see all my emails there, as single documents, or maybe if I’ve organized them I use the folder view context. Or maybe a folder called Contacts, which actually displays avatars/profile pictures of my contacts from all subscribed social networks. Or, you know, whatever.

It might not work well for the generic audience, but would it work for a specialized industrial vertical? Could it work?

I know a lot of people who rely on folders and documents to organize and store information. Very few people I know who use single tool/application to organize everything.

In other words, will hiding one layer of interface from the end-user work.

The Desktop Metaphor vs The Application Metaphor

I am deliberately being vague here, but humor me on this.

Real life example:

While looking at various version control systems, I went through two basic experiences. The first was a middle layer application that I had to integrate with my main application. I had to specify check-outs and check-ins, make sure that the file list that the version-controller was showing me was really the latest. It was pretty much straightforward and effective once I got the hang of it. The second presented me with a different user experience, rather the opposite, it offered a user experience that I was familiar with, the folder view. My project documents were stored in a folder, all I had to do was point my document authoring applications to this folder and that was the end of it. To check out a file, I pull up the context menu to get not only the standard options, but also the additional version control options.

The difference in my experience was removing the version control layer of sand-boxing out of my immediate access. The folder was a representation of the project, which was guaranteed by that version control to always let me access the latest versions of the documents. It was less intrusive, so I enjoyed it more. Firstly because it allowed me to stop thinking too hard about which revision of which version of which fork in the project I have to choose, secondly, it allowed to stay inside my learned desktop environment context, i.e. the Folder-document hierarchy.

Democracy’s Missing Business Case

There are overall proponents and opponents to any system of social representation in national governance. I am not getting into that.

Over many years I have come across many arguments, all good ones, in support of voting. I also agree, if you are in a democratic environment, then you should vote to select a candidate for an office.

Here’s my drill-down on the problem as I see it.

  1. There are candidates for an office.
  2. The candidates have an agenda, a manifesto.
  3. They reach out and try to convince the people on why they are the right choice.
  4. On voting day, the people go out to their designated centers and submit a secret ballot. (Yes for their favorite Candidate)
  5. The ballot is counted and the winner declared.

We all know how this works. It’s wonderfully simple, but a nightmare to organize and maintain a high quality of vote.

Generally the voting is structured to allow for selecting one of the given candidates. I strongly believe that there should also be an abstain option (non-of-the-above). This option is a direct reflection on the confidence in the candidates.

Sometime ago in Pakistan, we had our Prime Minister walking into office with a 2/3 majority win. That’s like wow! Never heard of such land-slide wins. What no body bothered to mention that the voter turn out was the lowest ever. The opposition supporters had lost faith in their candidate, though strongly believed in their agenda, so did not show up on voting day.

Putting this in business perspective:

I am a stakeholder in a large organization which has interests across the industrial verticals. It is a huge organization. I am interested in hiring a president and vice president for this company. What I will do is:

  1. Set job description
  2. Set qualifications and pre-requisite experience
  3. Post the job opening on the job sites and set a apply before date
  4. Wait for resumes and filter them, short list them, send out invitations for interviews
  5. Maybe have multiple rounds of interviews and a test or two
  6. Finally, award the job to the “BEST” candidate

In case through this process, I do not feel that I’ve found an appropriate resource, I’ll put out a second round of ad(s) and go through the process till I find someone who is the absolute “BEST” resource for the position.

Now, if this was a daily run-o-the-mill organization, it’s totally understandable, we as stakeholders need to keep an eye on the ROI, profitability, growth of the organization, we’ll go through the due dilligence and detailed analysis of every person, verify the education, past employers, recommendations, achievments and skills.

This brings me to the missing use case in democracy.

Standard Business Case: Select only one of the candidates listed.

This assumes that I have some level of confidence in the capabilities and potential of all the candidates. What happens when I actually do not have that confidence. I feel that all the candidates put forward are actually not up to my expectations and the job’s expectations. What do I do then? Do I check all of them, which I’m not allowed to? Do I leave it blank, this is equivalent to me not showing up? Or do I tell the electorial board that, I came and deliberately am saying that all these candidates are not up to the mark?

So, the candidates will get disqualified for this round of “employment” if no-show-voters + abstain-count > 50% (just pulling a number).

In a situation when 40% of the voting population shows  up, and then the winner claims 2/3 majority, land-slide win. It is incorrect and improper implementation of equal representation.

Windows 7 Addiction

About two and a half months ago I decided to try out Windows 7 Ultimate. I had read about the documents and settings migration from XP, and read about few of the recommendations out there on how to go about installing and what pitfalls to watch out for.

The first thing I did was to download the Windows 7 Compatibility tool from the Microsoft site and ran it. It basically said that my hardware had some issues.

One of the most critical issues I faced was the incompatibility, rather the lack of proper LAN drivers. This had actually blindsided me, and hit me hard. As I had initially been using my machine at a wireless hotspot, my home was also wireless networked at time also, I didn’t miss it. However, I realized the problem when I had to shift to a wired internet access location and was shocked to find that Windows 7 had not recognized my LAN card.

Scrambling to find a wireless hotspot, I immediately went to the Microsoft Update site and ran the update tool. To cut a long story short, after downloading over 700 MB of security patches, system patches, service packs, it also downloaded some of the missing drivers, including the LAN card.

Since then, I have not looked back to Windows XP Professional SP3.

I will definitely say, that Microsoft has really done a great job with this OS. I tried the Vista Ultimate when it had rolled out, but quickly uninstalled it, it really slowed my machine down. Then I had tried the Windows 7 Beta, and I was slightly impressed by it, however, it had some serious problems with my machine.

However, I believe that I have made a good choice, with a serious drawback. To understand that, I need to put down the specs of my machine. Please bear with me, the machine has a shipping date of June 2002. Wow! ancient innit.

Well here goes

Manufacturer Dell Inc.
Type Laptop
Model Inspiron 8200
Processor PIVm 2.2GHz
RAM 2GB PC2700
Graphics Nvidia GeForce2 Go 32MB
HDD 100 GB 5400RPM ATA
Screen 15.4″ SXGA+ (1400×1050)
LAN 3Com 3C920 (3C905C-TX Compatible) 100Mbps
Wireless Intel PRO/Wireless 2200BG
Modem Conexant SmartHSFi V.9x 56K DF PCI Modem
DVD/CD-ROM Toshiba CDRW/DVD SDR2102 ATA
Pointing Alps Touchpad

Straight off there were driver issues, however, I forced installed the XP drivers I had, and let windows update them from it’s own web site.

What I am not able to use is the Aero theme. I have seen it and used it on my friends machines, however, I am rather more comfortable with the Windows 7 basic theme.

I tweaked the UI, reduced icon sizes adjusted how the windows explorer should show files, set the blank screensaver (becuase I like that), and got down to business.

Now that I have rearmed the trial twice already, I am dreading the time when this third perid will end, which it is about to. What will I do then? Will I go out and beg/steal for cash to get the genuine license and active it? or … will I revert back to the XP I had and had gotten used to.

My XP rocked. Of course I had so many years to learn it, figure out it’s nuances and eccentricities and limitations and capabilities. In the end the only UI tweak I had done on it was to install the Zune theme for XP, the first thing I had done was thrown away the wallpaper. I like clean wall papers generally.

Now.. If I do go back to XP I will miss the following things that I have gotten accustomed to with Windows 7.

  1. Elegant failure recovery while operating.
  2. Elegant failure recovery while shutting down.
  3. Access/Authorization controls, asking me for administrative authentication before system level or security change.
  4. Improved Task Manager.
  5. Elegant Start bar design.
  6. Excellent Mouse over selection and control of multiple documents from running application on task bar.
  7. Better calendar (click on clock on status bar).
  8. Recently used Programs list and recent documents/activities against progams.
  9. Document Libraries.
  10. Other Libraries.
  11. Network/Network Connection management.
  12. Much better indexing.
  13. Integrated real-time search.

And … I’m sure there are many many more that I’m missing, and won’t realize till I get back to XP. So sad, but it’s bound to happen sooner or later.

Now, what is prompting me to switch back, well, lets just say I had the cash on me to be able to afford a proper license. Basically, this machine is probably classified as a legacy machine, however, I’m still using it.

For my family, specifically my two kids and myself, Friday nights are movie nights, as my wife works from home, I show them movies on my machine. When I was using XP, I used to play the movies with VLC Player, tried a lot of them, however, kinda clicked with this one. Everything was dandy until, I switched to Windows 7.

With the different graphics engine, not supported by my hardware, plus the limit of supporting DirectX 9c, I ran into a serious graphics performance issue while playing movies in full screen.

Luckily I have another HDD (80GB ATA) with Ubuntu on it, and it works perfectly on my machine. Of course some of the snazzy UI effects won’t work, OpenGL is a bit hiccupy due to the oldnesses and capabilities of my graphics card. So come Friday, I first switch hard drives before showing kids any movie. It’s a small over head at this time.

That got me thinking, what will I go through when I actually do switch back to XP, which prompted me to write down my thoughts.

I have also published another post regarding my thoughts on the Windows 7 graphics engine, and how it affects me, and perhaps other users also.

Anyway, I am almost dreading the day when I switch back.

I think the withdrawl will be bad! Dang, I need my Windows 7 fix!

Cheers.

Windows 7 Graphics Engine

I own a Dell Inspiron 8200 (Intel P4m 2.2GHz + 2GB RAM) with a Nvidia Geforce 2Go 32MB RAM and am currently evaluating Windows 7 Ultimate (trial). I have been an XP user since the begining. Being an IT professional, and an avid tinkerer since the begining. I personally feel, and I’m sure there are a lot of people out there with similar feelings, that Microsoft is leaving us behind.

Hey, I’ll be the first one to promote advancements in hardware architecture, microprocessor manufacturing and software. And I also understand that for organizations it is difficult to maintain legacy or old hardware as it adds an additional cost to the product, also it becomes a technical nightmare to manage and maintain and provide support to the customer base.

Microsoft either made a huge blunder with Vista or it was a fire test, a market study so to speak. They guaged the user response to a radical change in the operating system. They needed to do that to do three things, 1) to test their new graphics engine and the radically changed user interface, and 2) to see what percentage of users would actually switch, and 3) to technically evaluate the operating system to look at what problems the general user is facing.

Some might say it was an expensive exercise.

The company needed to push the new technology out to the market, however, by pushing it out now, like they did, they have put a lot of people in a very difficult position to make a choice, not only upgrade the operating system, but also, upgrade their hardware.

It is easier for a user to upgrade software, however, hardware is another issue.

I live in a developing country with a much weaker economy than the US. This translates to a much lower buying power, which means, I am borderline between switching over to Linux. However, my work always has kept me on the Microsoft of things.

If I were involved in the architecture stage of Vista and 7 this is how I would have gone about this.

  1. 1. Draw a line on what minimum legacy hardware will be supported.
  2. To not alienate the customer base who do not want to or cannot affor to upgrade graphics, an option will be provided
  3. This option will provided limitations to the Windows 7 user interface.

Legacy Graphics Support

At the architecture level, I will design the graphics modules in such a way that, it may be switched between legacy support and contemporary support. Afterall, according to my knowledge Windows is a micro-kernel architecture, so this should not be that technically difficult. It is a matter of how the graphics engine will be supported. Allow for new architecture, and build a wrapper for legacy architecture for limited support. This should allow the XP graphics drivers to run natively, and not be forced onto the DirectX 10/11. Simply put, My graphics card supports DirectX 9 and XP supports up to 9c. So when I install on my machine, Windows 7 asks me if I want legacy graphics support, explaining the difference in terms of DirectX support. If the user says “Yes” then Windows 7 does not install the DirectX 11, but installs the older graphics engine to allow for XP drivers. Otherwise, it does what it does now.

The reason I am thinking on these lines is because, I at one time tried the Vista Transformation Pack, and then later on also tried the Windows 7 Transformation Pack. the amazing thing was that both producs changed my XP interface to include a lot of user interface goodies that Vista and Windows 7 had introduced, including the alpha blended borders, the fancy 3D Alt-Tab alternative, the task bar application previews. Almost all were there. Of course these two products didn’t change the fact that I was using Windows XP. Which basically convinced me that the fancy user interface can be supported on my 8 year old machine.

Now with the support option for Legacy graphics, I feel that Microsoft can put in a disclaimer, say, sure, we’ll give you legacy graphics support, but we’ll disable the aero theme. I will be the first one to switch. Simply because, I would be able to watch movies which I like doing sometimes with my kids, do some graphics intensive work, maybe play NFS Hot pursuit for 10/15 minutes. I would like to do that without spending two to three months worth of pay on a new machine.

Right now, Windows 7 supports my hardware pretty well, by that I mean, I get enough response from a fully loaded and configured system to run SQL Server, and develop computationally intensive desktop and web applications using .NET Framework 2 and 3.x. Of course I don’t get Aero, and personally I kind of prefer the basic theme over Aero. Aero makes the windows borders quite busy for my liking. — While using XP I was using the Zune theme, prefered it over the default Luna with it’s three age old variations.

I do like to watch movies with my kids every Friday, it has become an important ritual that we do every week. With Windows 7, I can’t do that, however, I have a Ubuntu installed hard drive stashed away, and on Fridays I have to put in another 5 minutes to switch hard drives. It’s just an inconvienence, that my kids enjoy also (they are 5 and 7 years old).

Return to the Blog

Ah .. Long time no blog. 🙂 IT’s been quite a while since I posted anything.

I guess right now is a as good a time as it gets.

Auto Populate Time Stamp in SQL Server 2005 Express

Recently I was experimenting with trying to modify a database by adding an auto-populating Time Stamp Column to each table in the database.
Like any reasonable person I decided to test the different techniques on a simplified test database which I keep for experimentations like these.
The thinking I was following was:
Add another column to the table, define it as a TimeStamp type, define it to auto-populate with the current TimeStamp.
So I went ahead and launched the Microsoft SQL Server Management Studio Express and created the following table.
USE [TestDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TstAutoPopulatedTimeStamp](
[PID] [int] IDENTITY(1,1) NOT NULL,
[SomeText] [varchar](50) NOT NULL,
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
This will create a table with two columns, PID and SomeText.
Then I populate this with some random data.
Insert into TstAutoPopulatedTimeStamp values (‘Hello There 001’)
Insert into TstAutoPopulatedTimeStamp values (‘Hello There 002’)
Insert into TstAutoPopulatedTimeStamp values (‘Hello There 003’)
Then I added another column called “Created” and decided on the Timestamp data type. Now I ran into a problem. I could not define a Default Value or Binding for this column. I then decided to define a Computed Column Specification based on a function. I used (getdate()) for this. I saved the table and ran a simple SELECT on the table.
select * from TstAutoPopulatedTimeStamp
Which gave me the following result.
PID SomeText Created
1 Hello There 001 2009-06-05 13:26:31.270
2 Hello There 002 2009-06-05 13:26:31.270
3 Hello There 003 2009-06-05 13:26:31.270
Which to me was really odd. Then I thought, well because I has defined this new column as not-nullable, on saving the table, SQL Server Express decided to fill this column with the time it was created (table was saved).
Now came the fire test, INSERT another record.
Insert into TstAutoPopulatedTimeStamp values (‘Hello There 004’)
PID SomeText Created
1 Hello There 001 2009-06-05 13:30:49.553
2 Hello There 002 2009-06-05 13:30:49.553
3 Hello There 003 2009-06-05 13:30:49.553
4 Hello There 004 2009-06-05 13:30:49.553
What I was expecting was that the latest record would have a new date-time while keeping the old Timestamp unchanged. So this result was really strange. I went back to the drawing board, Looked at what I might have missed.
Examining the table in the design view, I found something odd, the Data Type for the Created column was undefined. I thought, perhaps because this is a column defined through Computed Column Specification, SQL Server does not allow me to explicitly define it’s value.
I noticed something else, I could also persist the data when I define through Computed Column Specification. I decided to do that. I set Is Persist as Yes and saved. To my surprise, SQL Server instead of saving the table definition, it reported the following error.
‘TstAutoPopulatedTimeStamp’ table
– Unable to modify table.
Computed column ‘Created’ in table ‘Tmp_TstAutoPopulatedTimeStamp’ cannot be persisted because the column is non-deterministic.
Basically, what SQL Server was telling me that, I cannot make a column with Computed Column Specification persist data if the Data Type is not specified, i.e. non-deterministic.
This left me scratching my head. Ok, this didn’t work.
I changed my approach and removed the Computed Column Specification for the Created column. Defined the Data Type as datetime and set the Default Value or Binding to (getdate()). On saving the table, I didn’t get any error.
Going back, I ran another insert query like the one I am using so far. I got the following error.
Msg 213, Level 16, State 1, Line 1
Insert Error: Column name or number of supplied values does not match table definition.
I modified the Insert and ran the following SQL Script.
Insert into TstAutoPopulatedTimeStamp (SomeText) values (‘Hello There 005’)
select * from TstAutoPopulatedTimeStamp
Which gave me the result below:
PID SomeText Created
1 Hello There 001 2009-06-05 13:30:49.553
2 Hello There 002 2009-06-05 13:30:49.553
3 Hello There 003 2009-06-05 13:30:49.553
4 Hello There 004 2009-06-05 13:30:49.553
5 Hello There 005 2009-06-05 13:55:45.823
Now it was working as I wanted it to work. However, This required me to look at every query in the application to see if the queries were in this form or the other form. And, how much work I would need to do on it. Before starting off, I wanted to also check the UPDATE query.
Update TstAutoPopulatedTimeStamp set SomeText = ‘Updated Data’ where PID = 1
select * from TstAutoPopulatedTimeStamp order by created asc
I expected the records to be ordered with the Created column in ascending order. Here I ran into a problem that I was in a way expecting. The Created column against the said record did not change. It remained where it was.
PID SomeText Created
1 Updated Data 2009-06-05 13:30:49.553
2 Hello There 002 2009-06-05 13:30:49.553
3 Hello There 003 2009-06-05 13:30:49.553
4 Hello There 004 2009-06-05 13:30:49.553
5 Hello There 005 2009-06-05 13:55:45.823
This meant that I would have to manually change all the UPDATE queries in the application to include the setting of the Created column.
This meant changes in the data layer of an application running at the client side.
Bummer.
This meant that I would have to got onto using Triggers 🙂 Not that I mind. That perhaps will be a better solution to this problem.
It would have been cool if I could do this by just setting one or two values in the table’s definition.

Recently I was experimenting with trying to modify a database by adding an auto-populating Time Stamp Column to each table in the database.

Like any reasonable person I decided to test the different techniques on a simplified test database which I keep for experimentations like these.

The thinking I was following was:

If I add another column to the table, define it as a TimeStamp type, define it to auto-populate with the current TimeStamp.

So I went ahead and launched the Microsoft SQL Server Management Studio Express and created the following table.

USE [TestDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TstAutoPopulatedTimeStamp](
[PID] [int] IDENTITY(1,1) NOT NULL,
[SomeText] [varchar](50) NOT NULL,
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF

This will create a table with two columns, PID and SomeText.

Then I populate this with some random data.

Insert into TstAutoPopulatedTimeStamp values ('Hello There 001')
Insert into TstAutoPopulatedTimeStamp values ('Hello There 002')
Insert into TstAutoPopulatedTimeStamp values ('Hello There 003')

Then I added another column called “Created” and decided on the Timestamp data type. Now I ran into a problem. I could not define a Default Value or Binding for this column. I then decided to define a Computed Column Specification based on a function. I used (getdate()) for this. I saved the table and ran a simple SELECT on the table.

select * from TstAutoPopulatedTimeStamp

Which gave me the following result.

PID	SomeText	Created
1	Hello There 001	2009-06-05 13:26:31.270
2	Hello There 002	2009-06-05 13:26:31.270
3	Hello There 003	2009-06-05 13:26:31.270

Which to me was really odd. Then I thought, well because I has defined this new column as not-nullable, on saving the table, SQL Server Express decided to fill this column with the time it was created (table was saved).

Now came the fire test, INSERT another record.

Insert into TstAutoPopulatedTimeStamp values ('Hello There 004')
PID	SomeText	Created
1	Hello There 001	2009-06-05 13:30:49.553
2	Hello There 002	2009-06-05 13:30:49.553
3	Hello There 003	2009-06-05 13:30:49.553
4	Hello There 004	2009-06-05 13:30:49.553

What I was expecting was that the latest record would have a new date-time while keeping the old Timestamp unchanged. So this result was really strange. I went back to the drawing board, Looked at what I might have missed.

Examining the table in the design view, I found something odd, the Data Type for the Created column was undefined. I thought, perhaps because this is a column defined through Computed Column Specification, SQL Server does not allow me to explicitly define it’s value.

I noticed something else, I could also persist the data when I define through Computed Column Specification. I decided to do that. I set Is Persist as Yes and saved. To my surprise, SQL Server instead of saving the table definition, it reported the following error.

'TstAutoPopulatedTimeStamp' table
- Unable to modify table.
Computed column 'Created' in table 'Tmp_TstAutoPopulatedTimeStamp' cannot be persisted because the column is 
non-deterministic.

Basically, what SQL Server was telling me that, I cannot make a column with Computed Column Specification persist data if the Data Type is not specified, i.e. non-deterministic.

This left me scratching my head. Ok, this didn’t work.

I changed my approach and removed the Computed Column Specification for the Created column. Defined the Data Type as datetime and set the Default Value or Binding to (getdate()). On saving the table, I didn’t get any error.

Going back, I ran another insert query like the one I am using so far. I got the following error.

Msg 213, Level 16, State 1, Line 1
Insert Error: Column name or number of supplied values does not match table definition.

I modified the Insert and ran the following SQL Script.

Insert into TstAutoPopulatedTimeStamp (SomeText) values ('Hello There 005')
select * from TstAutoPopulatedTimeStamp

Which gave me the result below:

PID	SomeText	Created
1	Hello There 001	2009-06-05 13:30:49.553
2	Hello There 002	2009-06-05 13:30:49.553
3	Hello There 003	2009-06-05 13:30:49.553
4	Hello There 004	2009-06-05 13:30:49.553
5	Hello There 005	2009-06-05 13:55:45.823

Now it was working as I wanted it to work. However, This required me to look at every query in the application to see if the queries were in this form or the other form. And, how much work I would need to do on it. Before starting off, I wanted to also check the UPDATE query.

Update TstAutoPopulatedTimeStamp set SomeText = 'Updated Data' where PID = 1
select * from TstAutoPopulatedTimeStamp order by created asc

I expected the records to be ordered with the Created column in ascending order. Here I ran into a problem that I was in a way expecting. The Created column against the said record did not change. It remained where it was.

PID	SomeText	Created
1	Updated Data	2009-06-05 13:30:49.553
2	Hello There 002	2009-06-05 13:30:49.553
3	Hello There 003	2009-06-05 13:30:49.553
4	Hello There 004	2009-06-05 13:30:49.553
5	Hello There 005	2009-06-05 13:55:45.823

This meant that I would have to manually change all the UPDATE queries in the application to include the setting of the Created column.

This meant changes in the data layer of an application running at the client side.

Bummer.

This meant that I would have to got onto using Triggers 🙂 Not that I mind. That perhaps will be a better solution to this problem.

It would have been cool if I could do this by just setting one or two values in the table’s definition.

My Political Inclination

Came across The Political Compass web site while searching for politics related information. Got side tracked and took their test. I have no idea how accurate this is. However it was thought provoking set of questions spread over 6 pages.

They have divided the political inclination into LEFT/RIGHT and Authoritarian/Social Libertarian. Giving a quantitative analysis based on the answers given during the short test.

Here are the two images with known personalities and how they fall on the political space.

According to their test, apparently I am a Left-Left-Libertarian. I wonder what that actually means.

 

-5.88 Left/Right Axis and -2.21 on Libertarian/Authoritarian Axis

-5.88 Left/Right Axis and -2.21 on Libertarian/Authoritarian Axis

This is interesting. I fall in the same quadrant as Ghandi, Nelson Mandela and Dalai Lama

Algorithm and Code

What came first, the algorithm or the code?

To the modern day developers, there may or may not be a clear distinction between algorithm development and coding (as it is sometimes lovingly coined).

For me personally, the algorithm always comes first. It is the attempt to define in non-ambiguous terms what exactly needs to be done and in what order for achieving the desired result. Once I am satisfied with the algorithm, I then start to code it. There have been instances where I have had to revisit the algorithm and change it when problems have surfaced while coding or testing.

Afterall, I am only one person, and because of that, at times I can suffer ther classic mistake of miscalculation, bad assumption or plain oversight.

Once a person has designed a concrete algorithm, it can be implemented in almost any language. For me the two are to a great extent mutually exclusive. I know there might be a great number of softwere developers/engineers out there who will object. But I would like to clarify one thing.

Algorithm is independant of data types and language references. Why? Simply because, all problems have three aspects:

  1. Some logical action
  2. Some Decision making
  3. Some Mathematical action

These three actions are independant of the language of implementation. The choice of language will have it’s own representation of how to perform these three activities.

If one develops an algorithm for fast searching of numbers, e.g. The infamous and incredibally popular Binary Search, and descibes it in English. It would look like.

  1. Define Problem Statement:
    Find matching number in a list of ordered numbers.
  2. Assumption:
    List of ordered numbers is available.
  3. Algorithm:
    1. Pick the middle number from the list.
    2. Compare with number to find.
    3. If number to find is smaller than the middle number, then number may exist in list with numbers smaller than middle number (Step 1).
      1. Use smaller number list to search number in.
      2. Go to Step 1.
    4. If number to find is larger than the middle number, then number may exist in list with numbers larger than middle number (Step 1).
      1. Use larger number list to search number in.
      2. Go to Step 1.
    5. If number matches the middle number, then no need to search more.

Now we are ready to implement this algorithm. There are a number of things we need to conisder first.

  1. How big is our list likely to get? 
    How large will our list be, 100, 1000, 100000 
  2. What type of numbers will we be comparing? 
    32 Bit Integer, 64 Bit Integer, Fractional Values 
  3. What limitations do we have from hardware?
    Memory Limitations, Address Space, etc. 
  4. What limitations do we have from the compiler/interpreter?
    Code Optimization, Interpreter memory space (e.g. browser)
  5. Any other limitations?

I do understand that some limitations or restrictions may not be valid. In which case, you have one less thing to cater for.

Then we check conditions when this system may fail.

  1. What happens when list has zero numbers.
  2. What happens when list size approaches the maximum number we use to address list?
  3. What happens when the list population does not have number that we are looking for?
  4. What happens when the number we are looking lies between two numbers that are in contiguous spaces in the list.
    e.g. we looking for 5, but list is 1,2,3,4,6,7,8,9
  5. Any other way the implementation may fail.

Now we are ready to implement the algorithm.

Algorithms are not limited to technology, they are independant of it. They are related to solving problems. If a problem has been well throught through, the solution algorithm will not have any failings. A Verbatim translation of an algorithm will be guaranteed to fail at some point or the other, because it will not have catered to run time scenarios based on limitations of the implementation environment.

The algorithm is bad if it fails to solve the problem. The code is not to be blamed for algorithm failure. However, if algorithm has been checked and double checked, and the solution fails, then it’s a problem with the code not the algorithm.

We are a Bad People

A few days ago I was talking to a gentleman about the local situation in Pakistan. With all the different factions/parties/independents trying to leverage any event to their own advantage. 

We talked about the economic situation, the political situation, the Talibans and Mullahs (please not I am not using the term Aalim), the under-the-table feudalism, the corruption. We ended up covering almost everything. It was depressing and entertaining, it almost feels like a Shakespearean tragedy/comedy.

We both agree that there is major truth to the phrase “you are judged by the company you keep”. As an individual that is true to a great extent, however, at times there are circumstances when this may not be true. I thought of another phrase at that time.

A people are judged by their rulers.

This is true, to a certain extent, as the rulers become the ambassadors of the nation, and represent the culture, thoughts, ideology of the people of that nation. Therefore, this being a self proclaimed democratic nation, implies that our rulers have been picked by the people. Therefore, the people have the same self defeatist attitude, mentality, and emotional instability that these leaders posses.

Hey, I’m not naming names here, but, let the guilty defend themselves. 😉

Coming back to my conversation with the gentleman, he recalled and quoted what another associate of his had commented on the state of the nation that is Pakistan.

… I was having a conversation with Mr. Smith, and he said shaking his head, “We are a bad people”…

Having said that, I do not think that we, Pakistanis are a bad lot at all. There is a large proportion of the nation who are actually good people in the real sense of the word. However, the political, social, economic, educational and other cultural forces in play have marginalized these people below the poverty line, where they are stuck in a situation from which they can’t seem to get out of. 

All you Pakistani people out there. We are not thieves, liars, drug and gun trafficers, nor are terrorists, extremists, or any other form of nut cases. We are sane people, we think rationally, we are aware of our surroundings, economy, politics. Even the illiterate amongst us is educated enough to understand the difference between right and wrong, good and bad, progress and self destruction. We can make the difference. We, the small minority, can make a difference.

There is one condition though. Sacrifices will need to be made. We will have to put the nation before our families and our families before us. We have to understand that we all are here to serve the nation for which train-loads of people lost their lives.

A person who through inaction allows bad things to happen, is worse than the person who does bad things.

Another interesting thing I learnt through conversations with someone who had met Qaid’e’Azam Muhammad Ali Jinnah, was shocking to say the least. Related to our motto, the original motto is:

Unity, Discipline, Faith

It was changed to what it is now to satisfy the “Mullah” people’s argument that this is an Islamic nation, and faith have to come before discipline. I have one thing to say to these people. Take a break, relax. This is too small a thing to argue over. The thing we should focus on is that all three aspects are equally important.

  1. Cannot Unite a people who are undiciplined.
  2. Cannot Discipline a people who do not have some form of faith.
  3. Cannot have Faith without being diciplined and united.

Well that’s my rant for today, hope it was entertaining, and if I happened to offend someone, then I have proved my point.