-->

Wednesday, November 13, 2013

Introduction to Unit Testing with JUnit

Often overlooked, testing is an important phase of any software package.  Without it, one can find himself with code that compiles, thinking that it works, only to discover a major gaff in the program later on.

It is imperative that certain best practices are followed when it comes time to test one's program. What follows are among such tips to keep in mind.

  1. Test one thing at a time.
  2. Have your tests ready before you start coding.
  3. Keep your test suite seperate from your main code.
In today's world of software development, tests can be easily automated using functions such as JUnit. These interfaces can save you loads of time in the long run.

More tips on precisely how this is done will be available in future articles. For now, allow me to feature the tutorial of one such "Simplyianm" of youtube, and his excellent introduction videos to the concept of Unit Testing.

Below is a decent introduction on how to get started with it:
<iframe width="560" height="315" src="https://www.youtube.com/embed/lYnMyi81hrs" frameborder="0" allowfullscreen></iframe>

~Code Crunch Out~

Friday, November 1, 2013

Procedural versus Object Oriented Thinking. How do you know which is which?

Its often befuddling what is really meant by Object Oriented Programming, and what supposed to really make it special.

To truly appreciate OOP, it helps if one is familiarly ~w a r y~ of its opposites: Procedural Programming.

Its important to know and appreciate the difference. For as it turns out, just because you're familiar with a OOP language, doesn't mean you're thinking and writing in an OOP fashion.

So again, what does this all mean? I've already begun explaining what explained what OOP is. What is Procedural, and how does it compare?

Procedural Programming generally breaks down things functionally and then just goes with it. Imagine for instance, building an entire project in one massive main method().

Doable, but then what happens when something CHANGES? The true key of object oriented programming is in making things easy to change WITHOUT making code so convoluted over time, that it becomes difficult to maintain.

Object Oriented Programming principles thus evolved, with the three primary features to keep in mind being to keep your code well encapsulated (ie, protected against errors), with excellent use of polymorphism and inheritance to delegate behavior within your project. In this way each class may have only one reason to change if necessary, and when requirements change, all that's generally necessary is to add in additional plug ins that do not break what has already proven to work.

I know this all sounds greek now, but in future updates I intend to further break down the value of these terms. For now, think of it this way:

While procedural programming attempts to have one file do ALL the work...

Object oriented programming understands how to delegate the behavior of their project as "teamwork" amongst multiple files.

 ~Code Crunch Out~

Monday, October 28, 2013

Code Concepts: Data Types

Having been sometime since our last venture here on Code Crunch Corner, lets explore a very basic terminology: Data Types.

Be you a web designer, software engineer, or database manager, there are several basic, primitive data types that are typical of most languages. The following are as basic examples.
  • Character (or char)
    • Single byte characters of any "written" type. 
    • Eg: 'a', 'e', '!', "8" and ' ' (aka a space).
    • Notice that BLANK SPACE itself is a type of character.
  • String
    • Think of these as full sentences. Often composed of characters, there are multiple ways to splice them. 
    • Eg: "This is a full sentence. ", "1942", or "*#)$!$"
    • Notice again that blank space is included when making strings.
  • Integer
    • The most basic kind of whole number, and often the first type programmers learn to do math with. 
    • Eg: 1, 2, 3, 4 
  • Double
    • Just as integers, these are number that include decimal points
    • Eg: 1.5, 2.3, 3.8, 4.7
Why is this important? Often (as is the case with Java), working with them requires the finesse of certain "static" or "wrapper" methods between them to convert types.  Strings for example, are often used when you want to display things or input things, but the language only understands how to do math if things are int the form of integers. 

In keeping things consistent, they are often named something along the lines of .toString() or .parseInteger().

More on static methods, type casting, and the like in the future. 

~Code Crunch Out~

Thursday, September 12, 2013

Social Media Widgets

When forming a blog or website these days, one thing is certainly crucial.

Whatever your template, its CRITICAL that you form a social media presence.

There are many ways one promotes such a presence, such as Search Engine Optimization (SEO), tags and branding, icons and logos, etc.

Today, however, we focus on a simple question: WHERE do I get those fancy little SHARE buttons?

Such buttons are HTML code that can be automatically generated for you at the various social media cites. For your convenience, I list the pages here.

1) Facebook Like Button

2) Twitter Follow Button

3) LinkedIn Share Button

4) Google+ Button

Once gather, you can create a template for them simply by collaging the code as such in the following example. It can then be saved as a .xml template for your future use.


Technical functioning aside, the most important thing is to have them. Why? So that your readers can SHARE them!

So please, if you find this advice useful towards establishing your own online presence....

Like


Re-Tweet

Share

Follow


and

Leave a comment below!

Its highly encouraging, and bound to result in more ways I can help one's technical talents in the future! Stay turned for future updates to Code Crunch Corner.

~David Noble Morris~

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!

