|
If my code works right you will never have to see it unless you want to debug a parser generator.
I provide it public because i provide the "math" for all of my code in this publically. Theoretically you could use it like Mathematica or JFLAP but in practice you don't need the stuff.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I have to agree with Nathan here. Your code may be hidden from the casual user, but that's not really the point. If you used an interface rather than a concrete type it would lead to more flexible code. As it is, it's rather brittle and not very readable.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
if you saw the rest of the code you might change your mind. If I did that here, I'd have like 40 other places I'd also need to declare a one off type.
no. just no.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
codewitch honey crisis wrote: I'd have like 40 other places I'd also need to declare a one off type. That's part of the problem with the approach here.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
Then the problem is the math, I guess. It's really heavy on tuples.
Such is the nature of context-free parsing.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Nathan Minier wrote: Psst...it's much less grating if you make your default assignment properly in the first place.
Except default parameter values have to be compile-time constants, so that won't work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Bah, stop with your correctness!
I'ma have some more coffee.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Nathan Minier wrote: public IRuleSymbolCollection
Always have an interface with a name starting with IRule . Every time you use it, say out loud "I Rule" - that should boost your self esteem.
There must be other good interface names, e.g. IRockPaperScissors (say "I Rock")
|
|
|
|
|
heh. yeah. except every time i think i rule the code shows me i'm still subordinate to the gods of the debugger.
But yeah i-interfaces in this code would be spurious at best.
that's not true of the runtimes component but i use abstract base classes instead of interfaces there, for reasons
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
What's the point of declaring collections for everything when I have generics for collections?
that was primary time saver moving from .NET 1.x to 2.0
I'm not going back.
I'd add, there's no reason for I-interfaces to be declared in this code.
There's no justification for it whatsoever.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
codewitch honey crisis wrote:
if (null == result)
A fan of these "Yoda conditionals" I also used to be, hmmm, yes.
But with C# 7, I now prefer:
if (result is null)
If the null-coalescing assignment operator[^] makes it into C# 8, this line could be further simplified to:
result ??= new Dictionary<string, ICollection<(CfgRule Rule, string Symbol)>>();
Add in target-typed new expressions[^], and you can really annoy the var haters with:
result ??= new();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I love var but some of what you posted is too much. C# 12 will end up looking like perl at this rate. :/
I'm a fan of yoda conditionals for two reasons:
The first is old habits from back when compilers were more primitive (preventing accidental assignment)
The second is I've found that if you must use a series of ifs on the same target value it is easier to visualize what you're doing when the target is on the left hand side. For example
if("foo"==target)
else if("bar"==target)
else if("baz"==target)
that one obv is simple and can be changed to a switch but once you start adding || and && in there and breaking each subcomparison out on it's own line the difference is clear. yodaized looks better in the source in terms of figuring out what you're doing. The target being on the right makes it less distracting
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I agree. It started as the same old habit to avoid accidental assignment, but I got used to it and still like it.
if (null == target) seems to make much more sense than if (target == null).
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
This gets so much prettier in F#, where IDictionary<string,ICollection<(CfgRule Rule,string Symbol)>> simply becomes a type, like "RuleMap"
|
|
|
|
|
amen.
i'm half tempted to use linq but a lot of my queries wouldn't be much easier with linq.
the big thing is the typedefs. Even a more intelligent "using" would be helpful here.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
A woman who taunts herself - you're attempting to draw me into soapbox quality material.
A definition that is, for some, an epiphany:
"Smut: The Stuff that Dreams are Made Of !"
(I warned you !)
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
haha. don't worry, I'm not your type. you're not gay.
i get mistaken for a woman all the time. IRL and online.
it's part of my aesthetic.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
If you can't even understand simple computer grammar yet, what chances do have men and women to understand each other?!
|
|
|
|
|
it's clearly hopeless =)
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
The simple answer to avoiding these things is to keep your code simple. The code you show there is complex, you are doing a lot on a single line. I know that grade-schools promote this, but it is not really that ideal when it comes to debugging.
|
|
|
|
|
Unfortunately the math behind it is really complex complicated*. I've figured most of it out by now.
*(A pet peeve of mine - complex and complicated are very different)
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
When the pun is not intended: Phrases that people get wrong[^]
Damp squids, indeed!
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
It started well, but then got silly. Just seems like made up article filler for the most part.
I mean, I can't imagine anybody has every said "Taken for granite"... well, at least not anyone that actually speaks English.
|
|
|
|
|
err, maybe not in UK, USA, Aus...
but in Asia (including countries like Singapore where English is the [first] official language) I've seen those mistakes, more and worse.
Message Signature
(Click to edit ->)
|
|
|
|
|
True, I have heard it used by some French and Belgians & French speaking Canadian, but not by a native (UK, USA, New-Zeland, Oz etc.) Interestingly the 'Jack Of All Trades' the quote Jack of All Trades master of none. I always understood it as 'Jack Of All Trades, master of none, more use than master of one'...
modified 18-Jul-19 10:44am.
|
|
|
|