Posts

New & Fun vs. Tried & True

I love new technology -- .NET 4.0 and the DLR are a dream come true. I cannot wait to convince other developers of the awesomeness of having IronPython for middleware supported by compiled C# on the backend. But before I go upgrading existing client sites to 4.0, I need to be sure it will work. I just want to see it be successful from start to finish. I am skeptical by nature and want results before jumping in bed with any new tech. Not that I don't think Microsoft did an amazing job with the latest framework -- its just that I'm not as familiar with the "workarounds" that I need to learn for things. And yes, there will be workarounds -- I have yet to see perfection in software ( only a few things come close). From my experience it seems that developers fall into two general categories when faced with new technology decisions. Hopefully they change from one category to another. If you're like me, you change on a project by project basis. New & Fu...

TwoRingBinder - a Custom ASP.NET MVC Model Binder

I haven't posted in a few months. Been busy at work and starting playing WoW (I know -- its awful but its fun). But a few weeks ago I made a Custom ModelBinder -- called TwoRingBinder -- for ASP.NET MVC. Ok, it's not an implementation but rather a class inheriting from DataAnnotationsModelBinder that allows for easier custom Binding methods. I put it on github but will explain how to use it below. Download or check out the meat of the code. Essentially, TwoRingBinder allows you to write Binding Extensions instead of writing your own Custom Model Binder every time you want to do something tricky or different with Model Binding. Example: We have a model called SignUp . SignUp has FirstName, LastName, Origin, IsFemale and FromRoot properties. Only the FirstName and LastName properties will be bound from a form via a ValueProvider; however, we need IsFemale to have a value (assume for a service of some type). Now, we don't want a checkbox on the site for people to se...

ASP.NET MVC and MSBuild via Command-Line

I struggled with this one for a couple hours & wanted to post some help. I'm trying to move towards better deployment processes. I'd like to use TeamCity but until then, command-line will do. It's how I roll anyways. When I first ran MSBuild on my ASP.NET MVC CSPROJ file I got the following error: C:\Projects\MvcApplication.WebUI>msbuild /p:Configuration=Debug MvcApplication.csproj Microsoft (R) Build Engine Version 2.0.50727.3053 [Microsoft .NET Framework, Version 2.0.50727.3603] Copyright (C) Microsoft Corporation 2005. All rights reserved. Build started 5/18/2010 9:27:29 PM. __________________________________________________ Project "C:\Projects\MvcApplication.WebUI\MvcApplication.csproj" (default targets): Target ResolveProjectReferences: C:\Projects\Assembly.csproj(200,11): error MSB4019: The imported project "C:\Microsoft .CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on...

Why TradingBlox is so Awesome

TradingBlox is a relatively expensive piece of software that you've (probably) never heard of. You may never use it. But I still think you should know about it. I've been passionate about the financial markets for years. Later I'll explain this month why you should at least know something about them. I had the pleasure of working at Carmichael and Company LLC and learned a great deal about trading from Ralph Carmichael. It excited a passion in me. This passion was fueled by books like: Market Wizards, Reminisces of a Stock Operator and The Way of the Turtle. Also this little PDF about the original Turtle trading rules really helped. After trying to program my own recreation of the Turtle rules, I stumbled upon TradingBox. It did everything I wanted and more. It has an amazing community. It supports trading & optimizing multiple markets with the same system (which was a pain -- if not impossible -- using TradeStation). TradingBlox lets you program trading r...

Spark - Optional Parameters in Partials

While on the topic of the Spark View Engine , there is an easy way to make a parameter of a partial optional so you don't always need to pass a value when calling the partial. Simply define the variable as part of the viewdata property. <!-- samplePartial.spark --> <viewdata optionalParameter="string" /> <a class="active?{optionalParameter == "home"}">Home</a> That's it. Now you can call the partial by itself... <samplePartial /> ... or with the optionalParameter ... <samplePartial optionalParameter="home" /> A helpful trick that I couldn't find a lot about online.

Spark - Recursive rendering of partial files not possible (but it is!)

We've been using the Spark View Engine a lot at work. I absolutely love it. Our front end developers love it (they don't need to re-learn something like we had to for NHaml ) and if they don't want to use Spark's features, standard HTML works without problems. During one project, I was making some contextual menus. I wanted to call a Spark partial recursively in order to not repeat myself & keep things flexible for the future. Unfortunately Spark specifically disallows this. If you try it, you will get an Exception that states "Recursive rendering of partial files not possible" . Well that just sucks. I understand the limitation in the View Engine itself but there is a way around it. Not super elegant but definitely functional without sacrificing anything other than style . I posted the following example in the Spark project itself. The trick is using the HtmlHelper 's RenderPartial method. Let's say we have a partial called: navigation...

How to Troubleshoot a Problem

Building computers early on in life was an invaluable experience. Fighting with mobos & hunting for drivers taught me more about software development (& customer support) than hardware. I've been trying to summarize those lessons into an easy framework for debugging, troubleshooting and fighting most problems. Below is just what I have so far. Hopefully it's useful in some way. 1) Don't Panic - if this sounds familiar, congrats, you're a geek. You have to be calm & stop freaking out to be of any use. Someone going ape shit in your face is the fastest way to stop your brain from working. So take a moment, read Zen Habits and just chill for a second. 2) Identify the Problem - before doing anything, ANYTHING, you must figure out what's going wrong. Is the page not displaying? Is an error appearing? What's in the stack trace? What is happening that shouldn't be? 3/10 times you will stop here because nothing is wrong at all. Someone wa...