Contents

210 Articles
12 Comments

Search

8 years Ago

Solving problems

Published by marco on

This graphic Geeks versus Non-Geeks when Doing Repetitive Tasks (How-to Geek) illustrates quite nicely how programmers approach the world of problem-solving.

The chart does not show just much time must be spent before the programmer wins, that being dependent on the complexity of the task. The probability that the task will recur is also highly relevant, as automation of a smallish, one-time task is useless. Neither of those things will stop a determined programmer, though, who will automate no matter... [More]

9 years Ago

Encodo Git Handbook 1.2 is available

Published by marco on

tl;dr: Encodo Systems AG has moved from Perforce to Git and has written a manual for getting started for other users or companies looking to make the leap. It’s available for free at Encodo Git Handbook.


In the beginning, there was Microsoft Visual SourceSafe. And it was not good.

In 1994, I started working for a small software company. Source control was a structured network share until I started moving projects into Microsoft Visual SourceSafe, which was slow and balky and feature-poor,... [More]

How to Write Good Code

Published by marco on

The oft though-provoking XKCD published a flow chart recently, called Good Code (XKCD), which outlines the two branches: doing it fast or doing it right. The chart is linked below.

Despite the panacea of Agile Development, you still can’t have both fast and right. While it is possible to write good code, the odds are good that that code will accomplish a task that no longer requires completion (indicated by the “requirements have changed” block).

Even if it’s decent code, it’s further quite likely... [More]

TuneSync 2.0

Published by marco on

A few years ago, I developed a utility for syncing ratings, play counts and last-played times between the same set of songs on two different iTunes installations. I haven’t worked on it in years, but it’s quite well-written and full-featured and has rich documentation with a tutorial. You can download the Windows-only software for free.

I originally wrote this software because I was listening to a lot of music at work and rating it. When I got home, I didn’t have these ratings anymore because... [More]

Encodo C# Handbook 7.30 – Loose vs. Tight Coupling

Published by marco on

I’m currently revising the Encodo C# Handbook to update it for the last year’s worth of programming experience at Encodo, which includes a lot more experience with C# 4.0 features like optional parameters, dynamic types and more. The following is an expanded section on working with Linq. A final draft should be available by the middle of April or so.

7.30 – Loose vs. Tight Coupling

Whether to use loose or tight coupling for components depends on several factors. If a component on a... [More]

Encodo C# Handbook 7.17 – Using System.Linq

Published by marco on

I’m currently revising the Encodo C# Handbook to update it for the last year’s worth of programming experience at Encodo, which includes a lot more experience with C# 4.0 features like optional parameters, dynamic types and more. The following is an expanded section on working with Linq. A final draft should be available by the middle of April or so.

7.17 – Using System.Linq

When using Linq expressions, be careful not to sacrifice legibility or performance simply in order to use Linq instead... [More]

PHPDocumentor Fork (earthli-v2)

Published by marco on

PHPDoc is a popular tool for generating documentation for PHP projects. I made a whole lot of improvements to it for PHP5 and updated all the skins to look less boxy, have nicer and more informative icons and be easier to use, and then created an earthli fork. This article includes a full feature list and screenshots.

The earthli WebCore (the software that runs this web site) is open-source. It is also relatively well-documented. The documentation is generated using PHPDoc, but a better... [More]

Overriding Equality Operators: A Cautionary Tale

Published by marco on

tl;dr: This is a long-winded way of advising you to always be sure what you’re comparing when you build low-level algorithms that will be used with arbitrary generic arguments. The culprit in this case was the default comparator in a HashSet<T>, but it could be anything. It ends with cogitation about software processes in the real world.

Imagine that you have a framework with support for walking arbitrary object graphs in the form of a GraphWalker. Implementations of this interface complement... [More]

10 years Ago

Sealed classes and methods

Published by marco on

According to the official documentation, the sealed keyword in C# serves the following dual purpose:

“When applied to a class, the sealed modifier prevents other classes from inheriting from it. […] You can also use the sealed modifier on a method or property that overrides a virtual method or property in a base class. This enables you to allow classes to derive from your class and prevent them from overriding specific virtual methods or properties.”

Each inheritable class and overridable... [More]

How to configure a local firewall for OpenVPN (Part II)

Published by marco on

The following tip was developed using Ubuntu 9.1x (Hardy Heron) with OpenVPn 2.1rc19. It builds on the the setup from Part I.


Part I of this guide to configuring a local firewall for OpenVPN introduced you to using iptables on Linux. It also included a script for OpenVPN that opened and closed the firewall for specific IP addresses. If you haven’t read it already, you should probably go do that first.

Unfortunately, it turns out that the firewall configuration from part I is not watertight... [More]

How to configure a local firewall for OpenVPN

Published by marco on

