What Makes Good Code? – Patterns and Practices Series

What Makes Good Code? It's been a while since I've had a programming oriented post, and I figured this would be a great topic to write about. It's been a topic I've been thinking about more and more over the last year and I've been experimenting with certain patterns and practices to see if certain things actually make code "better". A lot of the information presented in this series will be completely based on my opinion, but I'll try to back up my opinion with as many concrete examples as I can. If you have a differing opinion, I'd love to hear it in the comments. I'd also like to call out that much of what I'll be discussing is in the context of object oriented programming. To be specific, there may be mostly C# examples used. If this isn't something…

1 Comment

Should My Method Do This? Should My Class?

Whose Job Is It? I wanted to share my experience that I had working on a recent project. If you've been programming for a while, you've definitely heard of the single responsibility principle. If you're new to programming, maybe this is news. The principle states: That every class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class You could extend this concept to apply to not only classes, but methods as well. Should you have that one method that is entirely responsible for creating a database connection, connecting to a web service, downloading data, updating the database, uploading some data, and then doing some user interface rendering? What would you even call that?! The idea is really this: break down your code into separate pieces of functionality.…

0 Comments

Code Smells – Issue Number 2

Code Smells Welcome to the second edition of Code Smells! Periodically I'll be posting about how to detect code smells and what they mean in terms of the big picture of your code. The previous installment can be found right here. What's a code smell? Wikipedia says it perfectly: In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs—they are not technically incorrect and don't currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future. Onto the code smells! The Stink List Code Smell #4: (Thanks to reddit user fkaginstrom) You have an large number of parameters being passed in to your function call. Functions that take in a ton of parameters stink for…

0 Comments

Code Smells – Issue Number 1

Background I thought this might be kind of fun (fun can also be read as "upsetting"), so I'm giving it a shot. It's pretty frequent as programmers we go back and revisit some code and find ourselves shaking our heads at what we see. These code smells often don't show their faces when they're being created, so don't beat yourself (or anyone else) up just yet. Common signs you've stumbled upon a code smell are when you find yourself saying: How could that co-op have possibly coded this?! Blast those interns! Or What the heck was John thinking when he put this together?! Does he not have a brain?! Or No wonder we find so many bugs in this part of code! Look what Jane did! But it never truly hits home until you get one of these: What is…

4 Comments

End of content

No more pages to load