Wednesday, April 19, 2017

Oh! The Irony ...

If you peruse any decent book or blog regarding "good" coding practices, "naming things properly" is usually near the top of the list of recommendations to follow. This is actually quite important. Most recently, at a recent client's site, I took over the maintenance of a WPF application. It was part of a suite for a medical device the company was developing. One of the many "state" properties that were being used was named "hasManufactured". I was confused by this for reasons below. More importantly, when I asked around, no one else was sure what it meant. The original programmer was long gone.

There are several things wrong with this. First, as a property, it is incorrectly cased. It should have been "HasManufactured". In a more  egregious fashion the other "state" properties in the class WERE properly cased. Was there a reason this one was not?

Second of all, the meaning of "hasManufactured" was completely confusing to me. "Has" as a word, generally means possession of something, or else a state of being. "He has a goat" is an example of possession. "He has been hired" would be a state. But notice that when "has" represents a state, it's usually associated with a verb of some tense. A reasonable interpretation of the meaning of "hasManufactured" was probably "has been manufactured". Of course, everything that was in the manufacturing process was being manufactured, so ...

Finally, after digging around in the code, it appeared that "hasManufactured" was being changed from false to true when someone clicked the "Finalize" button on a particular dialog window. As it turns out, this button was clicked as the final step in the manufacturing process. So a good assumption is that "hasManufactured" really meant "has been through the entire manufacturing process and is ready for sale". A far better name would have been "IsFinalized". (And yes, I did refactor this.)

Which gets me to the real point of this post. "Object Oriented Design" and "Object Oriented Programming" are both lousy names.

I've been doing .NET Framework programming for over 15 years at the time of this post. Not once have I ever coded an object. In fact, Visual Studio doesn't create object files, it creates class files.

The following code is syntactically correct and declares a class:
public class MyClass() {}
However, this next statement is syntactically incorrect and it has a completely different meaning and result in c#:
public object MyObject() {}
In the first case, an empty class (no members) is being defined. In the second case, the only reasonable meaning is someone mis-coded a method in a class that was supposed to return an instance of the object class.

Note the distinction here identified by the difference in syntax. We developers are NOT doing Object Oriented Programming. We are doing Class Oriented Programming. And we are doing Class Oriented Design. We don't use diagramming tools that provide "object" diagrams - they provide "class" diagrams. Unfortunately, I don't anticipate a successful #hashtag campaign to change the name of the paradigm ...

So here we have an entire industry that recommends naming things properly that has incorrectly named its industry.

Paraphrasing Colonel Kurtz: "Oh! The Irony..."

Sunday, April 16, 2017

My first Xamarin app ...

I just finished my first Xamarin app and published it to  GitHub. It can found here.

I've certainly had my issues with Xamarin. I have an earlier post that's quite a rant. It turns out that if you want to create a "library" assembly to use in a Xamarin PCL, you seem to need to create a .NET Standard 1.4 (or less?) library. Then you can reference it in a PCL assembly. Who'd a thunk it...

Nevertheless, the emulator I selected worked quite well, and didn't require any configuration - though granted my app is very tiny. This app is just a proof-of-concept app to prove the feasibility of a bigger app I'll be working on to commit to the stores.

Hopefully, my experiences with Xamarin will improve. While it's been uncomfortable, it's still a lot more successful than my even more painful experiences with Cordova and NativeScript.

Saturday, April 15, 2017

Why sitting at your desk all day is bad for your heart...

While I work in IT, my B.A. is actually in Physiology. How I got to IT from Physiology is a long, sad, meandering tale not worth telling. Nevertheless, it gives me some background to make educated guesses.

Your circulatory system is composed of two primary sub-systems: the Venous system and the Arterial System. The Arterial system pumps oxygenated blood that is received by the heart from the lungs to the rest of the body. The Venous system returns blood (now de-oxygenated and full of CO2) to the heart which then pumps it through the lungs back to the heart and the Arterial system. 

Now consider how close the heart is your lungs and your head. Not very far, The top of your head is about 1 to 1.5 feet above your  heart. Everything else in your body is pretty much at the same level or below your heart. So the hardest part of pumping blood in the Arterial system is pumping blood UP to your head, your lungs, and your arms. On the other hand pumping blood down to your abdomen, legs, feet etc. means pumping a distance of about 4-5 feet, depending on how tall  you are. Pumping the blood down doesn't require quite as much effort, because gravity is working with your heart, not against it. 

What most people don't realize is that the Venous system, which returns blood to the heart, is assisted by your muscular  system, primarily your legs. In fact, your legs might actually be a stronger pumping system than your heart (more about this later). Your veins have little valves in them that prevent the back flow of blood when the arterial portion of the heart temporarily stops. What? Yes, that's what your pulse is all about. The heart pumps by contracting - which it does rhythmically. Pump - pause - pump - pause - pump - pause. During that pause, if you didn't have those little valves in your veins, the blood in your veins would start to flow back down in your body because gravity still works.  When the muscles contract, they actually help pump blood back to your heart.



