rules-of-thumb

Probability of hardware related disk or memory corruption?

I've got a few hundred computers running an app. On one computer, I've seen two instances of a single bit being incorrectly set on some strings that I pull out of SQLite. If this was my dev computer I would assume I have a bug somewhere, but there is certainly some number of installations at which point I'll start seeing rare hardware ...

How to structure #includes in C

Say I have a C program which is broken to a set of *.c and *.h files. If code from one file uses functions from another file, where should I include the header file? Inside the *.c file that used the function, or inside the header of that file? E.g. file foo.c includes foo.h, which contains all declarations for foo.c; same for bar.c and...

Where is the best place in an app to do validation? Rules of thumb?

I am making a C# app for a class project. I want to ensure a string has one of three values. Normally, in a web app, I would do validation with javascript on the client side. However, this is currently a console app. I know that I should do the validation early, but what are some good rules of thumb for validation? ...

Rule of thumb on when to use WITH RECOMPILE option

I understand that the WITH RECOMPILE option forces the optimizer to rebuild the query plan for stored procs but when would you want that to happen? What are some rules of thumb on when to use the WITH RECOMPILE option and when not to? What's the effective overhead associated with just putting it on every sproc? ...

Namespace Rule of Thumb

Is there a general rule of thumb as to how many classes, interfaces etc should go in to a given name space before the items should be further classfied in to a new name space? Like a best practice or a community preference? Or is this all personal preference? namespace: MyExample.Namespace interface1 interface2 interface3 interface...

I am compiling a Rules of Programming Mindset for my team: What are yours?

I have been working on a list for a while that helps me share the why of programming approach and thought as much as how to do something. For this, I wanted to build a list of things that are: best practice, best thought, best approach... that help a programmers ability to analyze, think, approach, solve and implement in the most e...

Hardware Sizing - Thumb Rules

In many Enterprise System architectures, it becomes imperative to size the hardware according to concurrency & workload requirements. Mostly product vendors will provide their own hardware sizing sheets wherein you just plug in the metrics and it will throw out details of number of servers, RAM required and so on. What I'd like to know ...

Balancing IIS compression with CPU time?

For instance, with a level of IIS compression set to 9, the web browsing is significantly faster. However, I also have a Web Services application on the box, which transfers significant amounts of data (e.g. 3MB payload is typical), it actually takes 20-30% longer for the data to get to the client, because the CPU on the server takes a ...

Java Collections Implimentations (e.g. HashMaps vs HashSet vs HashTable ...), what is the cost of choosing the wrong one?

In my code I default to using ArrayList for all Lists, HashMap for all maps, HashSet for all sets. From a practical standpoint how much am I losing in flexibility, scalability, readability and performance by choosing the wrong implementation? When does it make sense to spend time to decide to use one rather than another? I certainly se...

Thumb-rules to decide between web service implementations: SOAP / REST?

Are there any thumb-rules to decide between two schools of thought: SOAP and REST? ...

Rules of Thumb in GDI+

I have been working on some GDI+ code in .NET and have been learning my lessons the hard way. Simple things like: What looks good on screen may not look nice on paper and vice versa Caching too many objects can result in an OutOfMemoryException Floats aren't exact ...and so on. I'm sure there is a lot more that experienced folk can a...

Cocoa: Changing object property from different menu items.

What's the rule of thumb if I want to change observed object's single property from different menu items (think - list of options). E.g. I have an app that displays a car in a single window. I have a menu with menu item that says [Colors] with few submenu items like [Black, Green, Blue, Red, White, etc.]. How do I implement the mechanis...

What is the golden rule for when to split code up into functions?

It's good to split code up into functions and classes for modularity / decoupling, but if you do it too much, you get really fragmented code which is also not good. What is the golden rule for when to split code up into functions? ...

Polite frequency of AJAX requests?

I'm writing a script that makes an AJAX request at regular intervals. The request loads a remote page and pulls some numbers from it. The page is public, so the script does the equivalent of refreshing the page every few minutes. It's possible (although unlikely) that this script will be used by hundreds (maybe thousands) of users if I ...

Rules of thumb for when to call ToList when returning LINQ results

I'm looking for rules of thumb for calling ToList/ToArray/MemoizeAll(Rx) on IEnumerables, as opposed to returning the query itself when returning IEnumerable of something. Often I find that it is better to just return the query and let the caller decide whether a list is needed or not, but sometimes it can come back and bite you in the...