I got laid off too

I got laid off yesterday due to the economy like a lot of programmers. In that blog, they ask what I would do if I got laid-off today. Well, I’m happy to say, today I didn’t do JACK!

That’s right, I did nothing. I played Halo 3 on my XBOX 360 Elite and watched American Idol. And I blogged a couple posts. That’s it.

Tomorrow, I am getting heavy into coding. I’m going to work on a side-project for a couple weeks. I’ve got a month of severance pay, so I’ll be good until the end of February.

I am also going to update my resume tomorrow. At least I don’t have to put a cover sheet on my TPS reports…



kick it on DotNetKicks.com
14. January 2009 19:33 by Rick | Comments (2) | Permalink

When good code goes bad…

In my post about refactoring code, I wrote on how you can tell how good a programmer is by looking at his code. That got me to thinking: Some stuff that seems simple, is sometimes hard to remember.

For instance, if you want a class to only have shared methods, you should mark it as not inheritable and set the constructor to private.

Public NotInheritable Class SomeClass Private Sub New() End Sub Public Shared Function SomeMethod() as boolean End Function End Class
The code in C# is like so:
public sealed class SomeClass { private SomeClass() { } public static bool SomeMethod() { } }
Sometimes I get lazy and forget to mark it not inheritable, but lately I’ve been using code analysis, and trying to make my code be more like the .net framework libraries and use best practices.


kick it on DotNetKicks.com
14. January 2009 19:20 by Rick | Comments (0) | Permalink

Refactoring someone else’s code

I needed some code to do a function for my work. I found a .NET dll that costs $49 dollars. Well, after looking at it in reflector (which I always do to get a better idea of the architecture), I decided to refactor it.

I could have just used it.

I could have just made it work and had my boss purchase it.

I had already started on something similar when I decided to search the net for code already made, after all, why rewrite the wheel.

Well, the code was OK. You know when you look at someone’s code and you can always tell how much programming a person knows.

This person/people were only beginner/mid level programmers, and they were selling code with no visible programming patterns, had spelling mistakes, many duplications and more. So I used reflector to extract the source code.

Mostly what the code did, was a bunch of classes with properties, and two class that would concatenate the properties to a string, do a http post, and retrieve/parse the xml result to another class named Result.

Fine. So I refactored it, spending 4 hours or so on it. I added a factory pattern to distinguish between the two “gateway” objects that had almost the same code. I added an interface for the gateway. I added a base class for most of the generic properties for the classes, and left only the ones that were different from the base class.

At the end of the day, I got let go from work due to the economy, so did about 1/3 of the company, so I never got to implement this code in a project.

At this point, I would say 70-80% of the code I re-wrote. So the question remains, do I now own the code? or do they still retain rights to it?

At this point, it really only saved me a couple hours of typing in property declarations. What do you think?



kick it on DotNetKicks.com
14. January 2009 19:07 by Rick | Comments (3) | Permalink

The “cloud” buzzword

The “cloud” seems to be the buzzword of the moment. Loosely defined as software as a service running off the internet.

For some reason, this is rather grating to me. I don’t know why! Reminds me of when XML first gained traction as a buzzword before people knew what it was. They (the media and blogs) made it out to seem if XML was the be-all, end-all technology. It would not only save the world, but cook you a sandwich at lunchtime if you programmed it right.

I guess they got tired of the web 2.0 buzzword.



kick it on DotNetKicks.com
14. January 2009 18:32 by Rick | Comments (0) | Permalink

Almost time for CES 2009

It's almost time for me to go to CES 2009. I get to go to CtrStg anyway. Tonight I'm going to watch the keynote streamed.

This is my first time at CES, and it's gonna rock!



kick it on DotNetKicks.com
7. January 2009 10:06 by Rick | Comments (1) | Permalink

Too many data access methods

I think I'm getting senile in my old age. We have ORMs, Data factories, linq2sql, Entities, nHibernate, SubSonic, datasets, ADO and other ways of managing and viewing our data. In fact, too many. It's confusing! Whatever happened to just using stored procedures and views via ODBC in our code, inline?

When programming, I am not usually making “typical” business apps. More so a lot of CRUD applications, and ASP.NET sites.

Other than business apps, how do you approach data access / ORM?



kick it on DotNetKicks.com
5. January 2009 20:39 by Rick | Comments (1) | Permalink

Binary hack a .NET executable

I would first like to preface this article in saying: If you’re .net library is being protected by a single boolean function, you deserve to be hacked… :)

It’s actually not that hard to binary hack an assembly. I first learned it by reading these blog entries: Part 1 Part 2

When you change an .net executable by re-signing it after hacking, you have a small problem. Any dlls or executables referencing this executable will break because the public key has changed.

You can fix this by round-tripping to IL code and back.

ildasm.exe File.exe /text /out=File.il

Then edit the public key in the .IL file(s), and run this:

ilasm.exe File.il /exe /output=OutExe /key=PubKey.snk

Voila! All references replaced.

Hacking

To hack a binary, you need a good hex editor. I use UltraEdit. Here’s the code for a IsLicensed() method.

Public Function IsLicensed() As Boolean     Try         Me.License = _          LicenseManager.Validate(MyBase.GetType, Me)         Return True     Catch ex As Exception         Return False     End Try End Function

All you would have to do is change the Return False to Return True. Not a good way to protect your code. In binary, 16 is false, and 17 is true. so editing one byte changing from 16 to 17 and then re-signing makes a control be fully licensed. The license check will always fail, but by returning true, it’s licensed (as far as it knows). Remember to remove the old one from the GAC, and to update all references.



kick it on DotNetKicks.com
5. January 2009 20:07 by Rick | Comments (0) | Permalink

Why are all control designers the same?

I like controls. Some people would say I’m a control hoarder. I love having and using controls from Infragistics, Telerik and ComponentArt for example.

They all publish the same controls. Treeview, grid, listview, fancy buttons, etc.

With XAML and WPF taking over the ecosystem, why do they write the same controls again? How come we have 90 thousand carousel controls. Can no one think of anything new? Microsoft Surface is a really cool UI. It does have buttons and lists. But maybe making a panel control that is resizable with multi-touch would make more sense than another carousel control.

I had the opportunity to check Microsoft Surface out at the Rio hotel and casino. It was awesome! I can’t wait until we get an OS that supports multi-touch. It will definitely change the way we look at user interfaces.



kick it on DotNetKicks.com
5. January 2009 19:12 by Rick | Comments (1) | Permalink

Why do programmers suck at UI?

I know, all programmers are not designers. But c’mon, you can’t look at your internal business app and think it looks pretty. Or that it’s very usable. In fact, it probably has no flashy graphics, unless you use controls like Infragistics.

If we haven’t learned enough from programming, maybe we can learn something from the recession. You have to set yourself apart from the pack. Everyone can write a windows form app. But can you make it pretty? Can you make features discoverable? Can you make it not cluttered with buttons, and have a 120 page manual to explain to users how to use your product? (Not that anyone likes writing documentation, especially catering to users).

If you bring these skills to the table, it doesn’t matter if you can use linq-to-xml. Everyone can use that…



kick it on DotNetKicks.com
5. January 2009 19:01 by Rick | Comments (1) | Permalink

About Rick

Rick lives in North Las Vegas. He loves his wife, kids, dog, motorcycle, music and programming. There ain't nothing else. Oh yeah, mountain dew!



Programming interests are geared towards multimedia. Platforms are asp.net, windows forms, and WPF.

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

RecentComments

Comment RSS