The following tip was developed using Ubuntu 9.1x (Hardy Heron) with OpenVPn 2.1rc19. It was originally published on the Encodo blogs and cross-published here.


There are dozens of guides around that describe how to optimally configure the iptables firewall on Linux for OpenVPN. There’s even a script installed by default that is extremely well-commented and shows to how close down the firewall, then open up only very selected ports and protocols for optimal browsing. However, all of those... [More]

11 years Ago

Quino 1.1.0.0 Released

Published by marco on

Encodo Systems AG[1] has released Quino 1.1.0.0 to licensed customers; test licenses are available on request. Feel free to contact them at “info [at] encodo [dot] ch”. Read the Quino Fact Sheet for an in-depth overview.

Big, new features include:

  • Multi-language support
  • Remote method execution
  • Remote query execution
  • Full support for Microsoft SQL Server (including schema migration)
  • Improved support for object graphs in the ORM
  • Typed constants in the metadata
  • Beta support for ASP.NET MVC

More... [More]

Encodo C# Handbook 1.5.2 Released

Published by marco on

Version 1.5.2 of the Encodo C# Handbook is now available for download. It includes the following updates:

  • Expanded “8.1 – Documentation” with examples (this section is now four pages long)
  • Added more tips to the “2.3 – Interfaces vs. Abstract Classes” section
  • Added “7.20 – Restricting Access with Interfaces”
  • Added “5.3.7 – Extension Methods” and “7.17 – Using Extension Methods”

It’s also available for download at the MSDN Code Gallery.

Building pseudo-DSLs with C# 3.5

Published by marco on

DSL is a buzzword that’s been around for a while and it stands for [D]omain-[Specific] [L]anguage. That is, some tasks or “domains” are better described with their own language rather than using the same language for everything. This gives a name to what is actually already a standard practice: every time a program assumes a particular format for an input string (e.g. CSV or configuration files), it is using a DSL. On the surface, it’s extremely logical to use a syntax and semantics most... [More]

Designing a small API: Bit manipulation in C#

Published by marco on

A usable API doesn’t usually spring forth in its entirety on the first try. A good, usable API generally arises iteratively, improving over time. Naturally, when using words like good and usable, I’m obliged to define what exactly I mean by that. Here are the guidelines I use when designing an API, in decreasing order of importance:

Static typing & Compile-time Errors
Wherever possible, make the compiler stop the user from doing something incorrectly instead of letting the runtime handle it.... [More]

Waiting for C# 4.0: A casting problem in C# 3.5

Published by marco on

C# 3.5 has a limitation where generic classes don’t necessarily conform to each other in the way that one would expect. This problem manifests itself classically in the following way:

class A { }
class B : A { }
class C : A { }

class Program
{
  void ProcessListOfA(IList<A> list) { }
  void ProcessListOfB(IList<B> list) { }
  void ProcessSequenceOfA(IEnumerable<A> sequence) { }
  void ProcessSequenceOfB(IEnumerable<B> sequence) { }

