Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a student and a freelance programmer. These days I am developing a software in VB6 which has recently crossed 100KB of source code.

The main problem, I face is, many times I have to refactor my existing source code which is really very boring. Also the size of my code base is not very big (only 100KB).

What are the techniques I should you use to prevent my code from getting mess?

share|improve this question

marked as duplicate by gnat, Michael Durrant, Rein Henrichs, BЈовић, Kilian Foth May 3 '13 at 8:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Refactor even if gets boring. Use tools for refactoring which make it faster. Note that VB6 is not exactly a programming language made for big projects and gets messy easily. And document, document, and document your code. –  Sulthan Apr 28 '13 at 12:58
2  
VB6? In 2013? OMG... –  Konamiman Apr 29 '13 at 7:07

2 Answers 2

up vote 5 down vote accepted

I do not mean this in a patronising manner but if possible you should consider moving away from VB6 for future work. In the meantime my personal view is that you should not be too concerned about the number of lines of code in your solution. The real concern is the cost of maintenance. If this is a solution that is going to evolve further then you should start breaking the application up into logical units (as suggested above SOLID is a great set of principles). I also suggest that with respect to the 'document, document, document' advice above you take a 'clean code' approach where you focus on making your code self-descriptive and simple. Documentation gets out-dated because is often not maintained. Furthermore if you write simple expressive code all you really need to document is the public API.

One last thought, refactoring is difficult without using TDD. Without a set of unit tests that describe behaviour any significant refactor's are risky because you may change the application's behaviour in an unexpected manner.

share|improve this answer
    
I have to second the advice to start working on an exit strategy from VB6. This is a platform that is 15 years old, was effectively replaced by VB.NET more than 10 years ago, and has not had even extended support from Microsoft for more than 5 years. It's a dead platform and you will genuinely damage your future career opportunities if you stay on it too long. –  Carson63000 Apr 28 '13 at 20:28
    
Yeah, set up a new environmnt or machine and start working on a new machine and get a Visual Basic 2012 90 Trial at microsoft.com/visualstudio/eng/downloads –  Michael Durrant Apr 28 '13 at 21:07
    
@Carson63000 I know, I should switch to VB.NET. I want to switch. Earlier this month when I start developing my software, I want to use VB.NET but I can't use due to some financial problems –  user88873 Apr 29 '13 at 9:25

What language are you using?

If it is an object oriented language like Java or C++ make sure you understand OO Design principles like S.O.L.I.D. Also, learn some design patterns and try and analyse your current code to see if you could re-factor it to add some patterns. Design patterns will help with maintainability and extensibility in the future, and they will also help you communicate your implementation to other developers. Be careful not to use design patterns just for the sake of it, you want to avoid Needless Complexity.

Also, try and write code using the Test Driven Development approach, it forces you to really think about your design up front and write clean, testable and cohesive code.

share|improve this answer
    
I am using VB6. –  user88873 Apr 28 '13 at 9:54