One of the very few times I find myself liking Ruby/Rails syntax
-
Did you read what I wrote to the end? Every time I've done reflection it ends up becoming a footgun at some point in the future; and for what amounts to a single pass over the scores loading/unloading into arrays is just as verbose as accessing everything once directly.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
ah I did read to the end but skimmed over that part. :-O My bad. :-\ :^) Yeah, maybe I should just shut-up. :D
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Or start with an array? Section1Answers VARCHAR(N) Then just parse/count and iter. Less of a mess in the DB?
Maybe. Not sure what he's trying to accomplish. Maybe a table with question and answer columns?
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
My first was "reflection" as well, but then I read what you wrote at the end :laugh: I don't think reflection could hurt here though. It's just a small piece with a clear function. It wouldn't be much different than how Ruby solves it, which is calling the member using a literal string. It could go wrong if your naming convention changes or if someone added QuestionXSectionYAnswer (switching Question and Section), but that goes for the Ruby code as well.
Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
Sander Rossel wrote:
It wouldn't be much different than how Ruby solves it, which is calling the member using a literal string.
I know the feature in ruby works because its hashes all the way down (until you get to the pipe were the designers smoke it anyway); but the hackiness there is a core language feature not a gun that shoots bullets in multiple directions with every trigger pull only more dangerous.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
Sander Rossel wrote:
It wouldn't be much different than how Ruby solves it, which is calling the member using a literal string.
I know the feature in ruby works because its hashes all the way down (until you get to the pipe were the designers smoke it anyway); but the hackiness there is a core language feature not a gun that shoots bullets in multiple directions with every trigger pull only more dangerous.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
I see your point, but I'd still recommend reflection. Although typing out this stuff once isn't such a big deal either. writing a reflection solution probably costs you as much time as writing it out. The only reason to use reflection is because it's more fun to write :D
Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
-
I see your point, but I'd still recommend reflection. Although typing out this stuff once isn't such a big deal either. writing a reflection solution probably costs you as much time as writing it out. The only reason to use reflection is because it's more fun to write :D
Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
I generated the 1 off code. Used a mix of typing and excel copydown to generate the numbers and then regexed the code I wanted out.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
I'm replacing a ruby on rails site with C#/mvc. For the most part it's a complete rewrite because of problems with the site being scrapped. There're occasional parts where some logic is worth a directish port though. One is scoring standardized tests. I've got a test responses table full of columns like:
Section1Question1Answer CHAR(1),
Section1Question2Answer CHAR(1),
...
Section1Question5Answer CHAR(1),
Section2Question1Answer CHAR(1),
Section2Question2Answer CHAR(1),
...
Section13Question5Answer CHAR(1),The ruby code is then able to access the data like:
for section in 1..SECTION_COUNT
for question in 1..QUESTION_COUNT
test_to_score["Section{section}Question{question}Answer"] #do stuff
end
end:cool: In C# I'm stuck with accessing them 1 at a time
TestToScore.Section1Question1Answer //do stuff TestToScore.Section1Question2Answer //do stuff //... repeat 63 more times.
X| I'm not doing enough processing for load/unloading temp arrays to be worthwhile, and every time I've thought to myself that reflection would be a good way to solve a problem I've ended up regretting it. :sigh: Redoing the DB to store a single answer/row instead of a test attempt/row would just change where the pain points are; and since the test will always be M sections of N questions each keeping the entire response together is a lot simpler.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Quote:
Section1Question1Answer CHAR(1),
X| Why can't you do a table with:
SectionNumber int
QuestionNumber int
Answer char(1)?
Latest Articles:
16 Days: A TypeScript application from concept to implementation Database Transaction Management across AJAX Calls -
I'm replacing a ruby on rails site with C#/mvc. For the most part it's a complete rewrite because of problems with the site being scrapped. There're occasional parts where some logic is worth a directish port though. One is scoring standardized tests. I've got a test responses table full of columns like:
Section1Question1Answer CHAR(1),
Section1Question2Answer CHAR(1),
...
Section1Question5Answer CHAR(1),
Section2Question1Answer CHAR(1),
Section2Question2Answer CHAR(1),
...
Section13Question5Answer CHAR(1),The ruby code is then able to access the data like:
for section in 1..SECTION_COUNT
for question in 1..QUESTION_COUNT
test_to_score["Section{section}Question{question}Answer"] #do stuff
end
end:cool: In C# I'm stuck with accessing them 1 at a time
TestToScore.Section1Question1Answer //do stuff TestToScore.Section1Question2Answer //do stuff //... repeat 63 more times.
X| I'm not doing enough processing for load/unloading temp arrays to be worthwhile, and every time I've thought to myself that reflection would be a good way to solve a problem I've ended up regretting it. :sigh: Redoing the DB to store a single answer/row instead of a test attempt/row would just change where the pain points are; and since the test will always be M sections of N questions each keeping the entire response together is a lot simpler.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Or you could go old school - DataTable!
table.Columns[$"Section{section}Question{question}Answer"]
Latest Articles:
16 Days: A TypeScript application from concept to implementation Database Transaction Management across AJAX Calls -
I'm replacing a ruby on rails site with C#/mvc. For the most part it's a complete rewrite because of problems with the site being scrapped. There're occasional parts where some logic is worth a directish port though. One is scoring standardized tests. I've got a test responses table full of columns like:
Section1Question1Answer CHAR(1),
Section1Question2Answer CHAR(1),
...
Section1Question5Answer CHAR(1),
Section2Question1Answer CHAR(1),
Section2Question2Answer CHAR(1),
...
Section13Question5Answer CHAR(1),The ruby code is then able to access the data like:
for section in 1..SECTION_COUNT
for question in 1..QUESTION_COUNT
test_to_score["Section{section}Question{question}Answer"] #do stuff
end
end:cool: In C# I'm stuck with accessing them 1 at a time
TestToScore.Section1Question1Answer //do stuff TestToScore.Section1Question2Answer //do stuff //... repeat 63 more times.
X| I'm not doing enough processing for load/unloading temp arrays to be worthwhile, and every time I've thought to myself that reflection would be a good way to solve a problem I've ended up regretting it. :sigh: Redoing the DB to store a single answer/row instead of a test attempt/row would just change where the pain points are; and since the test will always be M sections of N questions each keeping the entire response together is a lot simpler.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
If this thread does not end up in a lecture about the billionth other possibilities how you could have done it better in C#, this is not a coding forum anymore. :rolleyes: I love this kind of threads: Q: "- Hey guys, I am using X to do Y, and I would need to know how I could do Z" A1:"- Why are you using X to do Y ? W is much better". A2:"- Wow, I would never use X that way. Plus Y is not recommended by [book you have never heard of, but obviously should have]. Maybe you should consider switching technologies" ... A187273:"- No wonder that we have flat-earthers bitching about global warming criticizing vegans that do not believe in the moon landing if you do Y by using X". :-D
-
I'm replacing a ruby on rails site with C#/mvc. For the most part it's a complete rewrite because of problems with the site being scrapped. There're occasional parts where some logic is worth a directish port though. One is scoring standardized tests. I've got a test responses table full of columns like:
Section1Question1Answer CHAR(1),
Section1Question2Answer CHAR(1),
...
Section1Question5Answer CHAR(1),
Section2Question1Answer CHAR(1),
Section2Question2Answer CHAR(1),
...
Section13Question5Answer CHAR(1),The ruby code is then able to access the data like:
for section in 1..SECTION_COUNT
for question in 1..QUESTION_COUNT
test_to_score["Section{section}Question{question}Answer"] #do stuff
end
end:cool: In C# I'm stuck with accessing them 1 at a time
TestToScore.Section1Question1Answer //do stuff TestToScore.Section1Question2Answer //do stuff //... repeat 63 more times.
X| I'm not doing enough processing for load/unloading temp arrays to be worthwhile, and every time I've thought to myself that reflection would be a good way to solve a problem I've ended up regretting it. :sigh: Redoing the DB to store a single answer/row instead of a test attempt/row would just change where the pain points are; and since the test will always be M sections of N questions each keeping the entire response together is a lot simpler.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Do not discount Reflection solely based on the fact that you weren't able to make good use of it previously. It has amazing powers but should not be your first choice, usually.
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
-
Quote:
Section1Question1Answer CHAR(1),
X| Why can't you do a table with:
SectionNumber int
QuestionNumber int
Answer char(1)?
Latest Articles:
16 Days: A TypeScript application from concept to implementation Database Transaction Management across AJAX CallsWay too much refactoring for the potential benefit; even before data migration and fighting with a CI system that chokes on anything it thinks might be a lossy DB change (a separate issue entirely).
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt