Saturday, January 27, 2007

I' m Learning Design Patterns

I received a great book from my girl friend this Christmas called Head First Design Patterns. I have been reading this book and it is really getting me excited (about coding patterns in case you needed clarification). To better understand these patterns I am going to try and code examples of each one and post my experience as well as the code on my blog. I will list the patterns so I can keep track of them as well as giving my one or two readers a heads up on what to expect.

All of these patterns and definitions are described in Head First Design Patterns by Eric Freeman & Elisabeth Freeman with Kathy Sierra & Bert Bates from O'Reilly

Design patterns

  • The Strategy Pattern (p24) - Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
  • The Observer Pattern (p51) - Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
  • The Decorator Pattern (p91) - Attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
  • The factory Method Pattern (p134) - Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  • The Abstract Factory Pattern(p156) - Provides an interface for creating families of related of dependent objects without specifying their concrete classes.
  • The Singleton Pattern (p177) - Ensures a class has only one instance, and provides a global point of access to it.
  • The Command Pattern (p206) - Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
  • The Adapter Pattern (p243) - Converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
  • The Template Method Pattern(p289) - Defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Methods lets subclasses redefined certain steps of an algorithm without changing the algorithm's structure.
  • The Interator Pattern (p336) - Provides a way to access the elements of an aggregate object sequentially without exposing the underlying representation.
  • The Composite Pattern(p356) - Allows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
  • The State Pattern(p410) - Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.
  • The proxy pattern(p460) -  Provides a surrogate or placeholder for another object to control access to it.

#     Comments [0]  
kick it on DotNetKicks.com
 Friday, January 26, 2007

Universal/Global Spell checks vs Free Dyslexic Helper, System Wide Spell Check

I have been looking for a good universal or system wide spell check for a long time I finally gave up and coded one for my self. I really like my spell check its simple and its fast. Basically it takes two key strokes to use, one to copy the text, two to launch the spell checker with a global assigned hot key. After you have corrected the spelling you paste it back. That is it, simple and fast. Do me a favor anyone that reads this blog compare what I threw together to some of the others. If enough people use/like my spell check I could add some new features like an auto-update and optimizing its memory usage.

My Spell check
Dyslexic Helper - System Wide Spell check.

Others

Enso Words 39.95 - This one takes way to many key strokes and seems too intrusive on what you are doing. I didn't want something to take up my whole screen and all of my attention. It is however very clever program and well done.

GlobalSpellChecker (freeware) - I like it, its free, and it contains a dictionary(very cool). But it uses the Microsoft Word spell checker and you have to leave the keyboard and actually access the program with your mouse, I guess you could combine it with slickrun to make this faster. It also looks like it only does one word per call to GLobalSpellCheck.

Spell Check Anywhere $29.97 - It seems to be the same as what I have done but you have to pay for it.

#     Comments [0]  
kick it on DotNetKicks.com
 Wednesday, January 17, 2007

Throw vs Throw ex - The Why

I was talking to a friend of mine and he found my example of throw vs. throw ex interesting but he asked me a question that I didn’t expect, he asked me, "why?" I simply replied, "I don’t know, just don’t do it." But his insightful question made me curious. The answer to the question is in the real .Net language, the IL. When you compile your C# or VB.Net code just plain Throw becomes ReThrow but if you write Throw ex it becomes throw. In the IL snipit below Look at line 13 for JustThrowIT and line 14 in ThrowEX.


.method private instance void JustThrowIT() cil managed
{
.maxstack 2
.locals init (
[mscorlib]System.Exception exception1)
L_0000: nop
L_0001: nop
L_0002: ldarg.0
L_0003: callvirt instance void throwDemo.Form1::ThrowsExceptions()
L_0008: nop
L_0009: leave.s L_001c
L_000b: dup
L_000c: call void [Microsoft.VisualBasic]
Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError([mscorlib]System.Exception)
L_0011: stloc.0
L_0012: nop
L_0013: rethrow
L_0015: call void [Microsoft.VisualBasic]
Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
L_001a: leave.s L_001c
L_001c: nop
L_001d: nop
L_001e: ret
.try L_0002 to L_000b catch [mscorlib]System.Exception handler L_000b to L_001c
}

.method private instance void ThrowEX() cil managed
{
.maxstack 2
.locals init (
[mscorlib]System.Exception exception1)
L_0000: nop
L_0001: nop
L_0002: ldarg.0
L_0003: callvirt instance void throwDemo.Form1::ThrowsExceptions()
L_0008: nop
L_0009: leave.s L_001c
L_000b: dup
L_000c: call void [Microsoft.VisualBasic]
Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError([mscorlib]System.Exception)
L_0011: stloc.0
L_0012: nop
L_0013: ldloc.0
L_0014: throw
L_0015: call void [Microsoft.VisualBasic]
Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
L_001a: leave.s L_001c
L_001c: nop
L_001d: nop
L_001e: ret
.try L_0002 to L_000b catch [mscorlib]System.Exception handler L_000b to L_001c
}



#     Comments [2]  
kick it on DotNetKicks.com
 Friday, January 12, 2007

Microsoft Home Server

I just found out about Microsoft Home Server it was unveil at the Consumer Electronics Show in Las Vegas. I am very excited about the possibilities of this product it sounds like its main purpose is backing up your Data, File Share, and Remote data access. This is awsome for people like me who have a media center computer, laptop, and a desktop. The best description I can find so far is an interview Tod did from Geek News Central Pod Cast.

#     Comments [0]  
kick it on DotNetKicks.com
 Wednesday, January 03, 2007

Style Helper/Color Converter

I found out that editing Cascading Style Sheets (CSS) for my blog as well as other projects can be really annoying, mostly when you are playing colors and font. I find my self constantly editing one number in a color hex set, saving the CSS file, hitting CTRL + F5, and then waiting for browser to refresh. My solution for this was a quick windows app I put together to help me coordinate my colors and font.


This app is very simple, to use it all you have to do is either enter the hex values or click on the buttons next to them choose the proper color or text from the dialog. You can also use dialogs to convert RGB to hex or hex to RGB.

Feel free to downlaod and use this application as much as you like.
DOWNLOAD
StyleHelper.exe (64 KB)
If you would like to see how it works or add more to it you can download the source.
StyleHelper.zip (110.3 KB)
#     Comments [0]  
kick it on DotNetKicks.com
 Monday, January 01, 2007

Can it be true? Does this site really give away free stuff? -- TenHunt


I was listening to The HotSpot podcast today and the host of this gaming talk show won a Wii from participating in an online scavenger hunt. This is the first time I have ever herd of a web site claiming to give stuff away and actually doing it. The name of the site is TenHunt, to win there is a count down on the front page when that reaches 0 you have to answer 10 questions that are linked to there sponsored web sites. The first one who gets all 10 questions right wins the 1st prize, even if you are not first you still get put in for a drawing for the other prizes. There is also one more way you can win, you can win by referral. If someone signs up to TenHunt using you as a referral and they win you win the same prize. If this is for real what a great idea, not only do the sponsors of TenHunt get hundreds of people meticulously searching there site but poor people like my self can win free crap.

#     Comments [0]  
kick it on DotNetKicks.com