|
When I started Uni, we were told we had to have meaningful identifiers. This was back in the punched card days (80 cols per card). So, as a silent protest, I wrote my Assessed Practical Work with every identifier being exactly 80 chars long. This mean that each identifier took a whole punched card and made the program unintelligible as it was impossible to use indentation. (It had one good benefit - I could just duplicate the cards with identifiers and slot them into the source deck as required, so I only had to type them once). I passed the Assessed Practical Work as the program worked and it had meaningful identifiers, but they were not amused.
P.S. Language was Algol60 - one of the few languages that allowed spaces in identifiers - that helped make them meaningful but the code even less straight forward to read.
modified 6-May-21 4:34am.
|
|
|
|
|
At these days, we were working in PL1, which allowed free format, like C, with columns 9-72 of every card filled with a code. One programmer from our team liked to fill all this area with a code. Probably to save punched cards. To fix a bug, he needed to retype everything from the buggy card to the end. He didn't like a bugs in the beginning.
|
|
|
|
|
What's "PIC"? Surely some acronym - and I do not understand it. Please write it out!
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
By gosh, you're right! Sadly it's such a part of our vocabulary (pronounced, er, "pick"), I don't even remember what it's an acronym of. If I had to guess, it would be "Printhead Interface Controller", which would then make the proper identifier
Connect_catcher_line_to_PrintheadInterfaceController_ink_port__Connect_duct_line_to_PrintheadInterfaceController_storage_port__Then_Step_Up I deliberately didn't replace the spaces in "Printhead Interface Controller" with underscores in order to emphasize that "PrintheadInterfaceController" is a component name.
Software Zen: delete this;
|
|
|
|
|
Or Programmable Integrated Circuit? What does PIC stand for?[^] agrees, but also has Programmable Interrupt Controller and Peripheral Interface Controller and dozens of non-IT meanings.
Take your pic(k).
“When I use a word,’ Humpty Dumpty said in rather a scornful tone, ‘it means just what I choose it to mean — neither more nor less.’
’The question is,’ said Alice, ‘whether you can make words mean so many different things.’
’The question is,’ said Humpty Dumpty, ‘which is to be master — that’s all.”
― Lewis Carroll, Through the Looking Glass
|
|
|
|
|
In this case it's actually a board within our commercial ink-jet printer products. It accepts print data via a fiber optic connection and parcels it out to one or more arrays of jets. Depending upon configuration, we print somewhere around 1 billion (109) drops of ink per second, where each drop is around 6-9 picoliters.
Our marketing created an interesting visual a while back. If each of our drops of ink were the size of a drop of rain, we dump an Olympic swimming pool every second.
Software Zen: delete this;
|
|
|
|
|
Can the ink jets be directed so the user gets sprayed in the face?
|
|
|
|
|
Well, no. Ink-jet can get messy, however. Most of the bathrooms include a dispenser for a product called "Dye Gone" to get ink off your hands.
A well-known incident occurred some years ago when an upper-level executive was being given the grand tour of some of our labs. A piece of tubing cut loose and sprayed the guy with a head-to-feet stream of yellow ink. We bought him a new suit.
Software Zen: delete this;
|
|
|
|
|
Wow! That puts it into perspective.
|
|
|
|
|
C/mainarray.c at master · dequbed/C · GitHub[^]
I... uh...
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
|
That was a thing of beauty. Duff's device to the next level.
Duff's device - Wikipedia[^]
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
|
|
|
|
|
Pardon me for being a tad dense, but... is that somehow a hand-assembled main() function, encoded in oh-so-useful decimal?
Software Zen: delete this;
|
|
|
|
|
Pretty much.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
To coin a phrase: "Kill it before it runs."
Even if something like that were technically necessary (I could see it in embedded code), an array of completely undocumented random decimal integers is beyond ridiculous. Even if the compiler doesn't support the asm keyword and inline assembly, you could still list the array contents as hexadecimal values with the corresponding assembly code in adjacent comments.
Software Zen: delete this;
|
|
|
|
|
Also ridiculous are names that activate horizontal scroll bars. But I digress.
|
|
|
|
|
Ah, but there's a reason for the ridiculously long name. The name I listed is the longest for a group of enum values which are individual bits in a 32 bit mask. Each bit identifies a message that should be displayed to the operator. The equipment can identify a single message or several to be displayed at once. The messages don't lend themselves to any kind of consistent, concise naming scheme.
As we know, the following two problems are fundamentally difficult in computing:- Cache invalidation
- Creating appropriate identifiers
- Off-by-1 errors
The simplest and most logically consistent naming for each bit was therefore the text for that bit, with minor transformations to convert the text into a valid C++ identifier. Space characters and all punctuation became underscores, and Bob's your uncle.
Just to add to your excitement over this challenging and seemingly intransigent problem, there is ongoing grumbling from the equipment group over the text I actually display based upon each bit. They expect the exact text in their specification to be displayed. You see, I have this effete and unwanted fondness for grammatical English, which their text... isn't. We won't even mention (yes we will) the fact that our UI is also translated to French, Italian, German, Spanish, Japanese, Chinese Simplified, Korean, Polish, and Russian. Some folks just kind of expect us to speak their language.
Software Zen: delete this;
|
|
|
|
|
I'm changing ISP's in a week or so, so I resurrected an old app I wrote to monitor my ISP and tell me when it changed.
And it didn't work any more, because the IP Geolocation service I was using has changed and needs an API signup instead of presenting the data as CSV.
So, I thought I'd re-write it using HtmlAgilityPack.
But it was odd that I got no error message in the original code ... until I spotted this:
private void FillInDetails(string host)
{
Timestamp = DateTime.Now;
IPAddress addr = IPAddress.None;
try
{
using (WebClient wc = new WebClient())
{
if (string.IsNullOrWhiteSpace(host))
{
host = "http://freegeoip.net/csv";
}
else
{
host = string.Format("http://freegeoip.net/csv{0}{1}", "/", host);
}
string data = wc.DownloadString(host);
string[] sections = BreakCSVLine(data);
if (sections.Length != freegeoipDataSectionsCount) throw new ArgumentException("Data returned from FreeGeoIP has changed format!");
addr = IPAddress.Parse(sections[freegeoipDataAddress]);
CountryCode = sections[freegeoipDataCountryCode];
Country = sections[freegeoipDataCountry];
RegionCode = sections[freegeoipDataRegionCode];
Region = sections[freegeoipDataRegion];
City = sections[freegeoipDataCity];
Zipcode = sections[freegeoipDataZipcode];
TimeZone = sections[freegeoipDataTimeZone];
Area = sections[freegeoipDataArea];
float lat = float.Parse(sections[freegeoipDataLatitude]);
float lon = float.Parse(sections[freegeoipDataLongditude]);
LatLong = new PointF(lon, lat);
}
}
catch (Exception)
{
}
Address = addr;
}
So I carefully create my own exception to tell me why it's not working ... and then explicitly ignore it.
I do wonder about past-me's thought processes sometimes ...
"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!
|
|
|
|
|
Exception handling/reporting is something I've never figured out how to do well, especially when writing a web application. The back-end throws an exception. What do you do? Log it somewhere nobody ever looks, least of all me? Do you report it to the front-end?
The front-end has to deal with the back-end exception. What do you do? Display an obtuse message to the user?
The front-end itself generates an exception. Is it even caught? What do you do? Another obtuse message? Or an API endpoint that it calls to log it on the server in a log that no one, least of all me, ever looks at?
I've decided to take a rather drastic approach to very specific problems (like a failure to update an audit table) - I email myself the exception and filter it in Outlook into specific folders. I find it a lot more effective in knowing about the exception and to fix it.
|
|
|
|
|
I feel your pain!
Been struggling with this myself.
I always make sure my users know something went wrong.
Like really wrong.
They should get an exception and not be able to continue.
Preferably some "scary" message that sounds very technical.
Very user unfriendly, but at least they'll call me so I can fix the issue instead of ignoring the error and continuing with potentially corrupt data (yes, that happened in the past)
|
|
|
|
|
Beyond that Exception , what's that:
OriginalGriff wrote: host = string.Format("http://freegeoip.net/csv{0}{1}", "/", host); Why do you need a parameter for the constant value of "/" ?
My diagnosis:
A severe case of hypocaffeinaemia.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
If it was my terrible code, the empty Catch() block would've been a helpful breakpoint holder while I was debugging the initial implementation. It may also have had code to handle a case that I subsequently made impossible.
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
modified 20-Apr-21 16:41pm.
|
|
|
|
|
I was thinking about the SSD in my wife's laptop. 120GB and it's been running for 4-5 years.
Kind of fell down a rabbit hole...
A Windows App?: Not really
I started looking for apps to tell me the situation.
Found an article that explains some things:
Find out how much longer your SSD will last - CNET[^]
The article mentions this app: Crystal Disk Mark -- not great[^]
All Comes Down to Reads & Writes
Basically the article tells you that most likely it will take you 15 years to wear a good SSD out so don't worry too much.
Found Some Sample Code
Then I found a sample program that makes some API calls and tells you how many bytes you've read and written since the OS was started.
Here's the output for my wife's computer that has been running for over 16 days without rebooting:
http://i.stack.imgur.com/3jTsD.png[^]
Compare those read/write bytes to mine that has only been running[^] for a little over 2 hours.
Here's the code (alterations by me) from c++ - How to get global Windows I/O statistics? - Stack Overflow[^]
NOTE: hard-coded to check only the C:\ drive
Update: Updated method to display the number of days computer has been running.
#include <windows.h>
#include <iostream>
#include <locale>
#include <sysinfoapi.h>
std::__cxx11::string displayValue(LONGLONG);
void getOsRunTime();
int main() {
HANDLE dev = CreateFile(LPCSTR("\\\\.\\C:"),
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
DISK_PERFORMANCE disk_info { };
DWORD bytes;
if (dev == INVALID_HANDLE_VALUE) {
std::cerr << "Error opening disk\n";
return 1;
}
if (!DeviceIoControl(dev,
IOCTL_DISK_PERFORMANCE,
NULL,
0,
&disk_info,
sizeof(disk_info),
&bytes,
NULL))
{
std::cerr << "Failure in DeviceIoControl\n";
return 1;
}
std::cout << "Bytes read: " << displayValue(disk_info.BytesRead.QuadPart) << "\n";
std::cout << "Bytes written: " << displayValue(disk_info.BytesWritten.QuadPart) << "\n";
getOsRunTime();
}
std::__cxx11::string displayValue(LONGLONG byteCount){
auto s = std::to_string(byteCount);
int n = s.length() - 3;
while (n > 0) {
s.insert(n, ",");
n -= 3;
}
return s;
}
void getOsRunTime(){
ULONGLONG milli = GetTickCount64();
long days = milli / (3600000 *24);
milli = milli - (3600000 *24) * days;
long hr = milli / 3600000;
milli = milli - 3600000 * hr;
long min = milli / 60000;
milli = milli - 60000 * min;
long sec = milli / 1000;
milli = milli - 1000 * sec;
std::cout << "OS has been running " << days << " days " << hr << " hours " << min << " minutes " << sec << " seconds " << milli << " ms." << std::endl;
}
modified 27-Mar-21 23:50pm.
|
|
|
|
|
What ARE you guys doing? Writing over 1GB/hr!
My linux laptops (not doing a lot, I admit) are running much much less than that.
(sorry I had a bit of a hiccup getting reliable stats. I'll update a bit later.)
Installing Audacity on one (and running it a bit) put a 150MB/50MB lump in its stats.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
modified 27-Mar-21 22:24pm.
|
|
|
|
|
Peter_in_2780 wrote: What ARE you guys doing? Writing over 1GB/hr!
I know. It's crazy on Win10. I run Win10 on this new laptop but I run Ubuntu 20.04 on my main desktop that I use daily and it performs so much better than win10.
Win10 reads and writes to disk constantly. Check it out. Here's an updated snapshot of what my laptop has done since that last one[^]. I haven't even been on this laptop for hours now, but it's written another 1.1GB and read another 1GB.
I noticed this with Win10 when it first came out because I could no longer run an HDD -- win10 eats so much I/O that the machine would get overwhelmed. Had to switch to SSDs or win10 kills performance.
|
|
|
|