variable-initialization

sending a SOAP request with c#

I'm trying to send a SOAP request to a 3rd party web service. I've successfully send and received data from other interfaces in the same service, but I'm having problems with this particular one: <SP_GoodsMovement xmlns="http://services.hnseu.com"&gt; <GoodsMoved xmlns="http://tempuri.org/SP_GoodsMoved.xsd"&gt; <SerialNumberedGoo...

Is it bad practice to initialize a variable to a dummy value?

This question is a result of the answers to this question that I just asked. It was claimed that this code is "ugly" because it initializes a variable to a value that will never be read: String tempName = null; try{ tempName = buildFileName(); } catch(Exception e){ ... System.exit(1); } FILE_NAME = tempName; Is this indee...

Java String initialization

Which do you prefer and why" String myString = null; if(someCondition) myString = "something"; else myString = "something else"; OR String myString = ""; if(someCondition) myString = "something"; else myString = "something else"; I know that using the ternary (? :) operator is possible but I'd like to know about the abo...

Java String initialization (part 2)

I asked this goofy question earlier today and got good answers. I think what I really meant to ask is the following: String aString = ""; // Or = null ? if(someCondition) aString = "something"; return aString; In this case, the string has to be initialized in order to return it. I always thought that either option (setting it to "...