-->

Monday, August 26, 2013

Featured Web Series: Derek Banas

As yours truly has been been a bit busy grinding the old development stone as of late. For today's tutoring tip, allow me to simply feature the YouTube Channel of Derek Banas.

Amongst the more clear YouTube tutors, under him, you'll find a variety of tutorials and reviews covering concepts from the beginner to the advanced. Don't be afraid to check this guy out.

Since I've been on the topic of OOP basics, allow me to get the introduction started by featuring his first video on this.




Methinks to make it a regular feature to share those who prove clear in their content. Follow me for me for more to come.

Keep code crunching out there.  

~David Noble Morris~

*Got recommendations of your own? Don't forget to comment below and share!

Thursday, August 22, 2013

Code Concepts: What is Refactoring?


Basically, this makes it so that writing code DOESN'T have to be redundant and confusing. Imagine you had a robot that knew how to move forward, but could ONLY "turnLeft" (in hard, 90 degree angles for the sake of making this metaphor simple).

And lets say he's in some sort of maze like hall.

To get it out of that maze, say you had to beam it instructions to turn LEFT to begin -> move down the hall -> turn RIGHT at the fork it'll find -> keeping moving till the next fork -> turn right one more time -> and finally move forward to FREEDOM!

Since this gimped 'what-if' bot can only make left turns, you could mimic the effect of turning right manually in this manner (in psuedo-code. Again, for simplicity's sake):

Main Method
<-where the actual instructions are followed
moveDownHall();
turnLeft();
turnLeft();
turnLeft(); //the robot is now facing to where his right should be

moveDownHall();
turnLeft();
turnLeft();
turnLeft(); //the robot is now facing to where his right should be

moveForwardToFREEDOM(); //so ends the maze


How turning LEFT three times leads to one facing to their RIGHT isn't too hard to imagine I'm hoping. And by the example written above, I hope its equally clear that, regardless of the language we're using, typing turnLeft(); over and over can get very redundant, VERY QUICKLY.

Hence the Object Oriented Programming (OOP) concept of REFACTORING to rescue us -
whereas to save us time, we write instructions we know we'll repeat a lot into what's generally known as private "helper" methods.

This enables us to beam the instructions as follows.


Refactoring Method "turnRight()"

turnLeft();
turnLeft();
turnLeft(); //the robot is now facing to where his right should be


Main Method <-where the actual instructions are followed
moveDownHall();
turnRight();
moveDownHall();
turnRight();
moveForwardToFREEDOM(); //so ends the maze

Talk about headaches saved, am I right?

~David Noble Morris~

*Please share and like if this has been helpful. Leave comments below if there's anyway I can help clarify.

Code Concepts: Object Oriented Programming (Overview)

When you start out programming in a language like Java or C++, one of the first basics that is oft repeated is object oriented programming.

What is object oriented programming precisely?

Prior to OOP, procedural languages were the way to go. Languages such as BASIC, FORTRAN and the like. The issue with these languages were that they required one to rewrite and repeat code continually.

As such, OOP was developed, which gave substantial versatility and ease of use to the principles of programming.  It all boils down to three key concepts, which will be covered in more detail with time.

1) Encapsulation - This is when you protect your code to keep it from being utilized incorrectly. Hiding it so that its easy to use and change, yet doesn't influence (or is influenced by) the entire system.  Afterall, if a Ferrai isn't working due to a bad headlight, you replace the headlight, not the entire car.

2) Inheritance - When the behavior of one "super" or "parent" class is extended to a "child" subclass. What behavior is at the top falls to all children below it. This can be convenient, though care must be taken to properly define common features of classes.

A good test for inheritance is the Is-A test. Take being humans and its relationship to Animals.



Every Dog is an Animal. True
Every Animal is a Dog. False.


A salesman is a job.
A job is a salesman.


In this case, inheritance would apply.
3) Polymorphism - When a subclass is composed of its inheritors in a manner that allows a it to stand in for the superclass. This allows varied behaviors at runtime. In Java, this is achieved through interfaces and overloading (for methods and constructors).

Allows subclass to stand in for a superclass.

To test for such, HAS-A statements help clarify such relationships.


A human has a gender. True
A gender has a human. False


A human has a ethnicity.
An ethnicity has a human.


A human has a job.
A job has a human.


A human has a hobby.
A hobby has a human.

A human has clothes.

A clothes has human.


In this case, polymorphism can applies. Also known as aggregation or  composition. As we all know, human beings are complex creatures with their own separate qualities and interests.


Aggregate enough these various behaviors together however, and you can begin to narrow down to specific individuals.


Human1 has a gender of "male."
Human1 has a job of "president."
Human1 has an ethnicity of "black."
Human1 has a hobby of "golf."
Human1 has a clothing style of "business."


Human2 has a gender of "female."
Human1 has a job of "president."
Human1 has an ethnicity of "black."
Human1 has a hobby of "golf."
Human1 has a clothing style of "business."



~David Morris~

Saturday, August 3, 2013

How to learn to think like a programmer.

In my other blog I mentioned that it'd be prudent to give oneself projects to work on. And in this current market, the only thing that can be counted on for employment opportunities is being able to talk the talk of information technology.

The fortunate thing about the IT industry is that just about anyone, from any background can transition into it. For its less about "official schooling" and more about the willingness to teach yourself into being current. 

Here are just a few things you can do to get started. 

1) Seek out beginner tutorials
There are plenty of places one can go to train, already prepared for you at various levels of advancement. Want to practice web programming? Try CodeAcedemy. Already a bit of an advanced java programmer and want to grill yourself on thinking outside the box? CodingBat is a great place to drill yourself. 

I'll try to give more as I go along, but here's a taste. 

2) Bookmark the things you find
Its important to stick with it when practicing your software development skills. As you find resources that speak out to you, don't forget to mark them down in an organized fashion. A seemingly no brainer suggestion, but documentation is truly a programmer's best friend.

3) Start small and trust you'll grow big
I've mentioned before that its important to give yourself a project. For the new beginner, starting small by simply copying the tutorials is sufficient. As you grow in competency, I'd recommend forming ideas for a bigger fish you'd wish to fry with the skills you gain.

~David Noble Morris~

As a 3+ year java programmer, I have plenty more to say where the above comes from. Follow me to stay tuned on the latest tips and by all means, converse with me by leaving a comment below!