language-agnostic

Where is the right balance of predicates in a single if statement?

I personally have no problem with the following code if (Object foo != null && !String.IsNullOrEmpty(foo["bar"])) { // do something } Because I think the following is too verbose if (Object foo != null) { if (!String.IsNullOrEmpty(foo["bar"])) { // do something } } But I wouldn't go so far with this standpoi...

Anyone plotting SO via code_swarm?

Is anyone working on something to render individual questions, or SO as a whole with codeswarm? If so, can you post a link to your work that transforms SO questions into revisions that codeswarm can understand (i.e. svn?) It would be really, really cool to see SO played (as a whole) via codeswarm, so I hope to not only ask if anyone is ...

Integer vs String in database

When defining datatypes in a database, I have always had a problem with choosing whether to use integers or strings to store certain 'numerical' data. Say I am building Yet Another Address Book and there is a post code field. Provided that post codes are always a 4 digit number, which data type do I store it as? Integer or string? Techn...

Asynchronous Vs. Synchronous Execution, What does it really mean?

Asynchronous Vs. Synchronous Execution, What does it really mean? ...

Where to go to browse for open source projects to work on?

I've decided to have a look around for open source projects that need a hand and lend a bit of time to one or two. One question though, is there a site(s) that lists current open source projects that are looking for developers and is there anywhere I could for example filter open source projects by language/technology/etc. What I'm afte...

Is what seems like polymorphism in PHP really polymorphism?

Trying to figure out whether PHP supports features like method overloading, inheritance, and polymorphism, I found out: it does not support method overloading it does support inheritance but I am unsure about polymorphism. I found this Googling the Internet: I should note that in PHP the polymorphism isn't quite the way it sh...

Ratio of real code to supporting code

I'm finding only about 30% of my code actually solves problems, the rest is taken up by logging, tests, parameter checking, exceptions, error handling and so on. Do you find that in your code, and is there an IDE/Editor that allows you to hide code that's not interesting? OTOH are there languages which make the support code more managea...

freelancer's ready-to-go code.

It's been a time since I've been on the freelance market, now I'd like to dive into that once again and I feel the best way to save private time and effort is to prepare myself some ready-to-go solutions for the most common needs. My list includes (some of them I have already done from past project, some will just write or adapt from var...

How do I set or clear the first 3 bits using bitwise operations?

Lets say I have a number like 0x448. In binary this is 0100 0100 1000. How do I set the bits 1, 2 and 3 to either all 0's or all 1's using bit-wise operations? When I say the first three, I'm counting the rightmost bit as the zero bit. So, for example Bits as 1's: b12 b0 0100 0100 1110 ^^^ Bits as 0's: b...

Boolean types

During code review I discovered many places of our C# code that looks like this: if(IsValid()) { return true; } else { return false; } or even "better": return (IsValid()? true : false); I always wondered why not just write the code like this: return IsValid(); This is the way I would write this code. I ain't questioni...

Simplest requested change that is complicated to implement?

I'm curious what change requests, from testers, clients, or managers, programmers have encountered that seemed really simple but were in fact really complicated. ...

Performance/Style Question About Returning from a Method/Function

I found some code like this in a project I'm working on public SqlDataReader SomeMethod(int someParam) { // ... some code goes here SqlDataReader dataReader = m_command.ExecuteReader(CommandBehavior.CloseConnection); return dataReader; } I was wondering what is better, the original or below public SqlDataReader Some...

Tips on a tool to measure code quality?

I'm looking for a tool that can provide code quality metrics. For instance it could report very long functions (spaghetti code) very complex classes (which could contain do-it-all code) ... While we're on the (subjective:-) subject of code quality, what other code metrics would you suggest? I'm targetting C#/.NET code, but I'm sure...

Empty method in an abstract class

I have just installed PMD to analyze my Java project. Really nice tool, highly recommended. Anyways, I got a few errors saying: "An empty method in an abstract class should be abstract instead" I checked out PMD documentation and the explanation says: as developer may rely on this empty implementation rather than code the app...

Predict next event occurrence, based on past occurrences

I'm looking for an algorithm or example material to study for predicting future events based on known patterns. Perhaps there is a name for this, and I just don't know/remember it. Something this general may not exist, but I'm not a master of math or algorithms, so I'm here asking for direction. An example, as I understand it would be ...

Maximum line length of your IDE / checkstyle

Duplicate of Coding standards and line length What is a sensible maximum number of characters per line of code? Line width formatting standard When writing code do you wrap text or not? Is there a valid reason for enforcing a maximum width of 80 characters in a code file, this day and age? Where to wrap a lin...

What programming tools haven't been written yet?

What tools would you like to have to make development easier, which either don't exist yet or are too niche/un-featured to be useful. This question was prompted by Redgate (no connection) who are looking to build a proper version control tool for Sql - that's been an obvious gap for years and will hopefully now be filled. Joel has been ...

What's an alternative to MVC?

Seems like every project I'm on uses a Model View Controller architecture, and that's how I roll my own projects. Is there an alternative? How else would one create an application that has persistent storage and a user interface? ...

Asking for Programmer Input?

When designing a system for programming use, and you want to query a large group, is there a better option than just asking Stack Overflow or any other large programming community? ...

What do you say to express the first succesful running of a program?

Yesterday, I had a moment of excitement when my LDAP client (pure C Win32) module successful retrieved data from Active Directory for the very first time. It was more than a smoke test -- I had all ready run a few of those, and it was well less than even feature complete code. Some data was mangled - so it wasn't even code I would show...