background preloader

Six ways to write more comprehensible code

Six ways to write more comprehensible code
I learned to write, clear, maintainable code the hard way. For the last twelve years, I've made my living writing computer games and selling them over the Net using the marketing technique that was once charmingly known as shareware. What this means is that I start with a blank screen, start coding, and, a few tens of thousands of lines of code later, I have something to sell. This means that, if I make a stinky mess, I'm doing it in my own nest. When I'm chasing down a bug at 3 a.m., staring at a nightmare cloud of spaghetti code, and I say, "Dear God, what idiot child of married cousins wrote this garbage?" So I have been well rewarded by learning about good, sane programming techniques. But there are many who, like me, stumbled into programming in an unexpected or unusual way and never had anyone drill this stuff into them. The example case For illustration purposes, our example program throughout this article is a hypothetical computer game called Kill Bad Aliens. Figure 1. Oh?

Advanced Programming Languages Introduction Research Syntax Semantics Static Semantics ( Type Theory ) Dynamic Semantics Semantic Related Developments Abstract Interpretation Program Transformation Decompilation Partial Evaluation Pragmatics ( Software Patterns , Generic Programming , Visual Programming , Persistence , Reflectiveness , Hyperprogramming) Semiotics Implementation Techniques: Garbage collection , Abstract Machines Some Conferences (not updated) People and Groups Teaching Introduction to Programming Languages Selecting First Programming Language Courses about Programming Languages Courses about Foundations of Programming Languages Courses about Language Processors Paradigms Comparing Programming Languages Functional Programming ( Haskell, ML) Logic Programming (Prolog) Object Oriented Programming (Java, C++, Smalltalk, ...) Cross Paradigms : Logic-Functional , Object Oriented-Functional , Object Oriented-Logic My List of Programming Languages Selected Bibliography Selected Papers Selected Books Acknowledgments Backus Naur Form (BNF) C.

Writing Maintainable Code Introduction The success rate for software development projects around the world is shameful. Projects are very often delivered late or over budget, which is acceptable because the alternative seems to be not delivering the project at all. Certainly there are things in the development lifecycle that are out of the developer's hands, such as the quality of the requirements. However, one cause of poor software delivery success rates is that applications with large amounts of code can quickly become unmanageable, tangled messes that no one wants to touch. Write For the Person Who Will Maintain Your Code Unless you work for yourself, the code you write will likely be touched by someone else at one time or another. Variable/Method Names I'm not going to advocate the use of any particular notation or convention. One thing you should focus on is making readable variable, function, and object names. Object s = this.GetSaxophone(); Object saxophone = this.GetSaxophone(); Short Methods Refactoring

Solving Every Sudoku Puzzle by Peter Norvig In this essay I tackle the problem of solving every Sudoku puzzle. It turns out to be quite easy (about one page of code for the main idea and two pages for embellishments) using two ideas: constraint propagation and search. Sudoku Notation and Preliminary Notions First we have to agree on some notation. A puzzle is solved if the squares in each unit are filled with a permutation of the digits 1 to 9. That is, no digit can appear twice in a unit, and every digit must appear once. Every square has exactly 3 units and 20 peers. We can implement the notions of units, peers, and squares in the programming language Python (2.5 or later) as follows: def cross(A, B): "Cross product of elements in A and elements in B." return [a+b for a in A for b in B] It can't hurt to throw in some tests (they all pass): Now that we have squares, units, and peers, the next step is to define the Sudoku playing grid. Here is the code to parse a grid into a values dict: Constraint Propagation Search Why?

Beginning Game Development: Part I – Introduction | Coding4Fun Articles Part I – Introduction Welcome to the first article of an introductory series on game programming using the Microsoft .NET Framework and managed DirectX 9.0. This series as aimed at beginning programmers who are interested in developing a game for their own use with the .NET Framework and DirectX. The goal of this series is to have fun creating a game and learn game development and DirectX along the way. Game programming and DirectX have their own terms and definitions that can be difficult to understand, but after awhile, you’ll crack the code and be able to explore a new world of possibilities. In this series, we are going to build a simple game to illustrate the various components of a commercial game. Tools: Before we start writing our first game we need to talk about the tools we will use. The most important tool for any developer is the Integrated Development Environment (IDE). At some point in your game development experience you are going to have to create or modify graphics.

