Thursday, June 29, 2006

Re-writing and copying HTML files with Ruby Refactoring

I submitted a previous post on re-writing and copying HTML files with Ruby. I could not let that rather large and unruly script go as is and had to refactor, a.k.a. extract, much of the script code out into a ruby class.

Here are the goodies.

Wednesday, June 28, 2006

Php 4 Quick and Dirty Model and View Separation Example

I was coding a site in Php and needed to display announcements and needed a quick and simple way to do this. Moreover, I wanted to keep the design in the good ole MVC pattern.

See how I, at least somewhat, did this here.

Monday, June 26, 2006

Re-writing and copying HTML files with Ruby

A personal goal of mine is to read through the Bible this year on a daily basis. To assist me in this I have an HTML file for each month of the year with links that call a JavaScript function passing the text-section value and then putting the value into a URL QueryString and opening a new window with the loaded URL. This worked OK but because the JavaScript opens a new window, the daily links were not showing with the visited style that I set in the CSS file. Here is where Ruby came in.

I thought about just rewriting the HTML but having to create 12 separate files, one for each month, was not what I wanted to do. Why not, as I am learning to use Ruby, use it to parse the existing HTML into a new file, a txt file in this case and then run script to rename the new into the old files, with links that use the traditional target attribute to open a new browser.

Click here to see what I did to parse the existing HTML files into TXT files.

Click here to see the copy of the TXT into HTML files.

Saturday, June 10, 2006

What are we thinking?

Okay. So now you have inherited someone else’s code. You typically review the automated tests (if any), available documentation (if any), and then the code itself. It is here that at lease one person in each development group will say, “What were they thinking? This code sucks.” It is at this point that I cringe. Yes, the code may not be the most elegant. But to just simply state, in your self-proclaimed superiority, that the previous programmers were stupid is both unprofessional and short sighted. Don’t misunderstand me. I am not saying that in the name of being nice to overlook and tolerate crappy code. My point here is that there is more than initially meets the eye.

What got me thinking about this was an article that I ran across by Dave Hunt and Andy Thomas entitled, Software Archaeology. In it the authors state:

Archaeologists generally don’t make wisecracks about how stupid a particular culture was (even if they did throw dead bodies into the only good drinking well). In our industry, we generally don’t show such restraint.


As stated above, it has been my experience that in the software development field, we are too quick to criticize. They then go on to write:

But it’s important when reading code to realize that apparently bone-headed decisions that appear to be straight out of a "Dilbert" cartoon seemed perfectly reasonable to the developers at the time. Understanding "what they were thinking" is critical to understanding how and why they wrote the code the way they did. If you discover they misunderstood something, you’ll likely find that mistake in more than one place. But rather than simply "flipping the bozo bit" on the original authors, try to evaluate their strengths as well as weaknesses. You might find lost treasure—buried domain expertise that’s been forgotten.


Therefore instead of just asking, "What were they thinking?” we need to consider “What and how are we thinking?" to get the most out of the code that we sometimes unearth and/or must excavate.

Sunday, May 21, 2006

Ego is not your friend

I was listening to Scott Hanselman's podcast called HanselMinutes and noted a statement from the host of the show Carl Franklin, "Ego is not your friend." The context was that as a developer, your ego, if too sensitive or too large, can keep you from learning from the developer community. The ego typically prohibits you from being honest and saying, "I do not understand or know what you are talking about, please explain." This prohibition is manifested in your feeling ashamed to state that you do not know what is presently being discussed or you want to appear that you know more about the topic than you actually do.

It has been my experience that my ego, if not monitored, can cause me to view my present lack of understanding in an incorrect way. The reality is not that I lack the ability to understand the information, but rather I lack exposure to the information. From that aspect, I am now informed about what I need to learn. Moreover, if I do understand a topic better than someone else, this does not mean that my level of intelligence is greater. It simply means that I have been made aware of the topic and have taken the time to learn. Otherwise, my ego could falsely cause me to think that I am more adept than I am in reality and cause me to not consider various aspects of a topic, since I think I understand more than I do in reality.

In summary, either by causing one to think they can not improve or that they have no need to better their understanding, ego is not your friend.

Thursday, April 13, 2006

msquaredweb.com now on linux

For those who care, I took the plunge and am now hosting on linux. This is in preparation to eventually move the site to Rails.

I will still have sites on asp.net just to keep my .Net skills current, but since I have moved to the J2EE team at my real job, I thought it best to make this move with msquaredweb.com.

Wednesday, March 15, 2006

Installing Ruby on Windows XP Pro

In my readings on Ruby I have yet to run across a step-by-step example of how to install it on Windows XP Pro. Anyway, since I bought a new laptop, I decided to record the steps in the installation of Ruby 1.82-15.

Here are the steps.

Tuesday, February 21, 2006

Truthiness?? Alrighty then!

