DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: code optimizers?

  1. #1
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    code optimizers?

    Hi all,
    Well I'm quite enjoying getting back to programming....

    Hack, you mentioned 'code optimizers',

    I have recollections of using something, again in the dim distant past.

    What are the free recommendations and of course from where?

    Regards
    Big Kev

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I am afraid that Hack's reference to the "code optimizers" was a stub on the spine of people like me that are happy spending hours optimizing their code (and most of the time, like for me now, we have to do it when a wait of 30 seconds is too much for the customers...)

    Having said that, there are some applications that are more "code cleaners" than "code optimizers", applications that look in the code for redundancy, variables used and not set, variables set and not used, replicated parts of code, code running more than once and so on. In the past I used one of them, to clean up legacy code left by other programmers (it is always useful to blame someone else, isn't it... ) I don't remember at the top of my head, but be careful with "free" applications, you get what you paid for.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by Hack View Post
    I once had a programming instructor tell us that 'if it works, it is good code'

    I guess that is true, although the code optimizers out there might have a different opinion.
    Quote Originally Posted by mstraf View Post
    I am afraid that Hack's reference to the "code optimizers" was a stub on the spine of people like me that are happy spending hours optimizing their code
    When I said the above I meant nothing disparaging. Quite the contrary actually. In addition, I was not referring to any type of software. “Code Optimizers” are people…programmers like mstraf that both enjoy, and are often required to, make the code they write execute at peak performance.

    For those of you reading this who might want to use a code optimizer I would recommend looking in the mirror. What you see will be the best code optimizer you can get.

    There have been numerous times in my career where I’ve had to optimize the code I’ve written. It worked, but was simply unacceptable, so I toiled away at it long enough to get it within customer-accepted limits, but I’ve never sat down and did it on my own just for the sake of doing it.

    I’ve always admired and greatly respected programmers who are good at, and enjoy, doing this.

    Signed:

    Your Friendly Neighborhood Spine Stub

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I agree with everything you said

    Quote Originally Posted by Hack View Post
    ..., but Iíve never sat down and did it on my own just for the sake of doing it ...
    Neither did I.
    In our team we say "premature optimization is the root of all evil", from Charles Hoare famous quote: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil"
    Alas, 3% of what is left sometimes takes 97% of the time to get it done.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    code optimization

    HI,
    nudge nudge,

    I was hoping for a source of a free one. I have searched with good old google, but can't find anything.

    I was sort of banking on someone dropping a broad hint.

    I used to have one, again , many years ago. Can't remember it's name.
    It didn't do the work for you, but came up with suggestions such as function not used or sub not used. Variables change types even duplication of code was found.

    It used to be a great training aid then..

    Regards

  6. #6
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    You can use Code Advisor for VB6, freebe from Microsoft
    http://www.microsoft.com/downloads/e...displaylang=en
    It helps to find common "mistakes" in VB6 projects, to help migrate them to .NET
    I used it and it works fine, very easy to use and to understand. It does not go "deep", but at least is a start.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  7. #7
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21
    Hi
    Thanks mstraf for the link. never knew it existed from MS..
    OK I have installed it and run it. Found a few things which were obvious and now this lazy programmer has em sorted.....

    BUT

    There is one type of problem I do not understand at all...

    Code:
    'FIXIT: Declare 'GetTagValue' and 'checkvalue' with an early-bound data type               FixIT90210ae-R1672-R1B8ZE
    Private Function GetTagValue(checkvalue)
        s = InStr(temp, checkvalue)
        e = InStr(s + 1, temp, "<")
        x = e - s
        GetTagValue = Mid$(temp, s, x)
    End Function
    How do I do this declare with an early bound data type. I just don't understand it.
    One is a function and one is a passed value,

    I can't declare the passed value other than in type (string)??

    Sorry old brain not getting a grip on this one.

    Another was option explicit, soon as I do that, all sorts of strange things happen especially when I use readini and writeini routine. again it wanted me to do some early bound stuff.

    Anyone explain in very very simple terms using the above example please.

    Regards
    Big Kev

  8. #8
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    Wink

    Think I might have it sorted
    Code:
    Private Function GetTagValue(ByVal checkvalue as string) as string
        s = InStr(temp, checkvalue)
        e = InStr(s + 1, temp, "<")
        x = e - s
        GetTagValue = Mid$(temp, s, x)
    End Function
    Doing that sorted out the FIXIT comments so I am assuming I have hit nail on the head....

    Regards
    Big Kev

  9. #9
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Hi Kev,
    in your code, both GetTagValue and checkvalue are by default declared as Variant, and therefore their type is obtained during run time (late-bound)
    If you know that they are String, declare them so:

    Private Function GetTagValue(checkvalue as String) as String

    and declare as Long the local variables (s,e,x)
    Well, I am a C programmer and therefore I never use Variant variables, for me they are just a source of trouble.

    As for "Option Explicit", the first thing I did when I started using VB was to enforce it automatically (Tools->Options->Editor->Require variable declaration)
    Although it seems convenient to be able to use a variable without declaring it, it has the drawback of possible misspelling errors.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  10. #10
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21
    Thanks again.
    Well you can tell what sort of 'style' I have, it took about three hours to sort out all the FIXIT's .

    What difference did it make, well only one, the software ran fine before all the changes. The difference being it is now about 25% faster.

    It did mess up quite a few things which I had to reprogram but to be honest it was well worth it. I've advanced my knowledge quite a bit.

    I have only one other question at the moment. I'll start another thread for it though.
    Many thanks for all the help.

    Big Kev

Similar Threads

  1. Jupitermedia Legal Notice -- NO PERMISSION TO USE CODE SAMPLES?!
    By Noryk Rekrap in forum Talk to the Editors
    Replies: 3
    Last Post: 08-23-2007, 03:56 PM
  2. .NET equals Efficiency
    By Kevin in forum .NET
    Replies: 150
    Last Post: 03-04-2002, 06:40 PM
  3. Another Language
    By Steven Bell in forum .NET
    Replies: 260
    Last Post: 06-01-2001, 04:32 PM
  4. Replies: 90
    Last Post: 04-17-2001, 12:45 AM
  5. error code in JSP(please chek the code)
    By satish in forum Java
    Replies: 1
    Last Post: 09-22-2000, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center