views:

1148

answers:

15

Being a self taught programmer, I base most of what I do on KISS and DRY.

For me they encapsulate complex ideas well and DO help me to write better code.

What else should I know?

+20  A: 
  • Encapsulate what Varies
  • Program to an Interface rather than an Implementation
  • (SRP) The Single Responsibility Principle: A class should have only one reason to change
  • Favour Composition over Inheritance
  • (OCP) Open-Closed Principle: Classes should be Closed to modification, but Open to extension.

These two UI gems are from Bumper-Sticker Computer Science; I try to adhere to them wherever possible:

  • The Principle of Least Astonishment: Make a User Interface as consistent and as predictable as possible.
  • Don't make the user interface provide information that the system already knows.
Mitch Wheat
Dont know who voted you down, I voted you up again.
mm2010
Head First Design Patterns, much? :)
Firas Assaad
@Firas I bet he does!
leeand00
I do, I do! ....
Mitch Wheat
OCP (Open-Closed Principle) is a very bad, outdated idea. Doing the opposite is much more effective. Unfortunately, many developers just take certain "principles" as gospel without really understanding them, or bothering to think critically about them.
Rogerio
@Rogerio Liesenfeld: please explain why you are saying the OCP is a bad idea. It's not as far as I'm concerned.
Mitch Wheat
The Single Responsibility Principle is not restricted to classes. It applies to Classes, Methods, Properties, Local variables. Anything in your code that can be named.
Chirantan
+16  A: 

YAGNI is a good one to help developer instituted scope creep.

Loose coupling is also a fave of mine, check out the IOC pattern, and watch this for a really nice and basic (C#) example

johnc
You Ain't Gonna Need It. Thanks, just wikied :D
DrG
It's a good one to keep in mind, a developer can be their own worst enemy at times
johnc
Note that the A in YAGNI stands for "ain't" when it's code that you actually want to write (exciting micro-optimisations, towering frameworks), and "are" when it's code that you don't want to write (error handling) ;-)
Steve Jessop
+3  A: 

tight cohesion and loose coupling

I think this concept encapsulates the core of software engineering.

hasen j
I just read this http://www.nabble.com/So-what-are-"loose-coupling"-and-"tight-cohesion",-anyway--td19939484.html and found it useful
DrG
+2  A: 

Perhaps it isn't a maxim, and you already know it: first think, then code. Don't write any code without thinking before what you want to do -using pen and paper.

ARemesal
+2  A: 

Write tests.

Tests that reassure you that your code is doing what it should do.

Pretty much whatever your language, there's a testing framework available. Probably more than one.

Once you have tests, run them often. Every time something changes, so that you know immediately when you've encountered an unexpected side-effect.

Care for your tests. As your code evolves, the tests may need to evolve with it - don't discard them when they're no longer testing what your code now does.

If you get that far, try going for the Big One: write a test before you write the code that passes it. Let your tests define your code. At that point you will have added a new acronym: TDD to your arsenal.

Mike Woodhouse
+1  A: 
Mischa Kroon
+5  A: 

Warning: Tongue firmly in cheek!

  • WoMPC: "Works on my PC" - a term for stating that the reported bug isn't really a bug in the eyes of the developer.
  • #pragma DWIM: "Do What I Mean" - a special #pragma statement that lets the compiler interpret your intention instead of your actual code, thereby "doing what you meant" and not "what you wrote"
  • PEBCAK: "Problem Exists Between Chair And Keyboard" - a developer term for stating that it's the user's own fault.
  • ID 10T Error: You can figure that one out yourself ;-)
  • SEP: "Someone Else's Problem"
  • RTFM: "Read The Fracking Manual". This one is never pronounced in full.
  • STFW: "Search The Fracking Web". See RTFM.
MadKeithV
We have a similar expression to PEBCAK which is PICNIC - Problem In Chair, Not In Computer
jheppinstall
Nice one ;-) I'll remember that.
MadKeithV
HMI (Human-Machine Interface). Also, SEP is from HHGTG, give props.
Bill K
+3  A: 

GIYF : Google Is Your Friend

Franck
http://letmegooglethatforyou.com
S.Lott
A: 

Buy Bentley's More Programming Pearls for his Bumper-Sticker Computer Science.

S.Lott
heh heh, If we can't fix it, it ain't broke
johnc
+2  A: 

"Do the simplest thing that can possibly work."

It gives you a good place to start, and has the side effect of encouraging an end product that is both effective and simple to explain, which can be a big benefit when the client doesn't have a technical background.

J.T. Hurley
+2  A: 

"Normalize till it hurts; Denormalize till it works!"

A: 

GTD - getting things done. A general maxim not only relevant for programmers.

Aputsiaq
+2  A: 

Principle of Least Knowledge: Use only one dot in OOP languages.

I.e., try to avoid a.b.Method()

a.k.a. Law of Demeter

joshdick
+3  A: 
e-satis
A: 

Classes for Concepts

Andy Dent