PDA

Click to See Complete Forum and Search --> : Some advice


Rauland
May 15th, 2007, 03:56 PM
Hi,
Does anybody else, find that your code really starts to get really messy, and you get this feeling that your not coding in the correct way, but it is way too late to start it all over again?

I´m a begginer (C#) and working on some basic things, but do some times, really loose myself in my code.
I start really optimistic, and seems to go well... but it gets to a point, when fixing parts and stuff,.. where it does get messy.....

It´s a bit of a stupid question, but apart from some preplanning, commenting your functions and code etc,... any other best practices?? or even books, tutorials,in order to learn how to do things the propper way,...?

Thanks,....:o

timeshifter
May 15th, 2007, 04:00 PM
Exercise good naming practice. If your variables and controls are well-named, no code is too messy.

MartinLiss
May 15th, 2007, 04:26 PM
Moved.

MartinLiss
May 15th, 2007, 04:27 PM
...If your variables and controls are well-named, no code is too messy.
I know you originally answered this question when it was in Chit Chat but surely you can't mean that.

penagate
May 15th, 2007, 04:35 PM
Hi,
Does anybody else, find that your code really starts to get really messy, and you get this feeling that your not coding in the correct way, but it is way too late to start it all over again?

Everybody gets that. Once a project becomes non-trivial, you just want to knock it all down and start again and cost yourself months of work.

Basically, you have to keep everything small and manageable and then tie those completed bits together.

Atheist
May 15th, 2007, 04:54 PM
I'm experiencing this right now in one of my projects. But Im not going to start all over, im going to finish it and then re-write one part at a time.
I started this project way way back so there are lots of things I know I can do better...now:)

jmcilhinney
May 15th, 2007, 06:40 PM
As penagate says, everyone gets that. This is why the design phase is so important, but we all neglect it because it doesn't seem as glamorous or fun as the coding part. Hopefully as you gain experience you start to realise that a proper design phase can help reduce this effect and you start to spend more time creating an efficient, modular design that allows you to create lots of small building blocks that can be fit together easily and in various different ways. We all make these mistakes. The important thing is to learn from them and avoid repeating them. Not always as easy as it sounds.

JenniferBabe
May 16th, 2007, 09:29 PM
It is not that much work. I recently did a program that I did almost the structured way, no objects, just methods and 1 class. No proper design. However when the code started to get messy, just simply bring in some design with classes and objects in small steps so it won't take up too much time. For example I might see that 2 methods could be placed in a static class, then I make that small change and step by step the program will eventually have a better design.

One good thing with a proper design, modification of the code is a lot more manageable. I don't know if there is really the perfect design, I guess everyone has their own way in designing object oriented code.

Jennifer.