Sitting Too Long Will Kill You

January 29, 2015

Hi all!

I know, a very daunting title for my blog post today, but it is rather important to all of you who sit most of their day like myself. For those of us who sit in front of the desk all day as well as those who sit in front of the tv all night, this is a really big problem!

Sitting too long will kill you. How? How is this possible?

Well, several studies have been done to show that those who sit too long pose at a much greater risk of illness as their bodies slowly lose their ability to fight infections.

White Blood Cell Fight

Not only that, but your brain doesn’t have as much critical thinking as someone who is active.

Here is an article talking about the effects of sitting:

CNN Logo http://www.cnn.com/2015/01/21/health/sitting-will-kill-you/index.html

ASAPScience also did a great video about the effects of sitting:

https://www.youtube.com/watch?v=uiKg6JfS658

What can you do in order to counteract the effects of sitting too long? Well, ASAPScience (or ASAPThought in this case) has a video for that too:

https://www.youtube.com/watch?v=4K_ENbRgywY

Keep yourselves active, and you will have a much healthier, happier life. 🙂

That’s all for now, until next time…keep that tech gear ticking.

~Goliath7470

Mafia Games Monday (MGM) – What is DRY?

January 26, 2015

Hello all,

So, a couple of weeks ago on MGM, I went into a basic overview of what OOP is. If you don’t know what that is or want to refresh your memory on that, the blog post is here.

Anyways, so today, I’m going to talk about one of the major goals of using OOP: the DRY principle.

What does DRY stand for?

It stands for “Don’t Repeat Yourself”. Basically, DRY means that you do not want to repeat code of which you’ve already written on a different page or even repeat code on the same page.

Dont Repeat Yourself

Why is DRY important? Well, to answer this question, let’s look at an example.

Suppose you have the following code on one page:

$number = 10;
$multiplier = 2;
$answer = $number * $multiplier;
echo $answer;

And this code on another page:

$number = 7;
$multiplier = 4;
$answer = $number * $multiplier;
echo $answer;

So, with this code in mind, let’s propose that now you want to do subtraction instead of multiplication. So now, you have to update both of those pages to subtract instead of multiply. I know, a very simple example here, but just imagine if you have 100+ pages each with 700+ lines of code, and you have to find and fix all of these. Pretty daunting now, isn’t it?

Well, with DRY, all we have to do is create one function in order to handle a change like this. So, let’s create a function!

function domath($number1, $number2)
{
$result = $number1 * $number2;
return $result;
}

Very simple function above. So, the pages using this function will look like this:

$number = 10;
$multiplier = 2;
$answer = domath($number, $multiplier);
echo $answer;

And the other page:

$number = 7;
$multiplier = 4;
$answer = domath($number, $multiplier);
echo $answer;

So, let’s suppose the scenario above: you decide to subtract instead of multiply. Well, all you have to do is adjust the code on the function! The function will now look like this:

function domath($number1, $number2)
{
$result = $number1 - $number2;
return $result;
}

And that’s it, you’re done! That’s the DRY principle in effect!

So, how exactly does this apply to OOP? Well, that’s one of the major points in using OOP: not repeating yourself. Classes are a great way in order to only have to change code in one place instead of having to change code in MANY different areas.

That is DRY for you: Don’t Repeat Yourself, and you will have much more bliss as a programmer.

That’s all for now, until next time…keep that tech gear ticking.

~Goliath7470

Solar Farms Up Above?

January 15, 2015

Hello all!

So, a little while ago, I posted in my blog about Wind Farms possibly being underwater (post is here). Well, they are also experimenting with having solar energy coming from the sun up in space! Yes, you read correctly, up in SPACE!

This could provide our world with a lot of renewable light energy that could with enough light energy power the whole world. However, even with this, the major disadvantage currently standing in the way of this major achievement is cost. These satellites will be very expensive to make; however, is putting some money into this now worth our prolonged existence in the long run?

Articles are here if you would like to check out more about this possibility:

CNN Logo http://www.cnn.com/2014/12/18/tech/innovation/space-based-solar-power/index.html

National Space Society Logo http://www.nss.org/settlement/ssp/

That’s all for now, until next time…keep that tech gear ticking.

~Goliath7470

Mafia Games Monday (MGM) – What is OOP?

January 12, 2015

Hello everyone!

So, some of you have been asking how to make your code more compact or not writing the same code over and over again. Well, today, I have some answers for you.

