Hi, Guys
I am in the process of cleaning up some old code (which does work). This code appears to use null or "" relating to strings in indicate they are empty.
I remember reading a Post from Erel saying best not to use Null for some situations (but I can't find it) and I could have got it wrong.
I am looking for some comments on best practice for usage of Null and "".
Questions
1. If you want indicate a string is empty should it be?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
2. Likewise does the following give the same result?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I think that empty strings should be set to ="" and null should not be used in relation to strings is this correct?
However for Objects, I have equated to Null (=Null) to indicate an object exists, and is initialized, but data has been cleared i.e.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Have I got it correct?
Dave
			
			I am in the process of cleaning up some old code (which does work). This code appears to use null or "" relating to strings in indicate they are empty.
I remember reading a Post from Erel saying best not to use Null for some situations (but I can't find it) and I could have got it wrong.
I am looking for some comments on best practice for usage of Null and "".
Questions
1. If you want indicate a string is empty should it be?
			
				B4X:
			
		
		
		Dim value as string
value = ""
' Or
value = Null
			
				B4X:
			
		
		
		' value is a string
IF value = Null then ....
' it it the same as
IF value = "" thenI think that empty strings should be set to ="" and null should not be used in relation to strings is this correct?
However for Objects, I have equated to Null (=Null) to indicate an object exists, and is initialized, but data has been cleared i.e.
			
				B4X:
			
		
		
		Private thisObject as ObjectClass
thisObject.Initialize()
'Code to insert data into the object and process it....
.
thisObject = Null ' indicates the object does not contain any information but can be used again.
' and
thisObject = "" '  is meaningless and should not be used.Have I got it correct?
Dave
 
				 
 
		 
 
		 
 
		 
 
		