Categories
Journal Entry

Journal Entry 243

Day 243 of self isolation. Rats are starting to become self-aware and leery of me. Running low on toilet paper. Going to make a trip back to the outside world and buy more.

Categories
C#

C#: When to use fields, get/set, properties, and/or methods

namespace TestCode {

    using System;

    /// <summary>When to use fields, getters, properties, and/or setters.</summary>
    /// <remarks>Totally open to suggestions to showcase wrong/right patterns.</remarks>
    public class WrongBetterRight {

        /// <summary>Bad.</summary>
        public class VersionA {

            /// <summary>Totally exposed public field. No protection.</summary>
            public Int32 ID;

            /// <summary>getter that 'does' something. Should be a method.</summary>
            public Int32 CalculateID => ( this.ID / 2 ) + ( this.ID / 2 );

            /// <summary>Okay, but still a getter.</summary>
            public Int32 GetID => this.ID;

            /// <summary>ctor.</summary>
            /// <param name="id"></param>
            public VersionA( Int32 id ) => this.ID = id;

            /// <summary>*poof* your app just blew up.</summary>
            /// <param name="newid"></param>
            public Boolean ChangeID( Int32 newid ) {
                this.ID = newid;

                return true;
            }

        }

        public class VersionB {

            /// <summary>Better than a public non-readonly field. Still vulnerable to a future change to property.</summary>
            public readonly Int32 ID;

            /// <summary>Only returns value. Okay.</summary>
            public Int32 GetID => this.ID;

            /// <summary>ctor. No checks yet.</summary>
            /// <param name="id"></param>
            public VersionB( Int32 id ) => this.ID = id;

            /// <summary>Contrived. 'Does' something, so a method is okay.</summary>
            /// <returns></returns>
            public Int32 CalculateID() => ( this.ID / 2 ) + ( this.ID / 2 );

            /// <summary>Prevents this method from changing ID. Which the compiler would prevent anyways. Not as easy to refactor (what 'value'??).</summary>
            /// <param name="newid"></param>
            /// <returns></returns>
            public Boolean ChangeID( Int32 newid ) => throw new InvalidOperationException( "value is not allowed to be changed." );

        }

        public class VersionC {

            /// <summary>Best way. Future proof. Property hides away field.</summary>
            public Int32 ID { get; }

            /// <summary>ctor. Checks incoming value.</summary>
            /// <param name="id"></param>
            public VersionC( Int32 id ) {
                this.ValidateValue( id );

                this.ID = id;
            }

            private void ValidateValue( Int32 id ) {
                ThrowIfValueTooLow();

                ThrowIfValueTooHigh();

                void ThrowIfValueTooLow() {
                    const Int32 minimumAllowedValue = 1;

                    if ( id < minimumAllowedValue ) {

                        //Exception message wording could better. But easy to refactor.
                        throw new ArgumentOutOfRangeException( nameof( id ), id, $"The value `{id}` is too low for {nameof( this.ID )}." );
                    }
                }

                void ThrowIfValueTooHigh() {
                    const Int32 maximumAllowedValue = 10;

                    if ( id > maximumAllowedValue ) {

                        //Exception message wording could better. But easy to refactor.
                        throw new ArgumentOutOfRangeException( nameof( id ), id, $"The value `{id}` is too high for {nameof( this.ID )}." );
                    }
                }
            }

            /// <summary>Future proof. Doesn't expose <see cref="ID" /> directly. Easy to refactor.</summary>
            /// <returns></returns>
            public Int32 CalculateID() => ( this.ID / 2 ) + ( this.ID / 2 );

            /// <summary>prevents this method from changing <see cref="ID" />. which the compiler would prevent anyways. but easier to refactor <see cref="ID" />.</summary>
            /// <param name="newid"></param>
            /// <returns></returns>
            public Boolean ChangeID( Int32 newid ) => throw new InvalidOperationException( $"{nameof( this.ID )} is not allowed to be changed." );

            /// <summary>Valid. Better than a plain getter? Debatable. This is more future proof though.</summary>
            public Int32 GetID() => this.ID;

        }

    }
}
Categories
gay god government human marriage rights

