Author Archive

Five Things I’ve Learned (and Learned to Love) About C#.NET

Adrian Sud, Web Developer

I am primarily a Java developer. Like many Java developers, when I think about .NET, I’m inclined to think of it as Microsoft’s rip-off of Java; that Java is pretty much exactly the same, but more readily cross-platform.  While that may have been true of at its inception, I’ve been working with C# recently and have noticed several pieces of syntactic sugar that are, well, just nice. Here are a few of the things that I have already grown to love, and that I wish were back in Java.

Null Logic and the Null Coalescing Operator

In C#, the primitive types can, with the annotation of a question mark, be wrapped in a Nullable type, to allow for the object to be null. It’s similar to using Object wrappers in Java with automatic unboxing, until you add Null to Boolean logic. The Nullable Types allow for this by effectively treating a Null value as “Maybe”, so that “null || true”  returns true, and “null && true” returns null. While such cases can easily be programmed around, the concept is powerful, and allows you to think more clearly about what you’re code is modeling. If a method is asked a yes or no question, and it says “I don’t know”, we have learned something wholly new about the state of the program.

Just to complete their thorough treatment of “null” as a legitimate value, C# provides the Null Coalescing Operator, “??”. This is really just shorthand for a terniary form, selecting the left-hand value if it is non-null, or else the right-hand value.  Still, it is an extremely common pattern, and produces complex assignments and tests without sacrificing conciseness or readability. Not a game changer, but it is a useful time-saver.

Read More Comments


Why a Clean API is Critical for Any Public-Facing Web Application

Adrian Sud, Web Developer

For most web projects, building an external or internal API is the last thing that happens, if it happens at all.  You envision the user interface, and design the data model required to produce that experience.  You start building the interface, wiring it to the model as you go.  Eventually, someone might think of setting up a public API, be it before launch or some time later. So you quickly provide accessors to whatever functions just happened to be available.

This is how we end up with APIs that can be more convoluted and difficult to use than the web application they were built for, or that are missing functionality to protect the system from bypassed business logic. This kind of “afterthought API” forces your whole system to become bloated, more complex, and more difficult to maintain, when in actuality an API should be the guiding principle toward making our applications as streamlined as possible.

Read More Comments


The Freedoms (and Restrictions) of Open Source

Adrian Sud, Web Developer

As a web developer, I feel no small amount of peer pressure towards using and building on Open Source technologies.  It’s usually a good thing: building on preexisting frameworks and projects that might fit most of your needs speeds development along, and avoids duplication of effort.  The mindset behind the Open Source ecology is wonderful too—developers, creating for the love of their trade, an overt admission that coding is what we love, and that sometimes recognition of a work well wrought is payment enough for the work itself.

Unfortunately, despite this pressure, I often wind up starting from scratch.  While I love coding for the sake of coding and am a big fan of many free and open source software (FOSS) projects, I do this for a living as well, and despite the Free Software Foundation’s assertions that “Free software is a matter of liberty”, many licenses do just as much restricting as they do freeing—they just do it the other way. A commercial license is all about ensuring that the rights of the software developer, or more likely producer, are protected. Open Source licenses, on the other hand, are all about limiting the developer or producer, so the control lies in the hands of the consumer.

Read More Comments