|
I used to work with a framework that lived off of that. Piles of magic numbers, created by a mechanical engineer of course.
Worked well enough so long as you had the right spreadsheets printed out and wallpapered your cube with them, I assume you have no such spread sheets.
|
|
|
|
|
Didn't they give you the secret decoder ring?
|
|
|
|
|
It looks like the coder had asked "how to storr datas inside from classes plz help its urgent" on some forum but nobody answered him, so he/she put app data in invisible areas of caption texts. If it is true then try
lblpnl10(0).AutoSize = True
Greetings - Jacek
|
|
|
|
|
I think he may have worked for us.
But I must say that he seems to have improved with time.
|
|
|
|
|
We had a contract programmer do some work for us recently. Alas, he was hired by the Pointy Haired One, so this month I get to go over his work and correct errors. Among the steaming pile, I found this nugget:
RunTSMenuItem.Enabled = CBool(IIf(MyUser.HasPermission(Permission.Admin), True, False))
When a user logs into the application, an instance of MyUser is created with all of the user's permissions (among other data.) HasPermission(Permission.whatever) will return true if the user has the requested permission and false otherwise. The above code activates a menu item on a form if the user is an administrator, otherwise the menu item is inactive.
Unfortunately, this guy was overly fond of IIf and used it every opportunity he could, whether needed or not.
|
|
|
|
|
That's a mighty nice turd you found there
|
|
|
|
|
I'm converting an MS Access app to C# & SQL Server. Here's part of an Access query I just came across:
IIf(TX.TX_TYPE="R",
IIf(TX.TX_MOSTYPE="P",
IIf(TX.TX_DEST_STATUS="A","PO Receipt",
IIf(TX.TX_DEST_STATUS="U","PO Receipt Hold","Other")),
IIf(TX.TX_DEST_STATUS="A","WIP Receipt",
IIf(TX.TX_DEST_STATUS="U","WIP Hold","Other"))),
IIf(TX.TX_TYPE="I",IIf(ISNULL(RTRIM(TX.TX_MOSJOB)) Or RTRIM(TX.TX_MOSJOB)="","Shipment Return","Reverse Issue"),
IIf(TX.TX_ORIGIN_STATUS=TX.TX_DEST_STATUS,"Loc Transfer",
IIf(TX.TX_ORIGIN="SCRAPPED","Reverse Scrap",
IIf(TX.TX_ORIGIN_STATUS="J","Count Adj Up",
IIf(TX.TX_ORIGIN_STATUS="D","PN Change To",
IIf(TX.TX_ORIGIN_STATUS="I","Reverse Unplanned Issue",
IIf(TX.TX_ORIGIN_STATUS="A" And TX.TX_DEST_STATUS="U","Hold",
IIf(TX.TX_ORIGIN_STATUS="U" And TX.TX_DEST_STATUS="A","Off Hold","Other"))))))))) AS [Transaction Type]
You'll notice that
TX.TX_DEST_STATUS="A" is being evaluated more than once.
Go figure
Everything makes sense in someone's mind
moved on Thursday, January 28, 2010 7:54 AM
|
|
|
|
|
I think step 1 is to delete it and then ask what the original intention was.
|
|
|
|
|
This is where you write a bank of unit tests, based on the input/output of this clause.
Then refactor ensuring all tests keep passing.
|
|
|
|
|
With a bit of formatting, it makes 'more' sense:
IIf
(TX.TX_TYPE="R",
IIf
(TX.TX_MOSTYPE="P",
IIf
(TX.TX_DEST_STATUS="A",
"PO Receipt",
IIf
(TX.TX_DEST_STATUS="U",
"PO Receipt Hold",
"Other"
)
),
IIf
(TX.TX_DEST_STATUS="A",
"WIP Receipt",
IIf
(TX.TX_DEST_STATUS="U",
"WIP Hold",
"Other"
)
)
),
IIf
(TX.TX_TYPE="I",
IIf
(ISNULL(RTRIM(TX.TX_MOSJOB)) Or RTRIM(TX.TX_MOSJOB)="",
"Shipment Return",
"Reverse Issue"
),
IIf
(TX.TX_ORIGIN_STATUS=TX.TX_DEST_STATUS,
"Loc Transfer",
IIf(TX.TX_ORIGIN="SCRAPPED",
"Reverse Scrap",
IIf
(TX.TX_ORIGIN_STATUS="J",
"Count Adj Up",
IIf
(TX.TX_ORIGIN_STATUS="D",
"PN Change To",
IIf
(TX.TX_ORIGIN_STATUS="I",
"Reverse Unplanned Issue",
IIf
(TX.TX_ORIGIN_STATUS="A" And TX.TX_DEST_STATUS="U",
"Hold",
IIf
(TX.TX_ORIGIN_STATUS="U" And TX.TX_DEST_STATUS="A",
"Off Hold",
"Other"
)
)
)
)
)
)
)
)
) AS [Transaction Type]
Granted, nesting like this just makes it impossible to read without a gratuitous use of formatting. The original query was just not very consistent in its usage of formatting it. The above was the best I could come up with to be able to read it effectively....
|
|
|
|
|
Btw, this looks more like a coding horror than 'wicked code'.
|
|
|
|
|
It's in the coding horrors section. Or was the topic moved later with all the replies? I didn't think it was possible to do so in codeproject.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
I was able to clean it up a bit more, although it took awhile.
CASE WHEN TX.TX_TYPE = 'R' AND TX.TX_MOSTYPE = 'P' AND TX.TX_DEST_STATUS = 'A' THEN 'PO Receipt'
WHEN TX.TX_TYPE = 'R' AND TX.TX_MOSTYPE = 'P' AND TX.TX_DEST_STATUS = 'U' THEN 'PO Receipt Hold'
WHEN TX.TX_TYPE = 'R' AND TX.TX_MOSTYPE = 'P' THEN 'Other'
WHEN TX.TX_TYPE = 'R' AND TX.TX_DEST_STATUS = 'A' THEN 'WIP Receipt'
WHEN TX.TX_TYPE = 'R' AND TX.TX_DEST_STATUS = 'U' THEN 'WIP Hold'
WHEN TX.TX_TYPE = 'R' THEN 'Other'
WHEN TX.TX_TYPE = 'I' AND ISNULL(RTRIM(TX.TX_MOSJOB),'') = '' THEN 'Shipment Return'
WHEN TX.TX_TYPE = 'I' THEN 'Reverse Issue'
WHEN TX.TX_ORIGIN_STATUS = TX.TX_DEST_STATUS THEN 'Loc Transfer'
WHEN TX.TX_ORIGIN = 'SCRAPPED' THEN 'Reverse Scrap'
WHEN TX.TX_ORIGIN_STATUS = 'J' THEN 'Count Adj Up'
WHEN TX.TX_ORIGIN_STATUS = 'D' THEN 'PN Change To'
WHEN TX.TX_ORIGIN_STATUS = 'I' THEN 'Reverse Unplanned Issue'
WHEN TX.TX_ORIGIN_STATUS = 'A' AND TX.TX_DEST_STATUS = 'U' THEN 'Hold'
WHEN TX.TX_ORIGIN_STATUS = 'U' AND TX.TX_DEST_STATUS = 'A' THEN 'Off Hold' ELSE 'Other'
END AS Transaction_Type
Everything makes sense in someone's mind
|
|
|
|
|
Nice to see people with some extra time on their hands
Learning without thought is labor lost; thought without learning is perilous. (Confucius)
|
|
|
|
|
It looks like Linq, pre-Linq.
Marc
|
|
|
|
|
I've seen Garbage like this before, it usually happens when engineers pretend to be programmers...
I laugh at inappropriate times
|
|
|
|
|
As you wrote: Everything makes sense in someone's mind
-muneeb
A thing of beauty is the joy forever.
|
|
|
|
|
Looks to me like a repeated event of technically challenged boss entering the room of a stressed halfwit programmer shouting: We need to add this NOW!
|
|
|
|
|
Holy sh*t...thats just horrific man. as long as I don't encounter that ever!
|
|
|
|
|
This dude is clearly a Lisp-genius, stuck with the wrong programming languge. What a pity!
........................
Life is too shor
|
|
|
|
|
I think he meant to make a Ladder; Only that it's lying on the wrong wall
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
So I am not sure if this is my "worst practices" or MS'. If you start a process (console app) which makes a call to Console.WindowWidth from C# (3.5) Process object, it crashes. I guess, I'm removing my fancy console screen formatting--for automated system testing, at least.
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "DummyTest.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
namespace DummyTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world! My window is this wide:");
Console.WriteLine(Console.WindowWidth.ToString());
}
}
}
|
|
|
|
|
That makes sense because you're piping its IO (.RedirectStandardXxx = true ), so it is not connected to the console, just your starting program.
I have confirmed this by replicating your exception (in VB.NET) and then only changing to
.RedirectStandardOutput = False
and there is then no error, but it may of course not be the functionality you need.
Regards,
Mark Hurd, B.Sc.(Ma.) (Hons.)
|
|
|
|
|
Ahh... and it is by design. A little further reading indicates that when redirecting io the underlying io and error streams Console object has NOTHING to do with the console screen that might be displayed albeit blank. This was lost on me initially.
Console class members that work normally when the underlying stream is directed to a console might throw an exception if the stream is redirected, for example, to a file. Consequently, program your application to catch System.IO..::.IOException if you redirect a standard stream.
http://msdn.microsoft.com/en-us/library/system.console.aspx[^]
|
|
|
|
|