Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / [LOCKED] Cut your Code

Author
Message
old_School
14
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 1st Aug 2011 09:50
Below is a snippet of some VB code:



Now I know you guys likely use DB but it all simular to C and the C family so it should make sense. This orginaly was over 1,000 lines of code. so what does it look like un optimized? Well Im not going to post a thousand lines but here is what a single variable looks like:



Imagine repeting this 1,000 plus times. Yeah that would suck not to mention it would slow down your performance. What I did above was simple. I took a collection of variables that all had the same outcome basicly and grouped them as one basicly. You should be able to apply this same concept to most if not all programming langs. This will optimize your code and give it a cleaner appearence.

Next thing to consider or question you may ask. Why do I need to clean it if Im the only one viewing the source? Good question, well at some point you may need to read over it for a refference. The best case is someone wants to buy the source code. If it looks like crap, may give a unprofesional appearence to you and your company. However, their is a except tion to this rule. It is more imporant for a code to work/function properly then just look pretty.

Do optimize were you can
Do clean your code were you can
Do comment your code correctly
Do not over comment your code
Do not optimize to the point the code no longer works
Do not make unused variables

These are some basic common sense Do's and Dont's to follow when cuting code or optimizing it. Remember a line of code can be written at lest three different ways in most cases. However, try to use to most trim and fit version when writting. If you do not know the best method, use the one you know. It may not be the best but if it works, thats all that counts. As you progress, you can go back and trim code. If your not "pro" yet its ok. Getting pratice in is far more important then worrying about making flawless code.

I hope this code tip helps.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Aug 2011 10:24
To be blunt, in my opinion, these posts you've made giving advice to other people come across as a little premature and condescending.


Why does blue text appear every time you are near?
ionstream
19
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 1st Aug 2011 10:27
You should not have 130 variables in the first place.

Login to post a reply

Server time is: 2024-04-25 18:07:01
Your offset time is: 2024-04-25 18:07:01