|
Are you talking about the foreach syntax?
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
No, the modification of the collection while looping it.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Brisingr Aerowing wrote: No, the modification of the collection while looping it. I've had issues trying to remove elements from a collection while looping but I have not had an issue just changing a value of the collection items, have you?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I believe Brisingr is thinking of when you iterate through a enumerable and you attempt to update the ienumerable item.
Like the following:
for(String s : stringArray){
if(i > 0){
s = joinCharacter + stringArray[i];
}
i++;
}
It's fine to update the other referenced collection (stringArray[i]).
Brisingr probably was just thinking about that. Not trying to start a battle by speaking for him though.
|
|
|
|
|
Hate to say it, but that should work just fine, even in a C# foreach.
It's just the product of a deranged mind.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I've had code like that crash several times. It seemed kinda hit or miss. Never figured out what happened.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I'm trying to figure out how some code wires up, but it's a spider web. I'll leave all the goodness out and just get right to the point - I'm cruising around through files and notice, upon going to definition, there's an empty interface. I'm in the habbit of cleaning up code, so I remove it. Compilation error. Why ? Because all this stuff implements this interface for no other reason then to be passed around "generically" through the code.......
Elephant elephant elephant, sunshine sunshine sunshine
modified 19-Jul-16 14:52pm.
|
|
|
|
|
|
AVOID using marker interfaces (interfaces with no members).
If you need to mark a class as having a specific characteristic (marker), in general, use a custom attribute rather than an interface.
But who cares about the framework design guidelines?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Except marker interface can be used as constraints in generics...attributes can't.
|
|
|
|
|
yeah, what good does it do, to constrain on empty interface?!
|
|
|
|
|
I think something like Serializable has a meaning to it, so that is a different case. Needing an empty interface just so you can write generic code makes your code base stank. Since these are using in multi-thousand line files, I guess it's only one bit of the problem, but I did say that I was going to skip all the particulars and get strait to the point.
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
I once used a marker interface for some third party component.
The component COULD edit, save, cancel, delete, etc. (through a method named DoAction(string)). If an action was supported was decided by some method ActionSupported(string) or some such.
I created an empty marker interface IThirdPartyComponent, and then interfaces like ISave (with Save method), IEdit (with Edit method) etc. that all inherited IThirdPartyComponent.
That worked a lot better than DoAction(string) and ActionSupported(string), especially since I was able to built some strong typed additional tooling around it
|
|
|
|
|
I think I short circuited my own post by "I'll leave out the goodness and just get to the point". It's possible that this is the marker pattern, although it's not - it's more likely it wasn't intentionally any pattern, just something thrown in to get it working. It's hard to tell though, in the multi-thousand line code files that I'm digging through.
Also, the marker pattern seems to imply[^]
I would argue first-off that Serializable and Cloneable are bad examples of marker interfaces. Sure, they're interfaces with methods, but they imply methods, such as writeObject(ObjectOutputStream). (The compiler will create a writeObject(ObjectOutputStream) method for you if you don't override it, and all objects already have clone(), but the compiler will again create a real clone() method for you but with caveats. Both of these are weird edge cases that really aren't good design examples.)
something like meta-data[^] or methods in many cases.
1) Looking carefully on marker interface in Java e.g. Serializable, Clonnable and Remote it looks they are used to indicate something to compiler or JVM. So if JVM sees a Class is Serializable it done some special operation on it, similar way if JVM sees one Class is implement Clonnable it performs some operation to support cloning. Same is true for RMI and Remote interface. So in short Marker interface indicate, signal or a command to Compiler or JVM.
Read more: http://javarevisited.blogspot.com/2012/01/what-is-marker-interfaces-in-java-and.html#ixzz4Esj4dLCe
I don't feel like what was done here is a good use for that, especially in the junk it's tied up in. If it was intentional, it was done to avoid a good refactor in a steaming pile.
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
What component? That single DoAction method is a horrible design, and any component that uses such patterns goes straight into the trash, never to be looked at or used again.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
It was part of the DevExpress WinForms controls.
It's really not THAT horrible as you have little choice but to use string codes for your UI.
So basically there was this button bar and whenever you clicked a button some component would raise DoAction(string).
I simply wrote a custom component that translated DoAction(string) to Save, Edit, etc.
|
|
|
|
|
I use DevExpress Winforms controls and have never seen that method on any of them.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I don't work for that company anymore, so I haven't done WinForms or DevExpress in a while, but there was this navigation button bar control to which you could hook some IIDontRememberWhat. It was that interface which had the method
|
|
|
|
|
Located the interface (INavigatableControl) and the method now takes a NavigatorButtonType enum as the parameter.
At least it isn't stringly typed anymore.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
In a Project I had to use Marker Interfaces to make base-class varialbes for MEF Imports/Exports "handlable" - some MEF (ManagedExtensibilityFramework) in your Project?
|
|
|
|
|
You could spend all that time defining a way to use JIRA to slow down work, and get more credit and would be easier
|
|
|
|
|
I'm not sure what you're getting at? We use JIRA to make things easier ? I don't really care about gettin credit. I mean, everyone likes credit or being noticed, but I just like to code.
Ravichanadeepakarandescarar wrote: use JIRA to slow down work,
JIRA is a good tool !?!
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
It all depends on the process flow and reduce the number of swivel chairs to reduce siloing resulting from diverged non-constrained islands of excellence as opposed to organization encompassing SME confluences.
|
|
|
|
|
yeah, you sound pretty familiar. I see you just joined.
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
Quote: I'm trying to figure out how some code wires up...
Quote: ...there's an empty interface...
Quote:...Because all this stuff implements this interface... I tell you this. You need subtle knowledge to understand it. Meditate, Hummmmmmm
modified 31-Jul-16 18:47pm.
|
|
|
|