Why is this important? Well, if you're sitting at your desk, your legs aren't pumping blood back to the heart! When you're sitting down, the distance from your feet to your heart is about 3 feet. That's actually a VERY long distance to pump fluid against gravity! And it puts a lot of strain on your heart -  all day.

In fact, a good demonstration of how much we depend upon our muscular system to pump blood that 3 or 4 feet back to the heart is to simply stand on your head or hang by your feet for about 30 seconds. Generally, you'll find that your face will get flushed, your sinuses will start to feel congested, and you might even start to get a head-ache because blood is starting to pool in your cranium. Your heart is having a hard time pumping blood uphill against gravity to your feet, abdomen, etc. All the things that are normally BELOW your heart. It pools because your muscular system can't help the heart get blood out of the Venous system. 

The human body evolved to depend on the muscles in our legs to help out the heart. We used to walk, squat, get up and down all day long before we got cars and desk jobs. 

So what's a poor desk jockey to do? Every couple of minutes stand up. Do some calf raises and a few squats. Or just tense your leg muscles with isometric exercises. 

Give your heart a break....

Thursday, April 13, 2017

Edge is finally worth using ...

I got the Windows 10 Creators Update this morning. One of the touted benefits is a new & better version of Edge. So far (1 day's use), it seems to be living up to the promise. 

I haven't had a single "recovering web page" or "web page not responding" error today. 

They have a MUCH larger suite of extensions available. I particularly like the "Page Analyzer" tool.

They've also added a "book reader' capability, and I've downloaded most of my favorite free books from their catalog (What can I say? I'm a cheap SOB...). However, their Store still sucks for searching for just books. It keeps showing games. I have no interest in games ...

I've always like Windows 10 since I started using it many months ago. The only issue for me was the lousy performance of the Edge browser.  While I've seen some issues today regarding Edge integration with Outlook (which may be a config issue on my part) I'm pleased enough I've set it back to my default browser.

If I live to regret that, I'll be posting about it again...

Most of it is dreck ...


Recently, I applied to a position that asked about contributions I've made to GitHub. I've purposely avoided doing any for the longest time. But the job posting also asked for a Cover Letter that was not a "standard" Cover Letter. So here's what I had to say about GitHub contributions in my "non-standard" Cover Letter:

I finally gave up and contributed one of my small libraries to GitHub and the NuGet gallery. Links are:
https://github.com/silverfox1948/SACC.OperationResult https://www.nuget.org/packages/SACC.OperationResult/
Why do I say “I finally gave up …”? For the most part, stuff on GitHub (and incidentally NuGet) is dreck. A lot of it seems as if the developer just wanted to point at something they’d put up there in order to say “See! I did this!”.(Possibly because some employers are asking about what their contributions to GitHub are…)
The other reasons are:
My employers want to  use libraries that are and will be continued to be supported for a long time. The reason they are using a library is because they don’t want to have to write & support it themselves. If it’s a one person library, it won’t have adequate support. I’ll be supporting my little library because I use it myself on all my projects. 
A lot of the contributions have absolutely no documentation at all. It’s just “read the unit tests to figure out how to use it.” If the developer is too lazy to document his product and is unwilling to: 
v  Convince me of the benefits of their product
v  Show me how to use it in my non-unit test code
Then I treat their actual code with a very high level of suspicion …

Saturday, February 11, 2017

VS Is Becoming Worse & Worse...


Recently, I tried, using VS 2015 Community, to create a simple Xamarin Forms app. All I did was select the standard template, and then tried to run the Android program. Didn't work ...

I don't remember the details, but rather than go through the tedious repair/uninstall process with VS 2015, I thought I'd try to install the VS 2017 Community Beta. I selected the standard template for Xamarin and then got this:

Not entirely encouraging ...
So I stopped VS 2107 and re-opened it. Then created the project again. I removed the iOS project, as I don't have a Mac, and don't want to see the "no mac" error window all the time. The Android project is the default start project. No error about packages this time. So I did a clean/rebuild of the solution. Here's the first error in the list of 3780!

Severity Code Description Project File Line Suppression State
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. DemoXamarinForms.Droid C:\repos\DemoCode\DemoXamarinForms\DemoXamarinForms\DemoXamarinForms.Droid\MainActivity.cs 7 Active

So first error is that mscorlib is not in any of the assemblies in the reference list for the Android project.

Does anyone do any testing at Microsoft anymore? It seems that since they went to this "open source" model, all they do is post s**t with the attitude "Well, this ought to work. If it doesn't the users will let us know ..."

As DJT might tweet: "SO SAD"...