views:

784

answers:

20

I have been coding for a while now and am confortable with a few programming languages but now feel that I need to improve my problem solving or program design technique.

What skills do I need have to be able to design a program as a solution to a problem?

More: The question is about how to design a solution rather than how to code better.

+6  A: 
David Basarab
Agreed, although it can be a bit much for beginners, it truly is the bible of software construction.
Gary Willoughby
It is about 1000 pages, does it really worth it?
Ali
@Ali: Definitely worth it. I don't recommend this book anymore because I feel it goes without saying, but every professional developer should read it.
Bill the Lizard
Definitely, it is a long read but i don't care who you are, you WILL learn something from this book. It really can be considered as a developers bible.
Gary Willoughby
If you read it you will be a better developer. It is what they should teach you in school but don't. To me is better than master in CS.
David Basarab
+2  A: 

For Starters I would suggest reading Steve McConnell's book "Code Complete, 2nd Edition"

http://cc2e.com/

devSpeed
+2  A: 

I agree with the above post concerning Code Complete, also do some research on Test Driven Development and The SOLID Principles.

+6  A: 

Keep a list of all the issues you or others have extending or maintaining your code.

Regularly go through that list and sort it by the amount of difficulty. Then, create or find practices that minimize the difficulties and make those into your ever-evolving list of "best practices".

Mark A Johnson
+16  A: 

There are many different approaches/tips.

  1. Books. The design by patterns, elegant design, etc, some apply to software others to how engineering problems where solved in general.

  2. Code code code. Code for fun, code just for the sake of coding, take a problem that has ABSOLUTELY nothing to do with work, and just code at it (on your own time of course). You will end up solving the same problem in multiple ways, and hopefully start to look at problems differently. Or we could say "thinking outside the box".

  3. Rise to the challenge. When you come across a problem that the only solution you can come up with is "ugly" or "dirty". Rise to the challenge of finding an elegant solution. Elegant solutions are 90% obsessive compulsive, 10% sadistic, at least when you start out.

  4. Don't be shy to ask questions. I think you may have this one down. So just keep asking questions.

Infamy
Where can I find some nice problems that I can use to code for?
Ali
Pick one at random. It depends on the language etc that you code in. But how about writing some code to go out and read all your rss feeds and send you an email on keywords. Finding problems to code, is to a certain degree reinventing the wheel. But in your own unique way.
Infamy
I am now clear about what you mean, thanks. My background in .NET, is there a website where people publish there ideas and problems they have in mind?
Ali
None that I can think of off the top of my head. But you can always ask for ideas on stackoverflow. The idea is to write code, if you want to be a little piratical about it, write code to help you on a day by day bases. Something that you will use, this will help you stay interested.
Infamy
Which book are you referring to by "Elegant design"?
Ali
There are websites that post projects for freelancers. You don't have to do the job, put you can look at their business problems and try to tackle them.
Shyam
+2  A: 

For problem solving technique, look at how other people have solved problems. I recommend The Algorithm Design Manual and Algorithms in a Nutshell. Both of these books take you from a problem statement through several iterations of solutions to show you the thought process, rather than going directly to the final solution.

Bill the Lizard
+2  A: 

The most effective solution I've found is to find a problem and attack it. Start with small problems and work your way up. If neccessary, create problems (though not at work, and certainly not on a primary branch).

Once you understand the problem, try to figure it out yourself. If you fail, Google the sh*t out of it. Even if the first hit on Google fixes your problem, look at the other ones anyway. it will help provide you with an understanding of the problem-solving process and how peoples' minds work.

tsilb
Same question I asked Infamy, How can I find some nice problems that solving them can help?
Ali
1: Join a big company's software team, they always have problems. 2: Join an OSS project like FireFox or MetaWeblog.3. Break something.
tsilb
+2  A: 
Gary Willoughby
+2  A: 

Talking about books, I suggest this great one, by Martin Fowler

Refactoring: Improving the Design of Existing Code

Javier Morillo
That book is the shizzy
Mark Rogers
A: 

