Skip to main content

CodeSOD: Conventional Events

2 months 1 week ago

Now, I would argue that the event-driven lifecycle of ASP .Net WebForms is a bad way to design web applications. And it's telling that the model is basically dead; it seems my take is at best lukewarm, if not downright cold.

Pete inherited code from Bob, and Bob wrote an ASP .Net WebForm many many ages ago, and it's still the company's main application. Bob may not be with the company, but his presence lingers, both in the code he wrote and the fact that he commented frequently with // bob was here

Bob liked to reinvent wheels. Maybe that's why most methods he wrote were at least 500 lines long. He wrote his own localization engine, which doesn't work terribly well. What code he did write, he copy/pasted multiple times.

He was fond of this pattern:

if (SomeMethodReturningBoolean()) { return true; } else { return false; }

Now, in a Web Form, you usually attach your events to parts of the page lifecycle by convention. Name a method Page_Load? It gets called when the load event fires. Page_PreRender? Yep- when the pre-render event fires. SomeField_MouseClick? You get it.

Bob didn't, or Bob didn't like coding by naming convention. Which, I'll be frank, I also don't like coding by naming convention, but it was the paradigm Web Forms favored, it's what the documentation assumed, it's what every other developer was going to expect to see.

Still, Bob had his own Bob way of doing it.

In every page he'd write code like this:

this.PreRender += this.RequestPagePreRender

That line manually registers an event handler, which invokes the method RequestPagePreRender. And while I might object to wiring up events by convention- this is still just a convention. It's not done with any thought at all- every page has this line, even if the RequestPagePreRender method is empty.

[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Remy Porter

Older People Who Use Smartphones 'Have Lower Rates of Cognitive Decline'

2 months 1 week ago
An anonymous reader quotes a report from The Guardian: Fears that smartphones, tablets and other devices could drive dementia in later life have been challenged by research that found lower rates of cognitive decline in older people who used the technology. An analysis of published studies that looked at technology use and mental skills in more than 400,000 older adults found that over-50s who routinely used digital devices had lower rates of cognitive decline than those who used them less. It is unclear whether the technology staves off mental decline, or whether people with better cognitive skills simply use them more, but the scientists say the findings question the claim that screen time drives what has been called "digital dementia". "For the first generation that was exposed to digital tools, their use is associated with better cognitive functioning," said Dr Jared Benge, a clinical neuropsychologist in UT Health Austin's Comprehensive Memory Center. "This is a more hopeful message than one might expect given concerns about brain rot, brain drain, and digital dementia." Benge and his colleague Dr Michael Scullin, a cognitive neuroscientist at Baylor University in Texas, analysed 57 published studies that examined the use of digital technology in 411,430 adults around the world. The average age was 69 years old and all had a cognitive test or diagnosis. The scientists found no evidence for the digital dementia hypothesis, which suggests that a lifetime of using digital technology drives mental decline. Rather, they found that using a computer, smartphone, the internet or some combination of these was associated with a lower risk of cognitive impairment. The details have been published in Nature Human Behaviour. "Using digital devices in the way that we use televisions -- passive and sedentary, both physically and mentally -- is not likely to be beneficial," said Scullin. "But, our computers and smartphones also can be mentally stimulating, afford social connections, and provide compensation for cognitive abilities that are declining with ageing. These latter types of uses have long been regarded as beneficial for cognitive ageing."

Read more of this story at Slashdot.

BeauHD