First off, what does OOP stand for? OOP stands for “Object Oriented Programming”. Instead of using countless variables, OOP substitutes these with objects and object references.

How does OOP work? For this part, I would like to use an example to fully explain OOP. First, let’s look at the image below:

Person Class

As you can see, there is a “Person”, who is considered as what’s called in OOP as a class. A class is an association of a group of objects, like in this case, people. Elaya, Dara, and Bharath are what OOP calls instances of the class (or objects). They are specific definitions of the person class with their own specific traits.

So, with that in mind, let’s do an actual PHP example.

First, we will need to create a class. In PHP, a class is defined like this:

class MyClass
{
}

Of course, there is much more to a class than this, but that’s the shell. So, in following the example I gave to explain a class versus an object, let’s create a class. So, we will do the skeleton first:

class Person
{
}

Now that we have that, let’s create some class properties, which I consider to be labeled as different traits of a class. So, with this example, let’s do sex (male/female), preferred hand (left/right), and hair style:

class Person
{
public $sex;
public $hand;
public $hstyle;
}

Wait, what’s with the “public” in front of the variables? Well, that is what’s called the visibility of the property. Basically, public properties can be accessed by anyone, protected properties can be accessed by the class itself, parent classes, and inherited classes (parent and inherited classes will be talked in a future post). I think a great visual of this is shown by the image below:

Pub_Priv_Prot

Wait, why not make everything public then?

Expose All Values

Well, not so fast! You don’t want to do that. I will talk in a future blog post as to why, but for now, just trust me on this one. 🙂

So, after this, we will create what’s called the constructor. The constructor is what it sounds like: it builds the class object when you ask for a class object to be created. This is what it looks like (shown in the example we’re doing):

class Person
{
public $sex;
public $hand;
public $hstyle;

public function _construct($mf)
{
$sex = $mf;
$hand = "right";
$hstyle = "straight";
}
}

So, the _construct function is what is called when you want to create a new class object. $mf is a function parameter that is called, which in this case will be the sex (male or female). In the constructor, I defined the hand and hstyle properties to be a default that I decided.

Ok, so this is all and good, but how do I use this? Well, to create a new class object, outside of the class definition, write this line:

$stanley = new Person("male");

Yep, that’s it. Pretty simple, right? Ok, so how do you define the other two properties for Stanley? Well, since they’re public, it’s pretty simple:

$stanley->hand = "left";
$stanley->hstyle = "curly";

There are other ways to set property values, which are shown here: http://php.net/manual/en/sdo.sample.getset.php.

This is simply just the beginning. I will go into more detail about some other OOP-related topics (including DRY, inherited classes, and parent classes) later on.

That’s all for now, until next time…keep that tech gear ticking.

~Goliath7470

Happy New Year!

January 1, 2015

Hello all,

Happy New Year to everyone! So, have you started on those New Year’s Resolutions that you created for this year yet? I sure hope so, as now is the time!

With this new year, we should be seeing quite a lot of new gadgets that will really be quite astonishing.

I remember many years ago, I got a Virtual Reality skateboard game. It was a lot of fun, and I really enjoyed playing the game. It was really cool putting on this helmet that basically took you into another world, and I skated around this virtual skate park doing all kinds of tricks. The foremost gadget is called the Oculus VR. This is a virtual reality helmet that is much more improved from previous virtual reality helmets. It also will allow development of apps that can be used on the Oculus platform, which is pretty awesome! I advise you to at least check it out and see for yourself. Would I buy it right now? No, it’s too soon for that, but I would keep this in mind possibly for the Christmas season this year!

I have ran into a dilemma recently in terms of my computers. A little while ago, I acquired a new (to me) computer, which is pretty awesome, but right now I have two keyboards and two mice in order to get everything to work properly. Well, this next gadget may help with this clutter as well as for those of you who are on-the-go and would like a keyboard for their mouse and tablet. It’s called the Logitech Bluetooth Multi-Device Keyboard. This gadget utilizes Bluetooth technology in order to allow multiple connections using one single keyboard, which is really neat. All you do is turn a dial to which device it should be actively using (1, 2, or 3). Simple, yet rather innovative. You can pick this gadget up now if you would like, or you can wait for more companies to create similar gadgets and price-check them all. Up to you! 🙂

These gadgets as well as more can be found at: http://www.itbusinessedge.com/slideshows/show.aspx?c=86885.

That’s all for now, until next time…keep that tech gear ticking.

~Goliath7470