|
I think the light is processed into something else. I couldn't tell what though, because, like, there's no light!
|
|
|
|
|
Aha, I see.
Or actually maybe I don't, lacking some light??
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I'm familiar, hence I'm going to write few lines explaining..., but, wait, maybe I'm too close to, s**t....................................
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Unless you do this:
Public WriteOnly Property example As Object<br />
Set(ByVal value As Object)<br />
' Do Nothing Here, Process Nothing Here<br />
End Set<br />
End Property
CLR: Removes tough Java-based stains fast!
|
|
|
|
|
Dave Kreskowiak wrote: Not quite. It turns a property into something akin to a voting box. You put your vote in, and there's no way to get it out.
But the Get accessor only returns it. Get does not remove the item.
CLR: Removes tough Java-based stains fast!
|
|
|
|
|
It is not a surprise, given that VB itself is a horror.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
The best use for write-only things, in general, is when you are dealing with real-time control interfaces. Some devices allow you to save data to a memory location or port and that sets control bits in an external device. As far as the external device is concerned, it is an input-only deal; from the program's viewpoint it's write-only and any attempt to read would be undefined or return garbage.
One logical use for a write-only property would be to control interfaces with external hardware. You would define a class encapsulating the hardware access and anything that writes to the hardware without any chance of being able to read the real-time results back, would logically be marked as WriteOnly. This is fairly common when using some PIC chips, DSP chips and assorted other devices. In my DSP applications, marking output data as WriteOnly would make perfect sense, since once it is sent to the buffer, it goes out the sound interface and does not exist anywhere that is accessible to the software. (Note: I haven't done that, since I knew it was essentially write-only and never thought I might try to read it again.) To me, marking a property as WriteOnly in a VB, C, C# or any other language very clearly tells everyone not to even bother to read it back because the data no longer exists.
Another use for WriteOnly properties would be when dealing with highly asychronous processes, but I won't go into that here.
So, yeah, if you're dealing with stuff in your own application's memory, WriteOnly may not make much sense, but if you are dealing with control systems and external devices, it may well make perfect sense.
The PetroNerd
Walt Fair, Jr.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I suppose a write-only property (in whatever language, but preferably C#) could be used when defining something like a queue (Enqueue) or a stack (Push). (Though not recommended.)
|
|
|
|
|
I quite often use write only properties in C#
Consider this:
Object A depends on an internal state and also needs an Object B for whatever it does. Object B inherits from a baseclass or interface, so there are many classes that may be used to create an instance to use as object B. Hardcoding it in A is not an option. Instead I use a write only property of A to pass a suitable object B at runtime. Object A then reinitializes it's internal state and prepares B for its use.
I do not want to have access to object B anymore. It is not needed and indeed any tampering with B would have a bearing on A's state. With a write only property this problem cannot arise.
|
|
|
|
|
Is there a reason for this appearing all over the code???
try
{
if (something is wrong)
throw new exceptionaboutwhateveriswring();
...
...
...
continue work
}
catch (whatever exception was just thrown)
{
Console.WriteLine(information about the error);
}
|
|
|
|
|
Hi,
that is a very clever piece of code. The normal approach:
if (!something_is_wrong) {
} else {
}
has several shortcomings:
1. the tests use negative statements, so they are error prone.
2. the error messages do not include class names and line numbers automatically
3. problems don't get encapsulated in objects
4. it disregards the exception trapping functionality available in Visual Studio
So basically it is old style, and against all modern OO principles.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Would this be better?
if (somethingIsWrong)
{
}
if (somethingElseIsWrong)
{
}
Because I don't see the point of throwing a exception only to catch it in the same place.
1: No more negative statements
2: The errors would be something that doesn't deserve exceptions like incorrect input (IIRC)
3: This shouldn't be a problem
4: Don't know
|
|
|
|
|
I'm afraid you've missed the joke icon.
The coding horrors forum was the right place to put it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I haven't been here long enough to recognize all these icons...
|
|
|
|
|
No problem. You'll catch on soon enough.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
"You'll catch on soon enough"
.
|
|
|
|
|
|
This is a function of mine, could I get a critique on this? The reason for it being there is because exceptions coming out of the lower level library were not very descriptive or helpful to the guy trying to understand where the config was screwed so this layer was added to get some extra info into the exceptions that were coming up if files were missing and so on.
Public Shared Function GetInt(ByVal iniFile As String, ByVal sectionName As String, ByVal keyName As String) As Integer
Dim i As Integer
Dim ConfigFile As IniConfigSource
Dim ConfigSection As IConfig
Try
'check file exists
If (Not System.IO.File.Exists(iniFile)) Then
Throw New Exception("Config file does not exist: " & iniFile)
End If
'Access the file
ConfigFile = New IniConfigSource(iniFile)
'Get section
ConfigSection = ConfigFile.Configs(sectionName)
'check section exists
If (IsNothing(ConfigSection)) Then
Throw New Exception("Config section does not exist: " & iniFile & vbTab & sectionName)
End If
'get key and check it is a valid value
Try
i = ConfigSection.GetInt(keyName)
Catch ex As Exception
Throw New Exception("Exception attempting to access integer key: " & iniFile & vbTab & sectionName & vbTab & keyName)
End Try
Return i
Catch ex As Exception
'Exceptions come in here
Throw ex
End Try
End Function
|
|
|
|
|
Sure does.
Yeah, that's bad; catching your own exception is like laughing at your own joke. Or other behaviours less kid sister friendly.
|
|
|
|
|
Probably written by a VB'r. I have seen that pattern used abundantly.
|
|
|
|
|
Only because C# doesn't support On Error Resume Next
You know, every time I tried to win a bar-bet about being able to count to 1000 using my fingers I always get punched out when I reach 4....
-- El Corazon
|
|
|
|
|
dan neely wrote: Only because C# doesn't support On Error Resume Next
Thankfully.
Steve
|
|
|
|
|
No, that would be
try
{
}
catch
{
}
|
|
|
|
|
PIEBALDconsult wrote: // Ignore Exception
Oops, I think you meant, return null .
|
|
|
|
|
Nah, actually I should have had several instances of that construct, but I didn't want to take up much space
try { statement } catch{}
try { statement } catch{}
try { statement } catch{}
try { statement } catch{}
...
|
|
|
|