programming-styles

As our favorite imperative languages gain functional constructs, should loops be considered a code smell?

In allusion to Dare Obasanjo's impressions on Map, Reduce, Filter (Functional Programming in C# 3.0: How Map/Reduce/Filter can Rock your World) "With these three building blocks, you could replace the majority of the procedural for loops in your application with a single line of code. C# 3.0 doesn't just stop there." Should we increasin...

Design patterns, how do they differ from other programming styles?

Design patterns aren't necessarily a programming style but rather a template for solving a problem in a number of different situations. But how do they differ from other programming styles? Thanks Edit: "(a) What are design patterns? How do these differ from other programming styles? [7]" ...

Programming style: should you return early if a guard condition is not satisfied?

One thing I've sometimes wondered is which is the better style out of the two shown below (if any)? Is it better to return immediately if a guard condition hasn't been satisfied, or should you only do the other stuff if the guard condition is satisfied? For the sake of argument, please assume that the guard condition is a simple test th...

Using static variable in function vs passing variable from caller

I have a function which spawns various types of threads, one of the thread types needs to be spawned every x seconds. I currently have it like this: bool isTime( Time t ) { return t >= now(); } void spawner() { Time t = now(); while( 1 ) { if( isTime( t ) )//is time is called in more than one place in the real...

Code "internationalization"

I worked on different projects in different countries and remarked that sometimes the code became internationalized, like SetLargeurEtHauteur()                            (for SetWidthAndHeight, fr) Dim _ListaDeObiecte as List(Of Object)   (for _ObjectList, ro) internal void SohranenieUserov()             (for SaveUsers, ru) et...

C# - Bad Practices

What are some of the bad practices you have seen in C# or .NET in general, there are plenty of posts on "good" practices, but I have not seen one on bad practices. If this is OT then please delete. ...

When should a .c file not have an associated .h file?

Most of the time in C programming it seems that there will be one header file (.h) per code file (.c), for the function prototypes at least. When would it be appropriate to not have a header file for a code file? ...