PDA

View Full Version : Dealing with Bad Design



asphalt
03-18-2005, 08:05 AM
How does everyone deal with bad code and design. Over the years my programming knowledge has moved forward with leaps and bounds.

I have a project that I have been working on for years, and this was my project for learning to code. So now I have big sections of my project/site that are just awful in the way it is structered. Don't get me wrong the code base works and I can even expand it fairly easily, but everytime I look at is I want to chuck it and start over but I know it will take a lot of time and new features are often mor fun to work on. So what does everyone think is the best way to go about this...

1. Say to heck with it and move everything to a better uniform architecture, bring coding and naming practices up to speed all at once?
2. Slowly update it over time?
3. Leave it and keep doing enhancements until I hit a brick wall??

This project is something I will probably work on in my spare time for the next 15 years without complaints so there is no deadline, feature lock or anything else, it is my project. That being said there are users that use it and I guess that is why I do it the satisfaction of knowing someone is using my work, so I need to keep them in mind as I move forward.


I work in asp.net and will be staying current with each release...

Fitness Logs (http://www.strengthnow.com)

Chris
03-18-2005, 12:02 PM
If you have the time I'd say do it all at once. I think you'll run into less snags that way and you'll also be more familiar with the code when doing the work.

Sometimes if I go back to work on a site I haven't worked on in awhile I'll forget how some things are setup.

asphalt
03-18-2005, 12:54 PM
I guess I am kind of thinking out loud with this post....

Chris, I do very much agree with you, but time is very relative, it is so tough to know where you should spend your time and on what in something like this. I do like the small income I make off the site and would like to make more. I am sure a lot of people on this site know that feeling of urgency to get things done, even when there are no deadlines to speak of. It seems like everytime I turn around there is a new piece of software/web site popping up in the same category, and with seemingly more time to spend on it. Working full time and family wipes out any extra time I have. Although I will not be competeing directly with any of these people, I would like to get a larger customer base built that I can workoff in the future.

OK enough rambling...

Currently the way I structure code is as follows

Every Object (business or table mapping) has 3 classes ->

Class one contains all the properties for accessing the data of the class.

Class two contains all of the Business logic wich for the most part is the go between Class one and the DB class

Class three or the DB class just loads arrays or business collections with the data from the table (looping through a datareader).

I hope this "framework" is sound and won't lead me to wanting to make changes again in the future.

chromate
03-18-2005, 01:04 PM
Sounds like it's almost a Model > View > Controller design pattern. You might wanna look it up if you're not already familiar with it.

I have the same problem as you.. Large amounts of code I wrote years ago, that works just fine in a usage sense, but it's terribly put together making it hard to maintain.

asphalt
03-18-2005, 01:47 PM
hmmm
Model > View > Controller all the documentation I read on that was kind of over my head. My structure is close to that from what I understand, but I don't have a full understanding of it? I like this layout and it works exceptionally well for everything I have implemented with it.

One other thing I have been trying to get better at is Naming Coneventions I am terrible about that. Form Fields matching, Property Names,Matching DB Names. If I could get a could solution set in stone it would save me hours of time going between the three layers to see what named things.

Speaking of stupid things I have done, stuff like allowing nulls into the database, and no default values - for me has been a huge problem.