Function/Variable naming...
This may seem like a silly question but is there any negative drawbacks to naming your variables/functions with somewhat longer than normal names?
processTourTabComingSoon():void
does it make the app bigger?
does it make the app slower?
Are there any negatives for doing so, or does it simply make your code easier to read?
It'll make the app larger marginally due to the longer names, but other than that i don't think there are any other noticeable changes.
In the long run i think the benefits such as:
- code that is easier to read by others
- more intuitive code
- easier to maintain
easily outweight the slight negatives.
so yeah, never skimp on that kind of stuff in my opinion. Like i said the file size will be a tiny bit bigger, and app speed may be a tiny bit slower, but we're taking bytes and barely microseconds here.
Similar Messages
-
Very odd behavior regarding variable naming with DataService.fill()
I'm experiencing this odd behavior in LCDS 2.5, wich pertains
to variable naming for the objects returned by a DataService.fill()
call. I ceated a simple destination with a Java adapter. the Server
side Java data object is defined as follows)
package test;
public class RepositoryObject
private String m_strObjectId;
private boolean m_bIsValid;
private long m_lSize;
[public setters and getters here]
On Flex side, the ActionScript value object is defined as
follows:
package test
[Bindable]
[RemoteClass(alias="test.RepositoryObject")]
public class RepositoryObject
public var m_strObjectId:String;
public var m_bIsValid:Boolean;
public var m_lSize:Number;
public function RepositoryObject()
The FDS destination definition (in
data-management-config.xml):
<destination id="testDs">
<adapter ref="java-dao" />
<properties>
<source>test.TestDS</source>
<scope>application</scope>
<metadata>
<identity property="m_strObjectId"/>
</metadata>
<network>
<session-timeout>20</session-timeout>
<paging enabled="false" pageSize="10" />
<throttle-inbound policy="ERROR" max-frequency="500"/>
<throttle-outbound policy="REPLACE"
max-frequency="500"/>
</network>
<server>
<fill-method>
<name>getObjects</name>
</fill-method>
</server>
</properties>
</destination>
What I figured while debugging into the client was is the
data returned by the service (I'm using the mx:DataService call)
returns objects whose variable names
do not match my definition:
m_strObjectId becomes objectId
m_lSize becomes size
m_bIsValid becomes isValid
I wonder why that renaming??? Basically "m_str" prefix was
stripped and capital "O" became lower case "o" for my first
variable etc.
For instance, in a datagrid cell renderer I could not
reference the returned value as {data.m_strObjectId}, but if I use
{data.objectId}, it works.
Any ideas why this behavior (which I found confusing and odd)
would be greately appreciated.
RobertThe latter, as "getM_strObjectId " is an ugly name... don't
tell me that causes issue...ok kidding, I got you. The
setter/getter names are important in this context.
Thanks a lot.
Robert -
My wife's email has been getting filled with hundereds of emails with this in them this morning. I don't see where anyone else is having this problem today, but I wanted to see if it's on iCloud's end or ours.
Processing errors occurred during delivery:
Recipient address: [email protected]
Reason: Error in sieve filter: Unknown function/variable found: church around input line 79 [ stop; } require " f^ileinto"; if header ]
Delivery processing continued in spite of these errors.
Reporting-MTA: dns;ms21034.mac.com (tcp_intranet-daemon)
Arrival-date: Tue, 13 Mar 2012 07:33:18 +0000 (GMT)My Wife and I both have an Ipad and an iPhone, I use an iMac and my wife a MacBook Pro.
I have this problem with all my devices.
My wife has NOT got this problem.
We both use a [email protected] email acount.
Just compared the settings:
For "Incoming server" I have p03-imap.mail.me.com
My Wife has p02-imap.mail.me.com .... and has not got this problem.
I have setup a new rule for incoming mails (for the meantime):
move all incoming emails from [email protected] to trash and delete it.
Works fine for now,......until APPLE deals with the problem.
Message was edited by: RTONLINE -
Hi all,
I come from a mostly JAVA background. Big emphasis in that arena on encapsulation and modularization of code to help facilitate ease of maintenance and reuse...in theory I sometimes struggle with variable naming conventions within my ABAP code because I'm not all together certain there are any. In C or C++ I might use a derivation of Hungarian notation to name varaibles...and in JAVA I might observe certain object oriented rules regarding varaible naming...I find myself using a combination of those two protocols in my ABAP code. Does anyone have any suggestions for how I might name global and lcoal variables within my code?
regards,
MatHi,
Please check this links perhaps they may help.
http://help.sap.com/saphelp_nw04/helpdata/en/92/c2b084bc1d11d2958700a0c94260a5/content.htm
https://websmp101.sap-ag.de/~sapdownload/011000358700004455192006E/NameConventions.pdf
http://help.sap.com/saphelp_nw04/helpdata/en/2a/6b0b1f547a11d189600000e829fbbd/content.htm
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/011ccf90-0201-0010-92a7-b319adf89b73
http://web.mit.edu/sapr3/dev/newdevstand.html
Regards,
Ferry Lianto -
Where do you stand on variable naming in your application code?
Just out of curisoity really, I've worked in a number of places over the years and encountered multiple coding styles.
Just thought I'd throw it out there and see what your personal preferences are for variable naming??
I've seen a lot just use v_ for any variable..
v_name
v_dateofbirth
v_ageSome prefix with the scope instead of just v..
l_localname
g_globaldateThen some add the datatype..
lv_localvarchar
ln_localnumber
gb_globalbooelanAnd some even use c/java stylee..
vMyName
dDateOfBirthp for parameters..
p_param1or i/o
i_in_param
o_out_paramAnd so on...
Me, I generally just fit in with the 'house style', unless I think it's that bad that it's unusable, but that's been pretty rare.
You?
Edited by: smon on Mar 17, 2011 2:21 AMsmon wrote:
Just out of curisoity really, I've worked in a number of places over the years and encountered multiple coding styles.
Just thought I'd throw it out there and see what your personal preferences are for variable naming??
I've seen a lot just use v_ for any variable..
v_name
v_dateofbirth
v_ageSome prefix with the scope instead of just v..
l_localname
g_globaldateThen some add the datatype..
lv_localvarchar
ln_localnumber
gb_globalbooelan
Yes, I just tend to use "v_" for variables, "p_" for parameters, "c_" for constants, "cur_" for cursors, "pkg_" for packages etc.
The problem with using e.g. "lv_" for varchars and "ln_" for numbers etc. is that at some point you'll get a requirement change such that something that was stored as a number now needs to be a varchar because the business has changed the "codes" being used and you would end up having to change the variable name throughout the code, or worse still leave the variable name but just change it's datatype and have something that looks inconsistent.
And some even use c/java stylee..
vMyName
dDateOfBirth
Yuk!
p for parameters..
p_param1or i/o
i_in_param
o_out_param
just "p_". Keep it simple. -
How to call a variable named "PI"
I have a typedef that contains a variable named "PI" like the constant 3.1416... but it's an acronym for "Program Information".... I can't rename it since it's a corporate typedef...
If I need to call it from an expression, TestStand takes it as the constant, but returns a syntax error due to variable notation... example "Step.Result.PI"
Is there a way to call it?
Thanks
Jim
Solved!
Go to Solution.Hi,
This type def called PI, you dont say what is made of, lets say its just a string containing information about your program. To use it you would insert it as a Local, FileGlobal, Parameter or StationGlobal in your Sequence/SequenceFile/Station Globals.
eg Insert into Locals of MainSequence, Locals.my_pi (this is avariable of type PI) and you would enter some inital value.
How this helps
Regards
Ray Farmer
Regards
Ray Farmer -
Select from function with named parameters doesn't work
Hello,
I'm trying to execute the next sql statement:
SELECT mypack.getvalue(user_id => 231, status => 'closed') AS someAlias FROM DUAL;
I'm getting the next Error:
Error: ORA-00907: missing right parenthesis
But the next works fine:
SELECT mypack.getvalue(231,'closed') AS someAlias FROM DUAL;
What I'm doing wrong?
Is there a way to call a Function and return it's result as a single-row query?
Thanks for any suggestions.Thanks for your answers.
Just want to explain what I want to accomplish:
I want to create PL/SQL statement which:
1) Calls Function in named notation way;
2) Returns a query which contains a single row - a Function result.
I know in Transact-SQL I can accomplish this the next way:
DECLARE @return_value INT
EXEC[myproc]
@id=2,
@status='ok',
@ret_param=@return_value OUTPUT
SELECT @return_value AS my_return_value
The last SELECT call returns a query with one row in it.
How can I do the same in Oracle?
Thanks a lot! -
Function call another function variable
Is it possible to call another function variable?
Below is my Script:
f2();
function f1() {
var v2 = 1;
function f2(v2) {
var v3= 2;
alert(v2);Hi creativejoan0425,
Some additional notes:
> Is it possible to call access another function variable?
No, it isn't. A local variable only lives in the scope of the function (body) where it is declared. In that sense any local variable should be considered private—in OOP terms.
pixxxel schubser's solution is based on setting a global scope for the variable myA, so it is visible from every place of your code.
Another solution could be implemented using JS closure mechanism. You can create a local scope (in an anonymous function which is executed once) then return your main function and additional helpers from that scope. All inner functions have then access to the local variables that have been declared in the scope. For example, you can create your function f1 and attach a getter function to it, as follows:
var f1 = (function(/*anonymous*/__)
// Local variable to be nested in the closure
var v1;
(__ = function(/*optional init value*/x)
// Here is your *actual* function
// do what you want with v1
v1 = 'undefined'!=typeof x ? x : Math.random();
).getVar = function()
// Here is your getter
return v1;
return __;
var f2 = function()
alert( f1.getVar() );
// Process
f1('init');
f2(); // => 'init'
f1();
f2(); // => some random number
f1();
f2(); // => another random number
// etc
This way v1 remains almost private but the outer code can read it through f1.getVar().
Anyway this seems to me a complicate approach for a basic script that probably does not require high security level. Another option, really easy to set up, is to use the fact that a function is an object. Instead of declaring a local variable, just handle v1 as a (public) member of f1, as follows:
var f1 = function F(/*optional init*/x)
// Do something with F.var
F.v1 = 'undefined'!=typeof x ? x : Math.random();
var f2 = function()
alert( f1.v1 );
f1('init');
f2(); // => 'init'
f1();
f2(); // => some random number
f1();
f2(); // => another random number
That's it!
> why every function need to return?
No, return is not required. By default, any function that has no return statement will simply return undefined.
@+
Marc -
SSIS variable naming conventions?
Anyone got a link for SSIS variable naming conventions?
Although this an old post, replying for readers who may be interested.
I use the following convention whenever possible -
SSIS Variable Naming Convention Based on Origin of Value
http://aalamrangi.wordpress.com/2013/04/06/ssis-variable-naming-convention-based-on-origin-of-value/
- Aalamjeet Rangi | (Blog) -
JSP Error: a variable named was previously declared
Hi,
I've installed my application from Tomcat to WebLogic.
I got problem in my JSP:
<%@ page import = "com.ml.gmi.pattern.*" %>
<jsp:useBean id="JSPexample" scope="session" class="example.exampleBean" />
<jsp:setProperty name="JSPexample" property="*" />
<% AbstractPatternBean abstractBean = JSPexample; %>
<%@ include file="inHeader.jsp" %>
<title>Example</title>
<body>
test page
JSP works
<p>this is example</p>
Value is: <jsp:getProperty name="JSPexample" property="value" />
</body>
<%@ include file="inFooter.jsp" %>
exception is:
weblogic.servlet.jsp.JspException: (line 2): a variable named "JSPexample" was
previously declared at line 2 of /jsp/JSPexample.jsp
at weblogic.servlet.jsp.JspLexer.jspException(JspLexer.java:782)
at weblogic.servlet.jsp.JspLexer.processBeanTag(JspLexer.java:1382)
at weblogic.servlet.jsp.JspLexer.mXML_OPEN_USEBEAN(JspLexer.java:3116)
at weblogic.servlet.jsp.JspLexer.mXML_THING(JspLexer.java:1902)
Do you have some ideas??
Thanks,
Jenya
use jspc with -keepgenerated to see the .java that fails to compile.
Peace,
Cameron Purdy
Tangosol, Inc.
Clustering Weblogic? You're either using Coherence, or you should be!
Download a Tangosol Coherence eval today at http://www.tangosol.com/
"Jenya Strokin" <[email protected]> wrote in message
news:[email protected]...
>
> Hi,
> I've installed my application from Tomcat to WebLogic.
> I got problem in my JSP:
> <%@ page import = "com.ml.gmi.pattern.*" %>
> <jsp:useBean id="JSPexample" scope="session" class="example.exampleBean"
/>
> <jsp:setProperty name="JSPexample" property="*" />
> <% AbstractPatternBean abstractBean = JSPexample; %>
> <%@ include file="inHeader.jsp" %>
> <title>Example</title>
> <body>
> test page
> JSP works
> <p>this is example</p>
> Value is: <jsp:getProperty name="JSPexample" property="value" />
> </body>
> <%@ include file="inFooter.jsp" %>
>
> exception is:
> weblogic.servlet.jsp.JspException: (line 2): a variable named "JSPexample"
was
> previously declared at line 2 of /jsp/JSPexample.jsp
> at weblogic.servlet.jsp.JspLexer.jspException(JspLexer.java:782)
> at weblogic.servlet.jsp.JspLexer.processBeanTag(JspLexer.java:1382)
> at weblogic.servlet.jsp.JspLexer.mXML_OPEN_USEBEAN(JspLexer.java:3116)
> at weblogic.servlet.jsp.JspLexer.mXML_THING(JspLexer.java:1902)
>
> Do you have some ideas??
> Thanks,
> Jenya
-
Hi Experts,
Does anyone know if it is possible to save a KF value into a function variable (both in the same Query), so we can play with the KF value in the user exit?
Thanks
Regards,
AlbertHey!
Maybe it helps you to know that you could have a formula variable. You can calculate this value over an exit and calculate in this formula whatever you want with other key figures.
Best regards,
Peter -
Buffer allocation in functional variable is driving me crazy
Hello,
I have a functional variable that holds 16 waveforms. Theses waveforms will be growing in time. For more memory efficency, I'm trying to use preallocation of the data arrays (let's say 300000 doubles).
But it looks like there is a new buffer allocation at the shift register and this is slowing my application big time.
Since i'm pre-allocating and using inplace structure, I don't see why LabVIEW is doing a duplication of all the waveforms.
Any idea to acheive an efficient functional variable?
Here are the code of my functional variable.
Thanks in advance!
Vincent
Solved!
Go to Solution.I don't think that buffer allocation dot is your problem. That will appear on any uninitialized shift register, and is just LV's way of telling you it's going to store data there.
To improve performance I would add a new case called Get Data that outputs the waveform buffer, rather than having the shift register wired directly to an output indicator. That just forces LV to make a copy of the whole buffer every time this FG is called, even just to write or initialize data. The Get Data case would fork the shift register wire and send it to an output. Select the Use Default Value option for this output for this output terminal, so that the other cases (writing, initializing, etc.) just output an empty array of waveforms, which LV can do very efficiently.
Jarrod S.
National Instruments -
Object, variable, function, listener naming in multiple frames
Hi,
I am building, block by block a project that will have about 350 frames. There are similarities and differences between frames that would allow copying and pasting large blocks of frames to create new blocks. Navigation would be within blocks. After completing a block, there would be a need to go to the next block.
In the first several frames that I've set up, (a frame 1, frame 2 and 9 additional frames representing a small version of a block, I've noticed that a dynamic text box, button, variables seem to need unique names for each key frame (they're all key frames). If I accidently duplicate a frame, and fail to rename (instance names) items, functions I get debug errors: identifying duplicate items. So it appears that each frame (in what will be 350) will need the script edited and changing names for any of these items.
That's the question: assuming that I will need to stay with my 350 frame design, are there any possble economies of naming that I can use? The discreet blocks are (in number of frames) 16, 16, 70, 70, 70, 70 (plus a landing frame before each block, and a few frames at the end, after the last block for scores, results, discussion.
Any suggestions appreciated.
Regards,If you need to repeat code in different frames, then you need to come up with unique names for variables and functions. How you go about naming tthem is your call, whatever makes sense to your way of thinking.
One thing to consider though... if you think you need to create the same functions in different frames, there is agood possibility that you do not have to. You can usually work out some way of having the same single set of functions and variables working for you along the entire timeline, only needing to define them once in frame 1. In your other posting today you saw that extending the variable along the timeline makes it available for that whole extent. The same applies to functions, and you can often write functions generically so that they can serve the same purpose at different locations along the timeline.
Instance names won't be a problem except if you have the same objects in adjacent frames and try to change the names between them. Instance names are inherited by same objects in preceding adjacent frames. -
Happy New Year NI forums!
I am working on a project involving mobile interacting robots. In the future it is likely the application's components may need to run on different PCs (Targets). Note: at this point in time all the components are seperate but all running on the localhost machine. Thinking towards the future I want to pick the 'best' architecture to allow all these components (VIs performing various functions) in multiple locations. For example, several VIs on the Robots, VIs on serveral PCs.
I am currently aware of using Server/Client TCP/IP using named services. My mock up works well, but is it time efficient (my time coding) I wonder.. ?
Whereas I am aware of networked shared variables which handle connections and all the parsing for the underlying tcp/ip communication. But will this be difficult the manage? I am unsure if I can associate shared variables with a VI similar to named services. I suppose I could pro grammatically create the variable upon initialization of the server component - and the client could just search the list of avaiaible variables to connect too. Downside this would require DSC module.
As you can see, I am rather unsure. Any advice would be great!
Kind Regards,
James
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help!Hi Jason,
Thanks for your reply. I hope your enjoying NI UK as much as I did.. fun times!
I have seen the link you posted a few times before. But today, I took a better look at it.
My issue is I need several multi-client severs, i.e. many servers which allow multiple clients to connect to them.
Now the STM does have an example of this - STM mutli-client Example - Server.vi (used with the STM mutli-client.vi)
However, when a make copies of these code (to have my second server) - it refuses to run. As in , it just stops itself.
I DID change the port number, on the lister aspect of the server code. But I Am unsure what else I would need to change to get this setup to work?
One thought I had was, the FIFOs all having the same name - this probably isn't a good idea between servers.
Any suggestions would be grateful!
*please could you provide me email support
Kind Regards,
James Hillman
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! -
Forms 6i- Good variable naming convensions
Could you suggest any good naming conventions on Forms 6i
Thanks for your time Brian,
This morning I solved,
If I tell you what it was you won't believe it.
To Oracle Forms 10g don't like that global variables comes in this way:
PACKAGE TGLOBAL IS
SEDE_AZIENDA VARCHAR2(1):= '1';
other variables
END;
but they have to be set before you call library Package, that is, set it, call library's function where you modify it !!!
TGLOBAL.SEDE_AZIENDA := '1';
CALL_FORM (......... SHARE_LIBRARY_DATA .....
Hope this helps other with same problem!!!!
Thanks again for your time, Brian and Have a good and Merry Christmas
Maybe you are looking for
-
Adcfgclone.pl dbTechStack on Target DB removes listener and tnsnames files
Hello: I am doing a first-time clone from my PRD to my TST instance, and have undergone the following steps: 1. perl adpreclone.pl dbTier on Source DB 2. perl adpreclone.pl appsTier on Source AppTier 3. Copy APPL_TOP, COMMON_TOP, ORACLE_HOME, IAS_ORA
-
We recently setup an Open Directory server on OSX 10.4 and we're having issues getting our GNU/Linux Apache 2.0 web server to authenticate against it. Here is the section in our httpd.conf: LoadModule ldap_module modules/mod_ldap.so LoadModule authld
-
Mobile hotspot app not working on Droid Charge
My mobile hotspot app stopped working today. When I click on the app the screen flashes for a second then nothing happens. I get the same result when going to settings, wireless network, mobile hotspot. It's like the link to the app is broken or the
-
How to modify the direction of a click box depending on path followed?
I am trying to create some branching that is based on the following example: 1. Learners select a category (by clicking on a lick box): options could be strawberries, oranges and lemons. 2. Learners have 3 options under each category, some of them ar
-
The software could not be verified. It may have been corrupted or tampered with during downloading.Can not reinstall.please help to me.