Click here to Skip to main content
14,663,182 members
Home » Discussions » C#
   

C#

 
QuestionConverting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 3:52
MemberExoskeletor2-Jun-20 3:52 
AnswerRe: Converting InAppBilling.Plugin to Amazon Pin
OriginalGriff2-Jun-20 4:38
mveOriginalGriff2-Jun-20 4:38 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 4:56
MemberExoskeletor2-Jun-20 4:56 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
OriginalGriff2-Jun-20 5:18
mveOriginalGriff2-Jun-20 5:18 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 7:40
MemberExoskeletor2-Jun-20 7:40 
AnswerRe: Converting InAppBilling.Plugin to Amazon Pin
Kris Lantz2-Jun-20 9:13
professionalKris Lantz2-Jun-20 9:13 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 9:24
MemberExoskeletor2-Jun-20 9:24 
QuestionState machine performance woes in .NET Pin
Member 79891222-Jun-20 3:04
MemberMember 79891222-Jun-20 3:04 
This is a followup to a thread started in the Lounge: The Lounge[^]

First this makes me think of The First Law Of Optimization: Don't do it!
And then The Second Law of Optimzation: If you have to do it, don't do it yet!

This obvuiouly refers to peephole optimzation. Selecting an algorithm of lower complexity is a different matter. But worrying about how the switch construct is handled by the compiler falls in the peephole class.

When I programmed Pascal around 1980, the compiler knew a single way of coding CASE x OF statements: As a jump table with at most 256 entries. Or more exactly: Alternatives was limited to internal values 0..255. Fair enough for small student exercises, but for real code, it was just tooo limiting.

Then I got into CHILL with its decision table entries ("CASE A, B, C OF ...", with all combinations of A, B, C values, with "don't care" and ELSE and the whole works - but still static). Later comes C# with much greater flexibility. Bottom line: Tiny jump tables is a very special case. You may hope for the compiler to optimize for that particular one, but I wouldn't spend too much energy on it. In the world of modern code, it is just too special.

Then there is another thing, now that you refer to state machines: I don't believe that switch statements is a good way to implemnent state machines. Maintenance is resource demanding when you expand it with new states and events. Giving proper handling to illegal events is difficult. And any reasonably complete state machine, e.g. for a communication protocol, will have a rather sparse state table.

If you implement a sparse 2D transition table by a jump table for one dimension, each leading to a jump table in the other dimension, you implemenent that full, sparse table in a rather un-maintainable way. I would rather pack the table, and address it as a single table. So you would maintain the table in an unpacked form, and use a small compaction routine to build the runtime table when you change it.

I let the compaction routine generate the table access function as well, so that a simple table not requiring e.g. predicate handling for alternate actions will not have this access code generated.

I guess my code is not super-optimized to those tiny demo-examples to teach students the basic idea of an FSM. But if you really need the functionality of a full blown solution, then I can handle it with sufficient speed that the table lookup is certainly not a bottleneck.

State tables are tables, not "cases". Treat them as such!
AnswerRe: State machine performance woes in .NET Pin
Member 79891222-Jun-20 3:41
MemberMember 79891222-Jun-20 3:41 
GeneralRe: State machine performance woes in .NET Pin
F-ES Sitecore2-Jun-20 4:08
mveF-ES Sitecore2-Jun-20 4:08 
QuestionProblem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
Member 1467808531-May-20 6:47
MemberMember 1467808531-May-20 6:47 
AnswerRe: Problem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
OriginalGriff31-May-20 20:34
mveOriginalGriff31-May-20 20:34 
QuestionMulti threading in C# Pin
bjwaldo28-May-20 9:21
Memberbjwaldo28-May-20 9:21 
AnswerRe: Multi threading in C# Pin
JudyL_MD28-May-20 10:45
MemberJudyL_MD28-May-20 10:45 
AnswerRe: Multi threading in C# Pin
F-ES Sitecore29-May-20 1:17
mveF-ES Sitecore29-May-20 1:17 
GeneralRe: Multi threading in C# Pin
bjwaldo30-May-20 7:30
Memberbjwaldo30-May-20 7:30 
QuestionLinq TO SQL - Pass Table Name Pin
Kevin Marois28-May-20 8:57
professionalKevin Marois28-May-20 8:57 
AnswerRe: Linq TO SQL - Pass Table Name Pin
Richard Deeming29-May-20 0:11
mveRichard Deeming29-May-20 0:11 
QuestionC# How To Get Version Info Of exe in FTP Pin
Ertuğrul ÇİÇEK28-May-20 3:16
MemberErtuğrul ÇİÇEK28-May-20 3:16 
AnswerRe: C# How To Get Version Info Of exe in FTP Pin
Richard MacCutchan28-May-20 3:19
mveRichard MacCutchan28-May-20 3:19 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Ertuğrul ÇİÇEK28-May-20 3:41
MemberErtuğrul ÇİÇEK28-May-20 3:41 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Richard MacCutchan28-May-20 3:43
mveRichard MacCutchan28-May-20 3:43 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Richard Deeming28-May-20 3:53
mveRichard Deeming28-May-20 3:53 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
OriginalGriff28-May-20 3:57
mveOriginalGriff28-May-20 3:57 
GeneralRe: C# How To Get Version Info Of exe in FTP Pin
Ertuğrul ÇİÇEK28-May-20 6:32
MemberErtuğrul ÇİÇEK28-May-20 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.