Monday, July 1, 2013

Coder's Log...How and Why You Should Maintain Them

Continuing from a post I made to young graduates on giving an internship to yourself, I thought I may as well give an example of how to do so.

LOG YOUR PROGRESS

With every iteration of one's work, its important to log and chart yourself, somehow, someway. In practicing what I preach, I figured I'd grant an example right here, as I would go about on the exciting journey of developing an atm machine (more on that in a future post):

~~~
Progress Log - June 27th and 30th
I continue to make forward progress on the bank simulation synthesis project. Software Development Guide now 10 pages and progressing smoothly on the accordance to my assigned timetable of my first iteration. 

Additional Notes
I wish I could move this a bit further, but as the only person on the job, I'll have to forgive myself.

Progress Log - July 1st
Practiced some CSS coding as warm up. Tested and successfully ran my first proof-of-concept GUI for Android. I belief I now understand how to make any program I've previously written run on a phone. Adapting to Eclipse has proven not as complex as I thought, and continued practice will assuredly serve to make me all the more comfortable.

But first things first. Time to consult the SDLC again and recall my next step.

Next Goal Note: 
Incorporate a database management system into the project...time for more research. As well as updates to my UX diagrams in light of new tools I'm made aware of.

~~
A good log document keeps it simple.  If you'll notice, this entry also backlogged for several days. So its not like you have to make an account every single day, but simply, that you jot as much as you can periodically. When you do so, it'll do wonders for keeping you motivated and on task.

More importantly, it'll work wonders on the concepts of TESTING and ITERATION. But more on that for another day. ;)

~David Noble Morris~

Thursday, January 24, 2013

Darksiders Review

Only just now gotten around to this game as a result of the Darksiders Franchise sale earlier this month. Vigil Games, being a brand new studio to the highly competitive game industry, decided to play safe by borrowing from other franchising with a focus on polish and execution. Given such, my overall impression of Darksiders has been that of a nine out of ten experience.

The storyline premise centers around the Horsemen of the Apocalypse in their role as liasions between the bitter forces of heaven and hell. As the Horseman of War, you are engaged in a celestial conspiracy that's has doomed mankind. The mystery behind the destruction of man  serves serves as excellent motive for the player.  Driven to avenge the downfall of man, War becomes a memorably likable tale's end, with plenty potential for expanded storyline. 

As stated, Darksiders is a new IP made by a rookie studio with much to prove. As such, they chose to follow reverently in the footstep of other successful franchises in a master crafted demonstration of competence. It'd be easy to simplify it as a rip-off in the matter, though one must remember that its only a rip-off if it sucks, otherwise its a homage.

To set the right expectation, best to think of Darksiders to games as a movie like Kill Bill or the Expendables are to movies. In this case, God of War and Legend of Zelda are the central foundations.  Each journey to the next LoZ style dungeon usually involves a cinematic fight sequences inspired by God of War, though impressively there will be moments reminiscent of other titles, including Panzer Dragoon, Portal, and even Gears of War.

Having played many hack and slash titles before, I can claim that while it comes close, it lacks the full depth its source material such titles. Hack and slashes require two things to work: Enemy variety and interesting toy and techniques to play with. The enemy variety is certainly there, though the amount of methods to kill them all wasn't quite there.


However, highly engaging combat never was a hallmark of the Legend of Zelda series. Thus, while the combat lacked the true depth of a Ninja Gaiden or Bayonetta, this is forgivable given that the Zelda segments would really shine, implementing puzzles and boss fights that'd truly make Nintendo blush.

Overall, for the first game of a new studio, Darksiders excels in execution and polish. There is one sorrow note however: the music. Though commissioned by Mike Reagan and Cris Velasco of God of War fame, its clear that they were uninspired for this game. There you'll be after witnessing War do something cinematically impressive, and now you're cutting down hoards of the angelic and demonic creatures almost feeling like a true horseman...only for the music to be half asleep. Took me three days to identify what if anything, was a main theme, and nothing caught my ear during the set pieces. The more I realized this game deserved better music, the more this flaw started to irritate me. Nothing much epic or memorable about it, and that's why I have to dock this otherwise 9/10 game as more of a 8.8/10.

Having started its sequel however, it appears that Vigil Games were aware of this flaw. The sequel's music is more like it. But that aside, Darksiders is a fresh new franchise you can't help but respect. Just give it time to grow on you.

Thursday, January 17, 2013

What This About

I started this blog to consolidate a certain few passions in my life: This blog is about one awesome passion in my life:

1) Software design 2) Tutoring. 3) The occasional video game review. Which I'll try to keep from an technical standpoint.

As software design would become an ever increasing obsession on my part, I simply figured that it is here where I'd consolidate the lessons learned on my journey, to the benefit of others. I hope that for any who follows along, they'll be able to learn some things about how to think like an IT specialist.

~David Noble Morris Out~