Hi, welcome to Will Code For Coffee dot com, the personal blog of Eric Hoff. After a short hiatus I'm now working on bringing the site back up and blogging regularly again.
Keep checking here for more new articles!
I’m finding CodeIgniter a little frustrating right now. I really wanted to use an MVC tool, but CI is not playing well with IIS. Also, the documentation really isn’t that great, even for an open-source project.
Alas, like most PHP projects it just wasn’t designed or tested with IIS in mind. Fortunately I’m discovering this relatively early in the project, but I’m a little frustrated that some of these things are coming up now.
I think given the choice, since the IIS setup was decided for me before, I might have push ASP.NET Forms (vs MVC) instead. Something I’ll keep in mind for next time.
Of course, CodeIgniter does work much better on my local Apache development environment. I don’t want to come down too hard on it. I’m just not impressed with how it works on IIS.
I think it’s really great that they’re building an MVC product for ASP.NET at Microsoft! I think it has the possibility to bring a lot of PHP, Python and Ruby guys onto the platform.
But it’s not ready to use yet so I’m going to use CodeIgniter. Sure people are out there coding with the beta, or I could even use plain ol’ Web Forms, but long story short: it isn’t ready. It’s going to be awesome when it’s done, it’s awesome now, but every new beta brings out breaking changes.
So even though it makes me sad to leave my beloved C# for one site, I’m gonna have to stick with PHP for this one.
I’ve been coding in PHP for a new client lately, and while PHP doesn’t have all the glory associated with it that ASP.NET has, nor does it have the compiler or IDE that I love, it is still a fairly decent language to code a website in - but only if you do it right.
For some reason people LOVE to stick a ton of MySQL queries into the middle of their HTML templates, which are also embedded deeply among more PHP code. Are you guys kidding me? The people who do this have obviously never maintained their own code, it’s just ridiculous to look at or even contemplate maintaining.
OK, maybe this is sounding too angry of a rant, but this is the reason that PHP Programmers have as bad a reputation as VB Programmers. I sure don’t want that kind of reputation.
Fortunately there ARE good PHP Programmers out there (no I admit, I’m not the only one!
). Isn’t most of Yahoo’s website infrastructure based around PHP? They must be writing maintainable, scalable code! So it must be possible in PHP.
There are lots of good, lightweight frameworks like CodeIgniter or CakePHP available out there. They’re easy to learn, easy to use and make your websites far more maintainable by you and people like me. It should also give you a bit more developer cred, AND help you get your site out there and online faster to boot!
Sorry for the Code Rage, just trying to get the word out! As with everything, there is a better, easier, faster way, you just have to look for it and use it!
And I’m back at work again! I got a call from a friend of a friend on Canada Day needing some help with a PHP project. So it’s back to the grindstone for me!
Today marks the end of a six month contract with Redengine. It’s sad to leave, but I wish them the best with their future endeavors!
I’ll be spending the summer looking for work, working on stuff around the house and on personal programming projects under Hoffsoft Consulting Services Corporation.
Ever since I first heard about it on the Plumbers @ Work Podcast I’ve been looking forward to the release of the psake PowerShell build tool James Kovacs was developing.
Looks like one of the first versions have been released. I’m excited for two reasons: 1) command-line build tools are always the most powerful tools, 2) I can use this to learn PowerShell!
Anyway, thanks to James Kovacs! I’m looking forward to trying it out!
I just read a great article in MSDN Magazine (available online here) on the Open / Closed Principle from the Patterns in Practice column. I really enjoyed it. I’m going to have to spend some more time learning some more design patterns. I’ve spent some time learning Model-View-Presenter (MVP) and Inversion of Control (IoC) but haven’t put either into practice yet. Who knows what the future holds though?
Another new feature added in C# 3.5 to accommodate anonymous types is the introduction of the var type keyword. In his Coding Horror blog Jeff Atwood is extolling the virtues of using var to reduce type declaration redundancy. His example is converting:
StringBuilder sb = new StringBuilder(256);
UTF8Encoding e = new UTF8Encoding();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
into this:
var sb = new StringBuilder(256);
var e = new UTF8Encoding();
var md5 = new MD5CryptoServiceProvider();
His point is that declaring the type as StringBuilder and then assigning it a new StringBuilder is redundant - StringBuilder appears twice on that line of code, before and after the assignment operator (=). He makes an excellent point because the example using var is far more concise than the original example. Furthermore, we should be more interested in what is being assigned than what we’re assigning too (at least on that line of code). I find when I read the first block my eyes stick on the left-hand side of the assignment, but in the second example I read the right-hand side code instead.
As a side note. the excellent tool ReSharper 4.0 suggests using var for every local variable declaration by default. It’s one of the first things I changed in ReSharper when I started using it.
You see, I don’t entirely agree with using var. Using var is fine, but we aren’t converting C# into a dynamically typed language like Python or JavaScript - C# is still statically typed, using var just forces the compiler to figure out the type you’re using, usually based on the first value assigned to it. In Python or JavaScript I could take sb from the above example and assign to it the UTF8Encoding() object reference on the next line, but C# won’t let you do that, the compiler will give you an error.
I don’t like the illusion, so where possible I will use var, but I’ll keep using types too when necessary for clarity.
I just found out after tracking down a weird popup alert error “Object reference not set to an instance of an object” that it was being caused inside an ASP.NET asmx web service being called from a ComponentArt grid control. The web service was causing an exception but it was not caught by Application_Error!
I spent a few hours trying to find out where on the client the exception was occurring before tracking it to the web service. I figured nothing was happening on the server since Application_Error didn’t log the error for me.
So, unless you know something I don’t know, make sure you add your own error handling to your Web Services.
Finding common values in two lists is simple in .NET 3.5 thanks to LINQ! I found this example here and here.
In practice here is what I did:
var currentOperatorFacilityIds = from fac in Facility.Facility.ListAllForOperator(this.OperatorId) select fac.ID;
var deleteOperatorFacilityIds = from fac in Facility.Facility.ListAllForOperator(operatorId) select fac.ID;
var commonFacilityIds = currentOperatorFacilityIds.Intersect(deleteOperatorFacilityIds);
Really simple! I love LINQ.