Should I always/ever/never initialize object fields to default values?

Think long term maintenance. Keep the code as explicit as possible. Don’t rely on language specific ways to initialize if you don’t have to. Maybe a newer version of the language will work differently? Future programmers will thank you. Management will thank you. Why obfuscate things even the slightest? Update: Future maintainers may come from … Read more

Is it a bad practice to always capture all in a lambda expression? [duplicate]

Performance The standard guarantees that if you do a default capture, the only variables that will be captured by that default capture from the surrounding environment are those that you actually use inside the lambda. As such, specifying individual variables to capture acts as documentation of what you expect to use, but should never affect … Read more

is it a good practice to close file descriptors on exit [closed]

The classic guide to POSIX programming “Advanced programming in UNIX environment” states: When a process terminates, all of its open files are closed automatically by the kernel. Many programs take advantage of this fact and don’t explicitly close open files. You did not mention the OS in your question but such behavior should be expected … Read more

SVG: Use Attributes or CSS to style?

I arrived here because I was trying to remember whether attributes or styles have greater precedence. This is one practical reason why you’d want one over another. Attributes get applied as “presentation hints”, as if they were the first of the cascading style sheets. In other words, this gives them lowest precedence. Thus the precedence, … Read more

How to customize / style a UIPopoverController

This is possible starting in iOS 5.0 by subclassing the abstract class UIPopoverBackgroundView and assigning your subclass to the popoverBackgroundViewClass property on your UIPopoverController instance. Unfortunately there is no tintColor property as the popover needs to use images for it’s arrow and border in order to achieve smooth animations during dynamic resizing. You can learn … Read more

Legible or not: C# multiple ternary operators + Throw if unmatched [closed]

Why not use a switch? I think it’s way more readable. private bool CanExecuteAdd(string parameter) { if (Script == null) return false; switch (parameter) { case “Step”: return true; case “Element”: return ElementSelectedInLibrary != null && SelectedStep != null; case “Choice”: return SelectedElement != null; case “Jump”: return SelectedStep != null; case “Conditional jump”: return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)