Alex Rivera | Logout

I am compiling a rules of programming mindset for my team: What are yours?

Asked 2009-02-05T00:05:47.960
44

I have been working on a list for a while that helps me share the why of programming approach and thought as much as how to do something.

For this, I wanted to build a list of things that are:

  • best practice,
  • best thought,
  • best approach...

that help a programmer's ability to analyze, think, approach, solve and implement in the most effective way.

I have seen dozens of incredibly valuable comments in questions throughout Stack Overflow, but I couldn't find a place where we keep them together. There is the most controversial opinion on Stack Overflow. However, I'm just looking for sagely insights that can be shared and help my team, and I approach and solve problems better through better programming.

Hopefully this can be one place to gather the one or two liners that are concise, profound and easy to share, repeat, review. If we keep it to one rule per answer it might be easiest to vote up/down.

I'll start with the first.

DRY - Don't Repeat Yourself - In code, comments or documentation.

Edit
Report

11 Answers

20

Follow the SOLID principles:

Single Responsibility Principle (SRP)

There should never be more than one reason for a class to change.

Open-Closed Principle (OCP)

Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.

Liskov Substitution Principle (LSP)

Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.

Interface Segregation Principle (ISP)

Clients should not be forced to depend upon interfaces that they do not use.

Dependency Inversion Principle (DIP)

A. High level modules should not depend upon low level modules. Both should depend upon abstractions.

B. Abstractions should not depend upon details. Details should depend upon abstractions.

answered 2009-02-05T00:33:43.083
16

Best Practice: Use your brain
Don't follow any trend/principle/pattern without thinking about it

answered 2009-02-05T07:58:32.080
13

Less code is better than more, as long as it makes more sense than lots of code.

answered 2009-02-05T00:18:41.790
7

Build Breaker Buys Lunch

answered 2009-02-05T00:11:57.497
5

Take part in open source development

If you are using open source code in your projects, remember to post your bugfixes and improvements back to the community. It's not a development best practice per se, but it's definitely a programmer mindset to strive for.

answered 2009-02-05T01:53:15.700
3

Never tell business everything!

Refactoring is part of your job and not something that is up for discussion. If you always add a little "estimated" time to be able to do necessary refactoring there won't be any complaints about it!

answered 2009-02-08T00:59:00.033
1

Declare everything. Never nest 15 functions into 1 variable.

answered 2009-02-05T00:34:11.040
1

It is never as easy as you think

This is in response to another answer, but does not contradict it! Both are valuable principles that should be followed.

answered 2009-02-05T10:42:25.490
1

Your code should be so simple that anyone who looks at it can understand what it does without reading any documentation.

But don't forget to document everything anyway.

If your API is not braindead-simple to use, there is something wrong with the API. Refactor it until it takes no effort to use correctly.

Before you write any code, research first to find out if the framework already has built-in support or extensible interfaces for what you're trying to do.

answered 2009-02-06T06:49:06.133
0

Some Things Are Better Done than Described

Don't fall into the specification spiral---at some point you need to start coding.

via The Pragmatic Programmer

answered 2009-02-05T01:07:21.597
0

Creating software is like.. building a house.

You can try building it without a blueprint, a plan, experience, an architect or qualified tradespeople.

As a result it will almost always cost more, take longer, and be full of future, ongoing surprises that need your time and money.

Just because someone can build a shed without a blueprint doesn't mean they should.

answered 2009-02-05T02:01:57.680

Your Answer