|
I swear English is my native language though I sometimes seem to speak it w/ a slight Polish accent. Maybe that's the cause of the confusion.
|
|
|
|
|
Are you perplexed because he could’ve used Polymorphism via Interfaces and solved this problem?
interface IDataSaver(){
int Save();
}
class InternetSaver : IDataSaver{
String dataToSave;
Int Save(){
}
}
class FileSaver : IDataSaver{
String dataToSave;
Int Save(){
}
}
class DBSaver : IDataSaver{
String dataToSave;
Int Save(){
}
}
List<IDataSaver> allDataSavers = new List<IDataSaver>();
allDataSavers.Add(new InternetSaver());
allDataSavers.Add(new FileSaver());
allDataSavers.Add(new DBSaver());
foreach (IDataSaver ds in allDataSavers){
ds.Save(); }
|
|
|
|
|
Imagine the class diagram.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
CPallini wrote: Imagine the class diagram
You mean in the original situation where he is creating separate classes for each of his switch statements, right?
Yeah, it would get crazy big!
|
|
|
|
|
Exactly!
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Perhaps I should provide the code. I prefer them in the same order as declared in the class not shown as it is a class cTest global variable.
void Random__METHOD()
{
static const int last_case = 96;
auto _case_ = m_cSCALAR_RNG.operator() < int > (0, last_case);
switch(_case_)
{
default: throw einternal_error_eXception;
case 0: Random__default_constructor(); break;
case 1: Random__primordialTimePoint(); break;
case 2: Random__DIAGNOSTIC_SNAPSHOT_HASH(); break;
case 3: Random__recordTermination_time_point_node_spec();
case 4: Random__open_with_arguments(); break;
case 5: Random__open(); break;
case 6: Random__close(); break;
case 7: Random__is_open(); break;
case 8: Random__set_toNascentState(); break;
case 10: Random__swap(); break;
case 11: Random__startTransaction(); break;
case 12: Random__endTransaction(); break;
case 13: Random__cancelTransaction(); break;
case 14: Random__is_activeTransaction(); break;
case 15: Random__activeTransaction_ctransaction_datum(); break;
case 16: Random__is_saved(); break;
case 17: Random__save(); break;
case 18: Random__offset(); break;
case 19: Random__size(); break;
case 20: Random__eofOffset(); break;
case 21: Random__mirror(); break;
case 22: Random__archivesPaths(); break;
case 23: Random__archivesFilenames(); break;
case 24: Random__fullPath(); break;
case 25: Random__fileName(); break;
case 26: if(m_rfe) {} break;
case 27: if(!m_rfe) {} break;
case 28: m_rfe == m_rfe; break;
case 29: m_rfe != m_rfe; break;
case 30: Random__read(); break;
case 31: Random__output(); break;
case 32: Random__delete(); break;
case 33: Random__setOffset(); break;
case 34: Random__incOffset(); break;
case 35: Random__decOffset(); break;
case 36: Random__adjust_eofOffset(); break;
case 37: Random__set_eofOffset(); break;
case 38: Random__initializedIntervals(); break;
case 39: Random__uninitializedIntervals(); break;
case 40: Random__treeEmpty(); break;
case 41: Random__treeSize(); break;
case 42: Random__number_ofUndosAvailable(); break;
case 43: Random__undo(); break;
case 44: Random__redo(); break;
case 45: Random__number_ofRedoBranches(); break;
case 46: Random__undo_node_spec_time_point(); break;
case 47: Random__undo_node_spec_ctransaction_datum(); break;
case 48: Random__undo_node_spec_time_point_vector_cedit_datum(); break;
case 49: Random__redo_node_spec_time_point(); break;
case 50: Random__redo_node_spec_ctransaction_datum(); break;
case 51: Random__redo_node_spec_time_point_vector_cedit_datum(); break;
case 52: Random__redo_node_spec_ctransaction_datum_all(); break;
case 53: Random__current_root_node_spec_time_point(); break;
case 54: Random__current_root_node_spec_ctransaction_datum(); break;
case 55: Random__current_root_node_spec_time_point_vector_cedit_datum(); break;
case 56: Random__terminus_node_spec_time_point(); break;
case 57: Random__terminus_node_spec_ctransaction_datum(); break;
case 58: Random__terminus_node_spec_time_point_vector_cedit_datum(); break;
case 59: Random__current_node_spec_time_point(); break;
case 60: Random__currentSessionIdentifier(); break;
case 61: Random__LIST_per_predicate(); break;
case 62: Random__REMOVE_per_list(); break;
case 63: Random__REMOVE_undos(); break;
case 64: Random__REMOVE_undo_branches(); break;
case 65: Random__REMOVE_redos(); break;
case 66: Random__REMOVE_sub_tree(); break;
case 67: Random__REMOVE_per_list(); break;
case 68: Random__REMOVE_undos(); break;
case 69: Random__REMOVE_undo_branches(); break;
case 70: Random__REMOVE_redos(); break;
case 71: Random__REMOVE_sub_tree(); break;
case 72:Random__NAVIGATE_to_nil_root(); break;
case 73:Random__NAVIGATE_to_root(); break;
case 74:Random__NAVIGATE_to_root_branch(); break;
case 75:Random__NAVIGATE_branch(); break;
case 76:Random__NAVIGATE_forward_route(); break;
case 77:Random__NAVIGATE_backward_route(); break;
case 78:Random__NAVIGATE_to_node_spec(); break;
case 79:Random__NAVIGATE_to_node_spec_root(); break;
case 80:Random__NAVIGATE_to_node_spec_branch(); break;
case 81:Random__NAVIGATE_to_node_spec_forward_route_terminus(); break;
case 82:Random__NAVIGATE_to_node_spec_backward_route_terminus(); break;
case 83:Random__NAVIGATE_to_canonical_route_terminus(); break;
case 84:Random__STEP_to_nil_root(); break;
case 85:Random__STEP_to_root(); break;
case 86:Random__STEP_to_root(); break;
case 87:Random__STEP_branch(); break;
case 88:Random__STEP_forward_route(); break;
case 89:Random__STEP_backward_route(); break;
case 90:Random__STEP_to_node_spec(); break;
case 91:Random__STEP_to_node_spec_root(); break;
case 92:Random__STEP_to_node_spec_branch(); break;
case 93:Random__STEP_to_node_spec_forward_route_terminus(); break;
case 94:Random__STEP_to_node_spec_backward_route_terminus(); break;
case 95:Random__STEP_to_canonical_route_terminus(); break;
case 96:Random__delete__count(); break;
}
}
|
|
|
|
|
Huh ?
You have performance issues on a switch that you need to re-order the case statements ?
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
The performance issue was re/ my fingers re-editing the lengthy list of case statements. Fortunately awk will from now on do it for me.
|
|
|
|
|
Why are you reordering the switch, exactly? Performance issues?
If so, you might get a lot more mileage out of using compiler specific extensions to implement a pure jump table out of it.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Maybe relying on fall through?
|
|
|
|
|
Yikes.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
yikes, indeed, like a cliff.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
I was trying to get DMA transfers working on the Seeed Wio Terminal. It's based on a SAMD51 MCU which itself is wrapped around an ARM Cortex M4 platform.
The trick is there are 8x2 DMA registers you need to fiddle with depending on which peripheral you want to control, and I had no information as to what mapped where.
I love VS Code "Go to Definition..." as it allowed me to traverse through the Wio Terminal's Arduino implementation until I found the registers it used for SPI3.
SERCOM7 was my huckleberry
And now I'm super satisfied that I figured that out, and got my data to the screen asynchronously.
It feels like hacking old Apple computers back in the mid 1980s, at least for me.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
In this day and age where everything is nice and pretty much wrapped up with a bow, it's cool that you have to / get to fiddle with the low level stuff that is more satisfying dragon to tame.
|
|
|
|
|
I submit that it's just as satisfying when you get things working with the help of properly documented registers, it's probably a faster implementation as well.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
"SERCOM7 was my huckleberry"
Old west expression of "I like it because it works."
Had not heard that expression in a long time.
BTW. Actual Huckleberry Jam and Preserves is quite good with a very unique flavor.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Wordle 1,138 4/6
⬜⬜⬜🟨⬜
🟩⬜⬜🟩🟩
🟩⬜⬜🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,138 3/6*
⬜⬜⬜⬜🟩
⬜🟨⬜⬜🟩
🟩🟩🟩🟩🟩
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
⬜⬜⬜🟩🟩
⬜🟨⬜🟩🟩
🟩🟩🟩🟩🟩
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 1,138 5/6
⬜🟨⬜🟩🟩
🟩⬜⬜🟩🟩
🟩⬜⬜🟩🟩
🟩⬜🟨🟩🟩
🟩🟩🟩🟩🟩
Within you lies the power for good - Use it!
|
|
|
|
|
Wordle 1,138 4/6
⬜⬜⬜🟩⬜
⬜⬜⬜🟩🟩
⬜⬜⬜🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1.138 4/6
🟨⬛⬛⬛⬛
⬛⬛⬛🟩⬛
⬛⬛⬛🟩🟩
🟩🟩🟩🟩🟩
GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
The shortest horror story: On Error Resume Next
|
|
|
|
|
Wordle 1,138 4/6*
🟩⬜⬜⬜🟩
🟩⬜⬜⬜🟩
🟩⬜⬜⬜🟩
🟩🟩🟩🟩🟩
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
Wordle 1,138 6/6
⬛⬛⬛⬛🟩
⬛⬛⬛⬛🟩
⬛⬛⬛⬛🟩
⬛⬛⬛⬛🟩
🟩🟩⬛⬛🟩
🟩🟩🟩🟩🟩
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 1,138 3/6*
⬛⬛⬛🟩🟩
🟩⬛⬛🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|