Read about data structures and algorithms. I put data structures first because the longer I'm in the software business, the more I realise it's really about data structures. Show me your data structures and I can probably guess your algorithms anyway. You need to understand how selecting the right data structures can make or break a system, and how to decide between them. I suggest reading about algorithms because some algorithms are very counter-intuitive, and you're unlikely to discover them for yourself when just noodling around with a problem. Sedgewick's algorithm books are quite good, if they're still in print.

Code complete is an excellent book (worth the price for the chapter on optimization - "code tuning" - alone), but for design... I'm not so sure. The second edition may be better on this, I only have the first... and its getting very dog-eared by now :-)

Bob Moore
A: 

To get better at coding, code more.

Jarrett Meyer
The question is about how to design a solution rather than how to code better.
Ali
+3  A: 

I am amazed at how many people suggest code complete or other books. In my experience people make bigger leaps/gain skills by working with other more experienced developers. A mentor/apprentice model works great here. The two work together with the mentor guiding decisions, but working through all the issues to help the junior person understand.

Seeing a master in action and how they work and what they think about is a great way to learn. Additionally, if people have different ways of working or thinking they get to see other viewpoints/aspects of doing the job/work.

IMO nothing can match the mentor model. Doing lots of coding and designing is also a way to get it, but you don't get that help that is so crucial to standing on the shoulders of others.

Tim
It is a nice idea, but how would one can find a mentor?
Ali
My apologies - I was writing as a person who spent his professional life at companies with the resources to provide this. As for hobbyists - that is a good question. You can probably find people around here willing to discuss the pros and cons of your designs if you post them up.
Tim
A: 

In my opinion the best way from intermediate to advanced level is:

Read good code written by other people.

You need to have a grasp of the basic theory first, of course. But there's a point you can't get past by just reading theory. Moving on from there requires a lot of work, and that means practical experience reading and writing code.

abababa22
Where can you find those codes?
Ali
There are many open source projects around in sourceforge etc. Not all code is great though, but you'll probably find good examples in many eshtablished open source projects.
abababa22
Sourceforge.net is not the only place. There are a lot of others like codeplex.com, code.google.com, github.com...
abababa22
+1  A: 

Start playing around in languages different from the one you are using now. And with that I don't mean to start using Java as a .Net developer.

Pick a language that you would not consider using in a production environment. A language that works totally different and has for some reason a devote following. Lisp comes in mind here.

The idea here is that you start using a language that will change your way of thinking. Sometimes you need to hit your rusty gears with a big sledgehammer to get them turning again. A weird language might turn out to be this hammer.

Patrick Huizinga
+2  A: 

Find a mentor - someone who has worked in your particular problem domain many years - and learn from them.

My best code comes from peer reviews, formal and informal. Reading books and learning about design patterns is great - but the best feedback is when someone can point directly at the code you're working on and say "You need to change this, this and that."

Specific, constructive feedback from your peers is immediately useful.

Runcible
+1  A: 

Reading and talking about it will help. Experience is great too (assuming that your not just re-enforcing bad habits).

A mentor is best.

In absence of that, write something, then delete it. Then write is again a couple of days later.

Sounds weird, but the second time around, you'll do a much better job :-) Like ants, we our lines get straighter the more we travel over the same path.

Paul.

Paul W Homer
A: 

I think you will enjoy Programming Pearls. It's very readable, chock-full of tips, and gave me a lot of insight on how to approach problems.

Also practicing on a class of problems repeatedly until you begin to recognize its patterns and characteristics. Online judges such as SPOJ are good for this.

I was also required to take an introduction to design and analysis of algorithms course in university. Like others have mentioned, having somebody more knowledgable like a mentor can save you a look of time and grief when you get stuck. But for me just being able to discuss and my thoughts with people like my classmates forced me to think more carefully.

Now if only I knew what that Donald Knuth guy is smoking....

vinc456
+1  A: 

use the great library of open source projects like source forge or google code. try to implement a piece of one of those projects and then compare. figure what is better in each design. learning is investigation that leads to discovery.

richs
A: 

sorry acccidently send a duplicate answer, haven't figured out how to delete

use the great library of open source projects like source forge or google code. try to implement a piece of one of those projects and then compare. figure what is better in each design. learning is investigation that leads to discovery.

richs
A: 

1) Read as many books as you can.

2) Study as much open source code as you can.

3) Code, code review and do pair programming as much as you can.

good luck :)

cherouvim