  void Main()
  {
    var bList = new List<B>();
    var... [More]

Creating fluent interfaces with inheritance in C#

Published by marco on

Fluent interfaces—or “method chaining” as it’s also called—provide an elegant API for configuring objects. For example, the Quino query API provides methods to restrict (Where or WhereEquals), order (OrderBy), join (Join) and project (Select) data. The first version of this API was very traditional and applications typically contained code like the following:

var query = new Query(Person.Metadata);
query.WhereEquals(Person.Fields.Name, "Müller");
query.WhereEquals(Person.Fields.FirstName,... [More]

Supporting Data-entry in Database Applications

Published by marco on

The following is an analysis and brainstorming of a problem in generalized database browser GUIs, like those generated by the Quino metadata framework.


The User Story

Let’s start with the user story that generated this idea:

“A user was entering data using our database software and complained of losing data. After verifying that the lost data was not due to an obvious software bug, we determined that it was because of how she was assuming the software worked. That is, she would use the... [More]”

Microsoft Code Contracts: Not with a Ten-foot Pole

Published by marco on

After what seems like an eternity, a mainstream programming language will finally dip its toe in the Design-by-contract (DBC) pool. DBC is a domain amply covered in one less well-known language called Eiffel (see ISE Eiffel Goes Open-Source for a good overview), where preconditions, postconditions and invariants of various stripes have been available for over twenty years.

Why Contracts?

Object-oriented languages already include contracts; “classic” signature-checking involves verification of... [More]

Remote Debugging with [ASP].NET

Published by marco on

When a .NET application exhibits behavior on a remote server that cannot be reproduced locally, you’ll need to debug application directly on the server. The following article includes specific instructions for debugging ASP.NET applications, but applies just as well to standalone executables.

Prerequisites

There are several prerequisites for remote debugging; don’t even bother trying until you have all of the items on the following list squared away or the Remote Debugger will just chortle at... [More]

The Dark Side of Entity Framework: Mapping Enumerated Associations

Published by marco on

This article was originally published on the Encodo Blogs. Browse on over to see more!


At Encodo, we’re using the Microsoft Entity Framework (EF) to map objects to the database. EF treats everything—and I mean everything—as an object; the foreign key fields by which objects are related aren’t even exposed in the generated code. But I’m getting ahead of myself a bit. We wanted to figure out the most elegant way of mapping what we are going to call enumerated associations in EF. These are... [More]

Eject/Change a CD from Windows inside a XEN-VM using VNC

Published by marco on

This article was originally published on the Encodo Blogs. Browse on over to see more!


At Encodo, we currently run Debian Etch on our servers, with a Xen hypervisor managing a bunch of individual virtual machines (VMs). Most of the VMs also run Debian Etch, but one of them runs Windows Server 2003 instead. We use this machine for testing integration with Microsoft technologies like Sharepoint, Exchange and so on. Recently, we had to re-install the Exchange instance on that server and were... [More]

Elegant Code vs.(?) Clean Code

Published by marco on

This article was originally published on the Encodo Blogs. Browse on over to see more!


A developer on the Microsoft C# compiler team recently made a post asking readers to post their solutions to a programming exercise in Comma Quibbling by Eric Lippert (Fabulous Adventures in Coding). The requirements are as follows:

  1. If the sequence is empty then the resulting string is “{}”.
  2. If the sequence is a single item “ABC” then the resulting string is “{ABC}”.
  3. If the sequence is the two item sequence “ABC”, “DEF” then the resulting string is... [More]

Cleaning up Old Code

Published by marco on

Once you’ve been coding for a while, you’ll probably have quite a pile of code that you’ve written and are regularly using. It’s possible that you’ve got some older code in use that just works and on which you rely every day. At some point, though, you realize that you have to get back in there and fix a few things. That happened recently with the upgrade of the earthli WebCore and attendant applications from PHP4 to PHP5 (which is ongoing). The earthli codebase was born in 1999 and was... [More]

Customizing Facebook Previews from your Website

Published by marco on

When someone posts a link to your web site on Facebook, it retrieves a preview and presents that as the default text, along with a selection of pictures it found in the page. Clearly, Facebook has some sort of scraper that extracts what it thinks is the best preview text from a given URL. Sometimes it works well, sometimes not. Luckily, you can tune your pages for Facebook requests, emphasizing the parts you think are important and belong in the preview.

It’s anybody’s guess how the scraper... [More]

Debugging PHP

Published by marco on

PHP is a programming language like any other; like any other, it’s possible to construct a bug complex enough that it can only reasonably be solved with a debugger. Granted, most PHP code is quite simple and limited to single pages with single include files and a limited library or framework. However, the advent of PHP5 has ushered in more than one team with the courage to build a full-fledged web framework. You would think that the state of PHP development had concordantly improved to the... [More]

Entity Framework: Be Prepared

Published by marco on

This article was originally published on the Encodo Blogs. Browse on over to see more!


In August of 2008, Microsoft released the first service pack (SP1) for Visual Studio 2008. It included the first version (1.0) of Microsoft’s generalized ORM, the Entity Framework. We at Encodo were quite interested as we’ve had a lot of experience with ORMs, having worked on several of them over the years. The first was a framework written in Delphi Pascal that included a sophisticated ORM with support... [More]

Mercurial, Python & Debian

Published by marco on

After nearly a decade of using Perforce for my private source control, I’d decided to switch to Mercurial. Mercurial is a distributed version control system and open-source and all kinds of awesome and I won’t go into why I made the switch here. Suffice it to say it makes it much easier to release code and work with others.

Mercurial itself is an easy installation and I had it running both on my OS X 10.4 and Windows XP in a flash. I even installed the newly released HgTortoise plugin, which... [More]

Using an OpenSSL certificate for Courier IMAP

Published by marco on

Courier IMAP has a default certificate for SLL communication, but it’s only valid for a year and has bogus, default information in it. You can use a utility to generate a new certificate and, with a little perseverance, find the configuration file from which it draws its parameters. With these parameters, you can make a slightly better certificate, but it’s better to use OpenSSL to generate a proper certificate, based either on a trusted certificate or self-signed. However, OpenSSL’s default... [More]

12 years Ago

Sorting Algorithms Head-to-head

Published by marco on

 If you’re faced with a pile of data that needs to be sorted, you can use the Animated Sorting Algorithms by David R. Martin to decide, based on what kind of data you think you’re going to have. Click a little green refresh symbol in the rows to watch the algorithms race on the same dataset or click a column header to watch the same algorithm attack best- and worst-case scenarios simultaneously.