Last post May 22, 2017 04:58 AM by PaulTheSmith
May 19, 2017 05:59 PM|trev52|LINK
I'm in the process of converting some PHP code to C# and ran into an issue with an associative array. I've been converting them all to dictionaries but haven't had any luck with this code. I know this is a C# forum so don't know if anyone will be able to
help converting PHP code but thought I would try.
foreach ( $load_items as $k=>$v )
if ( ($row_item=include_menu_item($v['key'],$force_sc_code)) )
May 19, 2017 08:24 PM|march11|LINK
Probably not the answer your looking for. I have had a bit of success just dumping to an XML then importing with C#.
May 22, 2017 04:58 AM|PaulTheSmith|LINK
Still not the answer you are looking for but ...
Doing a straight conversion from one language to another is a very, very bad thing to do. Not only do you get the bugs from the original code, you introduce new bugs by incorrect translations, your code will be harder to understand because it will attempt
to follow (translated) idioms from the other language. Ever heard of Chinese Whispers?
Try to understand what the code does from a business perspective or a black box perspective, not an IT/code perspective. What is the "big picture" of the problem that this code is trying to solve? When you have worked out what the purpose of the code is
then you know what the code is required to do. Now, write a program which implements that requirement.
It sounds like more work but in the long run it is actually much quicker and gives a better result which stands a chance of delivering what is actually required.