In a blog from Brian Marick I saw this: The American Dialect Society voted "truthiness" the 2005 word of the year. It "refers to the quality of preferring concepts or facts one wishes to be true, rather than concepts or facts known to be true." On a private level that may be well and good. However, the older I get the more that I am aware that “no man is an island.” In other words, in some small way we affect on another.

Therefore, if you are my family doctor, don’t use that in your medical practice. If you are my employer, do not use “truthiness” when you calculate my pay. If you are a civil engineer, do not go about “preferring concepts or facts one wishes to be true” when engineering the bridges I drive over.

Brian goes on to show that in the development of code, more tests are the answer to “preferring concepts or facts one wishes to be true, rather than concepts or facts known to be true”, not ignoring the facts.

And yes, when designing software, more tests please, and less "truthiness."

Thursday, February 16, 2006

The Scandal of Prediction (a.k.a We think we're purty smart)

Just listened to an interesting program on IT Conversations dealing with the problems of predictability and why the various models and systems of predictors fail by Nassim Nicholas Taleb entitled, The Scandal of Prediction.

What I gathered from the program is that the overall problem with accuracy in predictions and forecasting is systemic arrogance. We fail to acknowledge what we do not know and inflate the little we do know. We should not stop attempting to utilize our forecast models and systems , but let us do it with an honest look at the vast amount of knowledge we are yet to discover.

An interesting note is that Taleb refers to the concept of Yesterdays Weather with which agile developers should be familiar. Simply put, this concept is based on the understanding that there is a 70% chance that today’s weather patterns will be a repeat of yesterdays. Statistically, we know this but still we employ vast machinery to "predict" what the weather will be like in the future. Admittedly, there is more value in the use of models and formulas the further out one attempts to predict. In any event, I humbly predict (without any meteorological training or know how) a 70% chance that tomorrows weather is like today’s.

Tuesday, January 10, 2006

Learning Ruby

The Cincinnati Extreme Programmer’s Group January meeting was treated to a presentation by Jim Weirich, a consultant for Compuware, about Ruby On Rails. I could not make the meeting but watched a recorded video of the presentation and reviewed Jim’s blog concerning the meeting. As I was perusing Jim's blog I came across his link on a talk that he will be giving at the upcoming Dayton-Cincinnati Code Camp entitled, "10 Things Every Java Programmer Should Know About Ruby."

I must say that Ruby looks intriguing. In fact, I have registered for the Dayton-Cincinnati Code Camp and am looking forward to Jim's talk. Moreover, I ordered the Agile Web Development with Rails: A Pragmatic Guide book. I can not wait to dig in!!

Thursday, January 05, 2006

Output Parameters from C# Method

I know that this is “old hat” to many but I am working on an application where I needed a method to return two separate values. I turned to good ole output parameters. I know I could have created two separate methods but the values within the problem domain are always associated. Therefore, it made sense to me to use output parameters with one method.

Here is an example using a NUnit test and the method returning two values via output parameters.

[Test]
public void TestParseAndReturnTwoSeperateStrings()
{
string toParse = "00050000999";
string strOne;
string strTwo;

ParseAndReturnTwoSeperateStrings (toParse, out strOne, out strTwo);

Console.WriteLine("String 1: {0}", strOne);
Console.WriteLine("String 2: {0}", strTwo);

Assert.AreEqual("000", strOne);
Assert.AreEqual("50000999", strTwo);
}

private void ParseAndReturnTwoSeperateStrings (string input,
out string strOne, out string strTwo)
{
strOne = input.Substring(0, 3);
strTwo = input.Substring(3, input.Length - 3);
}

Saturday, December 17, 2005

NUnit 2.2.4 Released!!

Just got an e-mail within the Test Driven Development Yahoo Group from Charlie Poole concerning the release of NUnit 2.2.4:
If you haven't followed the development releases, here are a few highlights of what's new, as compared to NUnit 2.2:

* NUnit 2.2.4 runs under .Net 2.0 and works with VS2005. If you work exclusively with .Net 2.0, you can download a version that is actually built with that framework version, which eliminates dealing with the config file.

* You can run tests built against older versions - 2.0 or later - of NUnit without recompiling. As a bonus, you can run tests built against CSUnit without recompiling.

* A number of new Asserts and Attributes have been added. It is now much easier to create your own custom Asserts while still taking advantage of NUnit's built-in error message formatting.

* An extensibility mechanism allows you to define your own attributes for test fixtures and cases that behave in non-standard ways. [This feature is Still a bit experimental, and will appear in final form in the 2.4 release.

* Documentation is substantially improved and is provided as a set of html files. The packaged documentation includes only version-specific details, with info that may change over time, such as contacts, kept on the web site.

You can read the full release notes at http://nunit.com/testweb/index.php?p=releaseNotes&r=2.2.4. Note that the nunit.org site has not yet been updated to reflect this release.

You can download NUnit 2.2.4 at http://sourceforge.net/project/showfiles.php?group_id=10749

Friday, November 25, 2005

A thought experiment, just for fun

I typically, for a brief dose of humor, will go to the Dilbert site some point in my day. As I browsed to the daily comic strip I noted a link to Scott Adam’s free e-book entitled God’s Debris. Here is a part of the introduction:

The central character in God’s Debris knows everything. Literally everything. This presented a challenge to me as a writer. When you consider all of the things that can be known, I don’t know much. My solution was to create smart-sounding answers using the skeptic’s creed:

The simplest explanation is usually right.

My experience tells me that in this complicated world the simplest explanation is usually dead wrong. But I’ve noticed that the simplest explanation usually sounds right and is far more convincing than any complicated explanation could hope to be. That’s good enough for my purposes here.

The simplest-explanation approach turned out to be more provocative than I expected. The simplest explanations for the Big Questions ended up connecting paths that don’t normally get connected. The description of reality in God’s Debris isn’t true, as far as I know, but it’s oddly compelling. Therein lies the thought experiment:

Try to figure out what’s wrong with the simplest explanations.

What I found interesting is that, at least, sounds very much like the "simple design principle" that is advocated, correctly in my view, by the Agile Extreme Programming methodology.

In addition to this, I also found of interest related to software development was a discussion of pattern recognition and usage. In the chapter, Science, the central character states:
Computers and rocket ships are examples of inventions, not of understanding," he said. "All that is needed to build machines is the knowledge that when one thing happens, another thing happens as a result. It’s an accumulation of simple patterns. A dog can learn patterns. There is no 'why' in those examples. We don’t understand why electricity travels. We don’t know why light travels at a constant speed forever. All we can do is observe and record patterns." (P. 22)
In any event, instead of getting my daily fix of humor I got much more, a jolt to my thinking about fundamental questions. That, in my possibly warped view of entertainment, is for more enjoyable. Moreover, perhaps the joke is on me since I do not know nearly as much as I foolishly thought.

Thursday, November 17, 2005

Agile Amigo?

Ivar Jacobson, one of the founders of UML, pledged to support Microsoft Visual Studio 2005 Team System with the goal of a more agile approach to design and modeling.

Check this potential Agile Amigo out here. This will be interesting to follow.

Tuesday, November 15, 2005

Microsoft released guidelines for converting ASP.Net 2002/2003 projects to Visual Studio.Net 2005

Microsoft released guidelines for converting ASP.Net2002/2003 projects to Visual Studio.Net 2005 at Step-By-Step Guide to Converting Web Projects fromVisual Studio .NET 2002/2003 to Visual Studio 2005.

The article states:

The primary benefit of converting a Web application project to Visual Studio 2005 is the ability to use many new features in ASP.NET 2.0 (e.g., master pages,etc.) in your existing application. If you are looking to enhance an existing Web application built using Visual Studio .NET 2003, then upgrading to Visual Studio 2005 is most likely the right decision.
As expected, simple projects will be easier to convert:
For relatively simple Web projects where a Webproject is the only project in your Visual Studio .NET 2003 solution, conversion should be a relatively automatic process requiring little time or problem resolution.

However, not all ASP.Net 2002/2003 project conversions will be easy:
If the application you are converting is of reasonable size and has several Web projects and additional projects, such as class libraries, in a single Visual Studio solution, it is possible to encounter issues during migration. Be prepared to spend the better part of a day completing the entire process. The steps and guidance provided in this article can help an informed user to migrate most applications of medium complexity.

Thank you Web Platform and Tools Team for your honest assessment. I must admit that I am very skeptical when someone says, "it’s really pretty straight forward." Yea....right. In any event, I am looking forward to moving some of my small-sized projects to VS 2005.

Monday, November 14, 2005

Webservice Account Permissions "Gotcha"

For a project, an internal customer wanted to utilize web services for file reading and writing. Both the file write and read services were utilizing a System.IO.FileStream object, invoking the object's Read and Write methods. Since the location that the web services would be reading and writing from is a network share, two domain accounts were setup and given read, and you guessed it, write permissions each respectively to the share.

The “gotcha” that we encountered was that the accounts that the web services were utilizing needed modify permissions on the server <WindowsFolder>/temp folder in order to generate serialization proxies.

Click here to see what was done to remedy the issue.

Monday, November 07, 2005

It's in the wild!!

SQL Server 2005, Visual Studio 2005 with .Net 2.0 and BizTalk Server 2006 had their official launch today.

Also, DotNetNuke, an Open Source Web Application Framework, is releasing its 3.2 framework, built on the 1.1 .Net, and its 4.0 framework, built on .Net 2.0.

I can see that I am not going to get much sleep.

Friday, November 04, 2005

New from Yahoo! and still in beta - Instant Search

New from Yahoo! and still in beta - Instant Search where results instantly appear for Yahoo! Shortcuts and common searches.

Thursday, November 03, 2005

Covariance and Delegates in .Net 2

Click here to view this little nugget in .Net 2 dealing with covariance, an object-oriented principle, and delegates.

Very nice code re-use construct!