Monday, May 18, 2015

Perhaps programming something

So it's past 6AM and I haven't gone to sleep. I could have gotten off a few hours ago when my friend finished with the therapy session, but I have just been so caught up in programming since yesterday. Even though I'd certainly appreciate some shut-eye, a part of me wants to just keep going! That's how hobbies or interests work, I guess, haha.

I think I'm now satisfied with what I've gotten done. There was a lot of, "Let's delete that, it's too complicated," followed by, "Dammit, that's the best way to get it done," and repeat. Once I decided to take on the complication, I had fun seeing it through, and I feel smart for finishing it. Not that I'm finished with my coding. I've got a whole lot more to do.

There's a concept in programming called a singleton. The idea is that there is only one instance of a class throughout runtime. The One Ring could be a good singleton. There is one ring to rule them all, just one in all of existence. Thing is, I don't really see the point of even instantiating a class if there will only ever be one instance. I prefer to make all the fields and most of the methods static, so they can be accessed directly from the class instead of from an instance. The class is the class, no matter what, with no duplicates, and accessible from everywhere, so I think this is the best way of approaching it. Back to the One Ring metaphor, when I mess with the Ring I call it the One Ring, and it is everpresent. Someone who prefers to instantiate would be calling it My Precious, and they may lose it somewhere and have to find it again.

Singletons are just one of the coding concepts I've been employing. I hope the metaphor helped you to get it. Now, I should probably call it a morning. I've got three messages to write today, this one included. Don't worry, I'll keep to it. Time to head to bed...

No comments:

Post a Comment