Consensual Sexuality

I don’t care what your gender/preference/orientation is.
LGBTQIAP+ .. whatever.
Really. I don’t care. We all have preferences. You are no different than the rest of the world. We [should] all have the same rights.

I don’t care if you ‘come out’ or if you keep it ‘locked up’.

It doesn’t matter to me what you like to poke it in, or like to be poked from, or with, or where, or not at all.. as long as it is mutually consensual (and both are reasonably aged, you goddamn pedophiles).

But: I am so tired of hearing it on the news, seeing it on TV, movies, plastered over social media.. so STOP SHOVING IT IN OUR FACES! (Here’s looking at you, Star Trek’s: ‘Discovery’! If I wanted to see two men making out in the engine room, I’d go join a ship or fire up PornHub!)

If God has a problem with your preference: He will take that up with you in the afterlife.
If Nature has a problem with your preference, she will intrinsically breed out of existence that which does not propagate work.

So I tell you this: It is not our/society’s place to shun or promote any choice related to mutually consensual sex of reasonable ages.

My, deeply personal, opinion is that ‘gay’ marriage is an oxymoron.
I believe two people of the same gender cannot truly love each other the same way a man and a woman love each other. Lust? Sure, easily. But Love? Nope.

But I will NOT stop you, or put you down, or in any way not allow you to live your lifestyle choice, as long as what you do is totally mutually consensual.

I’m sure some asshat will take a warped view of my comments as “your way allows [insert nasty bigoted view here]!”.

NO, it does not. Consensual implies informed.

Alcohol, drugs, and youth all impair one’s judgement.. and that prevents the ‘mutually’ consensual part.

Abusing trust, authority, responsibility, or lying is not consensual!

🖖🖖🏻🖖🏼🖖🏽🖖🏾🖖🏿

Categories
science

Limitations of the Scientific Method?

The Scientific Method is a powerful tool to aid in our understanding of the Universe and how it works.

But.. Does it really have any limitations?

If there currently is a limitation, then it is most likely from a lack (or misunderstanding) of knowledge gathered, the other tools used to gather information, a lack of imagination to conceptualize a new idea, and/or [usually] the failure to follow the Scientific Method (i.e. “Jumping to a Conclusion”).

These would all be flaws on the human side.. not in the methodology itself.

Categories
politics

A Presidential Psychopath

“A psychopath is defined as having no concern for the feelings of others & a complete disregard for any sense of social obligation. They seem egocentric and lacking insight and any sense of responsibility or consequence. Their emotions are thought to be superficial and shallow, if they exist at all. They are considered callous, manipulative and incapable of forming lasting relationships, let alone of any kind of love. It is thought that any emotions which the true psychopath exhibits are the fruits of watching and mimicking other people’s emotions. They show poor impulse control and a low tolerance for frustration and aggression. They have no empathy, remorse, anxiety or guilt in relation to their behavior. In short, they truly are devoid of conscience. Psychopaths also have a markedly distorted sense of the potential consequences of their actions, not only for others, but also for themselves. They do not, for example, deeply recognize the risk of being caught, disbelieved or injured as a result of their behaviour.”

attributed to Robert D. Hare

Categories
Quotes

Compassion

“It’s easier to provoke fear than promote compassion.” – Protiguous

Categories
Anything

Sports Ability

Okay, bare with me. I’m trying to formulate an idea here..

Sports. Some people love to watch, others to participate. Right?

The current problem, as I understand it, is that we (as enlightened as we claim to be in 2020) are still separating people who compete by their birth genders.. something which isn’t always 100% accurate!

Here is my proposal: How about grouping (not separating!) people into their performance-groups based on their maximum performance levels during training.
Level meaning how far they can throw, how fast they can run, how far they can jump, how well can they hit, etc during their training stages.

This would ignore gender differences, steroid use, drug use, strength.
All of it.
It would dismiss the old stereotype of ‘women’ being weaker than ‘men’.
It would dismiss the fear of being beat by a ‘woman’ who was classified as a ‘male’ at birth. And visa-versa.

If a 125 pound person can run, jump, & throw distance-X then classify them into that Level-10 group. No matter what they’re juiced up on, or born as, or how many years of training they’ve had.

