Embedded systems worst practices?

Uninitialized exception vectors (you know, for the ones that “will never be reached”) Say it with me: Global variables. Especially ones shared between ISRs and tasks (or foreground loops) without protection. Failure to use “volatile” where necessary. Having routines that DisableInterrupts() and then EnableInterrupts() paired up. Got that? Not RestoreInterrupts(), but ENABLE. Yeah, nesting. No … Read more

Ravioli code – why an anti-pattern? [closed]

Spaghhetti: Spaghetti code is a pejorative term for source code Ravioli: Ravioli code is a type of computer program structure, characterized by a number of small and (ideally) loosely-coupled software components. The term is in comparison with spaghetti code, comparing program structure to pasta; It’s comparing them. It isn’t saying it’s an anti-pattern. But I … Read more

How to prevent the arrowhead anti-pattern

I’d go for the multiple return statements. This makes the code easy to read and understand. Don’t use goto for obvious reasons. Don’t use exceptions because the check you are doing isn’t exceptional, it’s something you can expect so you should just take that into account. Programming against exceptions is also an anti-pattern.

C# Antipatterns

Rethrowing the exception incorrectly. To rethrow an exception : try { // do some stuff here } catch (Exception ex) { throw ex; // INCORRECT throw; // CORRECT throw new Exception(“There was an error”); // INCORRECT throw new Exception(“There was an error”, ex); // CORRECT }

What anti-patterns exist for JavaScript? [closed]

Language: Namespace polluting by creating a large footprint of variables in the global context. Binding event handlers in the form ‘foo.onclick = myFunc’ (inextensible, should be using attachEvent/addEventListener). Using eval in almost any non-JSON context Almost every use of document.write (use the DOM methods like document.createElement) Prototyping against the Object object (BOOM!) A small one … Read more

Singleton in go

Setting aside the argument of whether or not implementing the singleton pattern is a good idea, here’s a possible implementation: package singleton type single struct { O interface{}; } var instantiated *single = nil func New() *single { if instantiated == nil { instantiated = new(single); } return instantiated; } single and instantiated are private, … Read more

Python: is using “..%(var)s..” % locals() a good practice?

It’s OK for small applications and allegedly “one-off” scripts, especially with the vars enhancement mentioned by @kaizer.se and the .format version mentioned by @RedGlyph. However, for large applications with a long maintenance life and many maintainers this practice can lead to maintenance headaches, and I think that’s where @S.Lott’s answer is coming from. Let me … Read more