Solved

Any issues with combining logic?

Posted on 2014-04-09
5
115 Views
Last Modified: 2014-04-09
I'm streamlining my code and I did the following;
    var currVarNm = aa.varMapping('deviceType','props');
    window[aa.prefix][currVarNm] = deviceType.toLowerCase();

Open in new window


and combined to:
window[aa.prefix][aa.varMapping('deviceType','props')] = deviceType.toLowerCase();

Open in new window


Any issues doing this? It works but I haven't checked on anything other than FF.
0
Comment
Question by:894359
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39989534
I'm not sure what the point is since it doesn't speed it up any and makes it harder to read and maintain.  Almost all interpreters these days precompile the code, they don't run it exactly as you type it.  So any attempts at shortcuts are usually meaningless and just make it more difficult to maintain.
0
 

Author Comment

by:894359
ID: 39989757
I just wanted to minimize the # of lines for some code. So you think it is a bad idea then?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39989823
Yes, I think it is a bad idea.  I never try to minimize the lines of code.  I try to make it easy for me, the human, to understand because I am the one who has to maintain and modify it.  And the machine doesn't care.  What you did does not minimize the code that is actually run.

In general, I say do not try to be 'clever'.  Write code that you can understand next week or next month.  That is especially true the first time around.  If you can get your code to work when it is clear you might be able to see things that you actually can do better.  But minimizing the lines is rarely going to do that.
0
 

Author Closing Comment

by:894359
ID: 39989931
Thanks!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39990001
You're welcome, glad to help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question