Menu

Code cleanup

think12
2001-08-18
2001-08-20
  • think12

    think12 - 2001-08-18

    hello... i was looking at the ircd and was impressed. On the frmMain form you have a lot of 'extra' code... To improve performance and useability I suggest throwing it all in a .bas (i.e. modGlobal).

     
    • Nathan Martin

      Nathan Martin - 2001-08-20

      Actually all that code on the frmMain file should belong there since all of it deals with the Form it's self.  Moving it all into a Module would be fullish since that in fact will not change any speeds on firing code.  I have basicly all the code in the correct places as they should be, throwing most of it into modules wouldn't be the professional thing to do since doing that will only make matter worse and doing so will slow it down believe it or not.  Actually having more code localy and instead of globally will increase the speed of the VB application.  But by doing that it will make the source code harder to read so having all the code placed in correct modules and not spead across the whole project like I see in most VB projects on PSC which the developers put the declarations in one module without any subs or functions, and put all the functions and subs in another module.  Sure they can be a good idea, but the thing is the code was very small so that developer wasn't thinking right.  The best way to develop good code and great projects is to follow these rules:

      1) Don't ever learn to program in VB using MS examples! Cause most of them never do work and they're full of bugs and their examples show how to code the lazy way and not code professional way. Why I say that you may ask is because they code their examples to take way too many steps to do a single function.

      2) Don't do too many steps to complete a function, an example:

      # Bad Way:
      X = Instr(1, Text, "Hi")
      If Not X = 0 Then 'Code Function here

      # Best way:
      If Not Instr(1, Text, "Hi") = 0 Then 'Code Here

      See how easy it is to make code faster?
      and you may wonder why I didn't just do:
      If Instr(1, Text, "Hi") Then 'Code Here
      well because doing that may trigger unwanted results so you have to make sure it triggers to the correct result because VB is known to mess up if it's not therow.

      Another Example:
      # Bad Way
      X = Instr(1, Text, " ")
      TmpText = Mid$(Text, 1, X - 1)
      TmpData = Mid$(Text, X + 1)
      iSYS TmpText, TmpData

      # Best Way:
      X = Instr(1, Text, " ")
      iSYS Mid$(Text, 1, X - 1), Mid$(Text, X + 1)

      See how easy is it and so simple to do?
      By doing this you will increase the speed of the
      project and use less memory and less CPU usage, plus your executable file size will also decrease.

      I've done allot of code changes on vbIRCd v1.1.53 which is soon to be released and I've been working hard on to getting the project done.  I hope that I have helped you and anyone else who reads this posting would better understand how coding works in the life of VB, now in C/C++ it's basicly the same, but you can put your code in any place that's valid and it's not going to be time consuming.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.