Same thing: If a 275 pound Rock (Dwane Johnson – who is the coolest guy ever) can run, jump, & throw distance-X, then group him into a different Level-20 group.

Basically: Group via Observed Athletic Ability.

The only cheat to this grouping system, that I can think of at the moment, is some bad apples would purposely under-perform during the ‘testing’ phases in order to gain an edge on the group into which they would be categorized. But then during the actual competition they’d perform at their real Rated level, and thereby have an advantage over their competitors.

But, doesn’t something like this kind of cheating go on these days already?
Just hidden from view so they don’t get caught as easily?

Maybe adjust the pay/awards/rewards on their Level then?

What do you think? Would this help eliminate all of the phobias in sports?
Man vs woman. Transgender vs non-transgender?

Categories
Philosophy

Charmed: Good vs evil

I really liked the show “Charmed“, except for one thing. Their concept/religion they kept [constantly] trying to push: that “Good” and “evil” must be “Balanced” [or else the Universe disappears/corrupts/implodes].

Their “balance” concept is fundamentally flawed. The Universe (and human beings & other lifeforms) is not a balanced 50/50 mix of Good and evil.

Something Good starts 100% pure, like a healthy body. Think “Purity of the Light”. Example: All babies are created with 100% of pure good no matter their point of origin/conception/parents. Full of love. Not a single drop of hatred or evil.

Evil is not inherent; it must be learned/influenced from the outside.

Evil is more like a disease, a corruption. A cancer that starts small and can spread throughout the body.. a darkness that will eventually kill the very body it corrupts.

Evil spreads like a contagious virus. It ‘infects’ others. It is the easy way to behave. Hate is easier than love, although it requires more energy. Evil begets more evil.

Loving another Being requires effort to overcome evil.

Love one another.. Be Good.

Categories
Short Story

Short Story: Titanium Baseball Bat

“Hey Bob, brb. I need to grab my titanium baseball bat to smash the stupid car that’s honking behind me lol”, I texted my friend Bob.

Sigh. ANOTHER idiot having the nerve to honk at me! Now where did I leave my bat? Aha, there it is! Now to go show them who’s boss! Nobody honks at me!

So I reach for my bat. Oh..

I guess I ought to put down my phone first..

Written by Protiguous

Copyright Protiguous 2020

Categories
SQL Server

Don’t let this little SQL slip delete your rows!

I came across this quick example that shows how easily the tiniest little mistake could end up deleting rows from your table.

The solution to this bug? Always name & reference your tables, CTE, and subqueries!

-- Create and populate test tables.
drop table if exists dbo.purge_test;

create table dbo.purge_test(
    id int primary key,
    purge_type int not null default 1, 
    purge_date datetime not null default current_timestamp
);

insert into dbo.purge_test(id) values(99);

drop table if exists dbo.star_wars_film;

create table dbo.star_wars_film (
    film_id int primary key,
    film_description varchar(50) not null
);

insert into dbo.star_wars_film(film_id, film_description)
values 
    (1,'Star Wars - The phantom menace'),
     (2,'Revenge of the Sith'),
     (3,'Attack of the clones'),
     (4,'A new hope'),
     (5,'The empire strikes back'),
     (6,'Return of the Jedi'),
     (7,'The force awakens'),
     (8,'The last Jedi'),
     (-1,'Rogue One');

And now you can play: Spot the Bug™!

-- Check the data before the unspotted bug.
select film_id, film_description from dbo.star_wars_film order by film_id;

-- Bug! Do you see it? The query runs just fine.. right?
delete from dbo.star_wars_film
where film_id in (
    select film_id from dbo.purge_test where purge_type = 1
);

-- After the delete.
-- Expected the same rows as before because we *know* the purge id of 99 wasn't one of the file_id.
-- Right?
select film_id, film_description from dbo.star_wars_film order by film_id;

-- Corrected query. Won't execute now because specified column doesn't exist.
delete swf
from dbo.star_wars_film swf
where swf.film_id in (
    select pt.film_id from dbo.purge_test pt where pt.purge_type = 1
);