Tag: standards
-
The Law of Demeter
I’ve been doing some more reading and came across the Law of Demeter and train wrecks again. The last time while while reading Clean Code. I’ve one book that tells me this is bad practice: And that I should do this instead: My feeling was to prefer the first as more compact here and it…
-
API lock-in
When C# first came out it didn’t have generics, that didn’t come out until version 2.0. That meant that, say, the user interface APIs either had to deal with collections of unknown objects or be use custom written collections. If they did one you don’t know what object you have; if you do the other…
-
Dream formatter
I have my own preferences about formatting code. Some developers do but I’ve met others who don’t care and just want to get on with the code. On a team you’re dealing with other developers who will have their own ideas about this. How does that work? Do you each do your own thing? Do…
-
The Power of 10
I originally came across the The Power of 10 by watching the video how NASA writes space-proof code. These are a set of rules to produce code that can be reviewed and statically analysed. As they’ve come from the space industry you can understand why they want to be really sure what their code does.…
-
Clean Code
I’ve heard of some people following the Clean Code methodology and some people reacting against it. It’s not been on my reading list before so I got hold of Clean Code by Robert C. Martin. I think it has some good ideas and a few bad ideas. My biggest problem is that these are often…
-
Historic programming style
While researching one of my recent post I came across a reference to The Elements of Programming Style. It’s a study of programming style and it was first published 50 year ago. My dad recognised the book and he remembers when you had to make programs using punched cards! Despite it’s age a lot of…
-
Good names
Code is full of identifiers. Whether that’s variables, functions or types. If you’re doing something to something else chances are that one or both of those involve identifiers. I not going talk about how you format a name for the moment, whether you use camel case, snake case or something else. This is about the…
-
Ninja coding
Apparently “ninja” is Japanese for “one who is invisible” and that sounds appropriate to me. I’ve thought of ninja coding as going and changing something as the original author would do. The idea is to leave no indication, other than a commit history, that you were there. The same function can be written in all…
-
A step too far
One of the seeds for this blog was some code that I was reviewing. It was based on a recommendation by SonarQube. I don’t have it to hand but it went roughly like this: and was based on the rule: “if”, “switch”, and range-based for loop initializer should be used to reduce scope of variables…
-
In one glance
I’m surprised how often I come across large functions in projects. It’s not uncommon to come across functions with hundreds of lines. I’ve searched for something, jump in to the middle of a file, and then scrolled up desperately looking for the start of the function so I can start to understand what it’s doing.…