Code Improvement Suggestions?
I am kind of in a bind and I don't know what I should do.
I have been working on an application at work for two and a half years now. This program constantly needs upgraded and new features. So far I have the program up to 40mb or so after installed. The problem I am having is I find it REALLY hard to develop new stuff,fix old stuff and speed it up.
I started on this job with absolutely NO vb.net background and little VB6 background. I had never even seen a database or knew how it worked. I have had to teach myself most of it via books/internet and some great help here. The new items I have to create at work are not very planned out, in the fact that as soon as my boss hears about it. I have to have it done in a little amount of time. And new things are added constantly, more often than not, before I finish an item I am currently working on.
I know a lot of my code has some minor to major flaws in it, but I rarely get time to go back and fix it, and it is becoming such a pain to work on this program. I don't even understand half of my old code (which im sure is a common problem as you advance in your knowledge).
One of the most major problems I am having, and don't know of any solution, is an EXTREMELY large context menu on the parent form. This menu must have EVERY link on the company's website (anywhere from 1500 to 3000 dont feel like counting). Almost daily new links are added to the website, and each time I compile I am supposed to go get all the new links to add to this menu. Every time I add a new menuitem, it takes anywhere from 2 to 5 minutes to go from code to design view on the parent form. Any ideas on how to fix that up, speed it up, or move it off the main/parent form?
Another problem I am having is my knowledge on threading is slim. I know how to create a thread no problem, but getting rid of it is my problem. What is the best way to go about disposing a thread? I have seen a few people say they set the thread to nothing... but would I do that in the function, or after I call the thread? (seems it would destroy it before the code is finished). I am not too sure on that.
Ugh... sorry I think I rambled on too much. Anyway if anyone feels like reading this novel post any comments would be appreciated. Thanks in advance
Edit: I have little OOP experience. I have been trying to teach myself how and when to use a class rather than a function/structure/form/etc... Would it be worth it to try and re-do this application from scratch (off hours) or a waste of time? It has 17+ forms, 40+ crystal reports, and 20 or so classes (not really an OOP class though, just a class to put most of the code for the forms)... I did that because it was taking a long time to switch from design/code view from all the controls on certain forms. Probably not great practice but I had to rig it somehow I guess. Some forms have 20k+ lines of code.
Re: Code Improvement Suggestions?
What does this app do? Do you say the exe is 40MB (holy crap!)?
Can you move the menu items to a combobox instead? That would conserve less space and be user to program for.
Do you already have a plan for the re-write? If not I'd wait until you have a good solid plan otherwise you might be doing the samething a little later. Also a lot of your reports and maybe some forms probably wouldn't need to change, unless they aren't needed anymore or something of that nature.
Re: Code Improvement Suggestions?
Well I am not positive what the exe file size is, but in add/remove programs its 40mb... might be the reports?
Also, When it comes to the menu, and most of the program for that matter, I don't have much control over the design. But, I know with the menu, there are a bunch of sub-menu's I know one a few of them go 6+ Sub Menu's deep.
I work at a college and this program pretty much handles everything that the school needs (as well as the website). It handles financial transactions like payments, charges, loans, etc.. all the student info, employee info, student placement, just everything.
As for the plan... I don't really have one yet. I do have a few Ideas to make things a little better. For instance, I have to load a bunch of stuff when the user logs in (so the form loads faster when they go to it... if they do). And it all loads into a two-dimensional arrray. I believe classes would be quite a bit better for most of those arrays though. Like the student array. Would be much easier to understand with a class and properties to access their SSN rather than studArray(x, 3) or whatever. But when it comes to the whole program I don't know how to make it better.
Thanks for the reply.
Re: Code Improvement Suggestions?
Quote:
I assume, best for you is to start new application from scratch ... you will loose less time on that way
Quote:
...... I had never even seen a database or knew how it worked.
Then, how it works at all, if you say this app handles financial transactions like payments, charges, loans, etc … really weird … how you manage data without DB
Previously to this job I never had. We use an Oracle database now. And I would think starting over would be the best idea if I can get the time, but like Edneeis said, without planning it will end up as it is now. Maybe I will try working on it Form by Form until its all done.
Re: Code Improvement Suggestions?
Thanks for your advice and replies. Maybe I will be able to talk my boss into letting me try to plan out a better solution for this whole project when I get a few more things done that need to be finished in a day or two. Hopefully he will be able to let me have a little while to fix this thing up.
Thanks again
Re: Code Improvement Suggestions?
Hi,
When faced with a situation like that, if you start again from scratch your boss will not be pleased with the amount of time and runtime debugging it will take. As your existing programme actually works, I suggest that, your first task is to go through it putting in clear comments as to what it is doing. Then you will have a refreshed global view of the programme and when you build the new programme you will have easy reference to code which you can improve.
If you plan this properly you have lifetime job security :bigyello:
Re: Code Improvement Suggestions?
Hah, that is a great option. When I started this application, I was not in the habbit of commenting code at all. This in turn makes it a lot more difficult to go back and read/change code of course. I think when I get some free time at work I will go back and comment it all for when I do get enough time to start rebuilding this application.
Oh and another question if anyone reads this far.
I am using an MDI interface, but it is technically not a "visible" MDI interface. What I mean by that is, In my program every form has to load at a certain location in the form. Below a program image at the top, and to the right of a TreeView. My program opens most of my forms via a TreeView with over 1k Items (most of which load the same form in a different manner). Is this actually an ok method of doing this? Or is there a better method? Each child form has no title bar so it cannot be moved/closed/etc. unless another form is opened via the TreeView.
Re: Code Improvement Suggestions?
Hi,
Sounds OK. You are obviously closing (or hiding if for a short time) all unused
forms.
Re: Code Improvement Suggestions?
Yeah, before I open a new form I use the following.
Code:
Dim f As Form
For Each f In Me.MdiChildren
Try
f.Close()
Catch er As Exception
End Try
Next
Re: Code Improvement Suggestions?
Dynamic data such as links etc. shouldn't be stored in the app source code itself. Can you not load the list of links at load time, or store them in a text file?
That will reduce the size of your application and also allow for easier updating of links.
Re: Code Improvement Suggestions?
Quote:
Dynamic data such as links etc. shouldn't be stored in the app source code itself. Can you not load the list of links at load time, or store them in a text file?
That will reduce the size of your application and also allow for easier updating of links.
I agree with you on that. I have been half tempted to try and make a database table to hold all the links, their URL, what rights have access to it, etc, etc...
But I am not sure if that would work so well since I already have to load so much data when the user is logging in as it is. Never though of a text file though. I will have to look into that, in fact I will try something like that right now. Thanks for the idea.