On Writing Maintainable Code A QUICK NOTE: This was supposed to be a single treatise on the coding and design principles that *I* think are most important for writing maintainable code. A draft of this has been on my hard drive for a long, long time and it's turning into my own great white whale. Just to get it out, I'm breaking it into pieces that will follow shortly, depending on ongoing bouts with writer's block. Enable Change or Else! Change is a constant in an enterprise software system. A couple of months ago I talked about my vision for creating a Maintainable Software Ecosystem in which I claimed that the single most important quality for an enterprise software system is maintainability, i.e. the ease in which a system can be modified or extended. I spent much of the past two years at my previous job extending, restructuring, or flat out re-writing legacy code. Extensibility yes, but how? One solution for system maintainability is to build in "extensibility" points or use metadata-driven design approaches.

C Craft - Chapter 1. Introduction C is the desert island language. This is my favourite statement from a talk Rob Pike gave in 2001. Despite its age, despite many flaws, C is still the de facto standard, the lingua franca. Why? Or as Linus Torvalds puts it, “C is the only sane choice”. One of C’s designers, Dennis Ritchie, gives a modest account of the evolution of C. The canonical reference, Kernighan and Ritchie’s "The C Programming Language" is slim, yet contains much more than the language specification. Not only is C easy for humans to understand, but machines too can pick up the language quickly. I can roughly envision the assembly generated by a C statement, so I can make educated guesses about time and space efficiency. Brevity is the soul of wit. In my Eiffel days, I was encouraged to write "integer", not "int", "character", not "char", and so on. We call friends by shortened versions of their names. C possesses elementary yet powerful constructs that are missing from other languages.

Top 10 Things Every Software Engineer Should Know Please take a second to look at our brand new Java Resource Collection. The following top ten list collects some important things I have learned in the last eighteen years as IT professional. It is a very personal selection and doesn’t necessarily reflect the opinion of a software engineering organisation. There is no strict ranking in the list – though I tried to put the more important things to the top.The technical and business know-how is more important for young software engineers and the soft skills getting increasingly relevant for senior software engineers. 1) Fundamentals of Emotional Intelligence Almost all of us work with a lot of people. During my professional life, I attended some so called soft skill courses. The Wikipedia definition of Emotional intelligence starts with the sentence “Emotional intelligence (EI) is the ability to identify, assess, and control the emotions of oneself, of others, and of groups.” [1] The important key word in this sentence is emotions.

Some lesser-known truths about programming | Dot Mac My experience as a programmer has taught me a few things about writing software. Here are some things that people might find surprising about writing code: Averaging over the lifetime of the project, a programmer spends about 10-20% of his time writing code, and most programmers write about 10-12 lines of code per day that goes into the final product, regardless of their skill level. Good programmers spend much of the other 90% thinking, researching, and experimenting to find the best design. A Beginner’s Guide to Big O Notation « Rob Bell Big O notation is used in Computer Science to describe the performance or complexity of an algorithm. Big O specifically describes the worst-case scenario, and can be used to describe the execution time required or the space used (e.g. in memory or on disk) by an algorithm. Anyone who’s read Programming Pearls or any other Computer Science books and doesn’t have a grounding in Mathematics will have hit a wall when they reached chapters that mention O(N log N) or other seemingly crazy syntax. Hopefully this article will help you gain an understanding of the basics of Big O and Logarithms. As a programmer first and a mathematician second (or maybe third or fourth) I found the best way to understand Big O thoroughly was to produce some examples in code. So, below are some common orders of growth along with descriptions and examples where possible. O(1) describes an algorithm that will always execute in the same time (or space) regardless of the size of the input data set. Logarithms

code school

Related: