Pages

Thursday, July 23, 2020

Newbie to Newbie Blog Part Two

In my last post four weeks ago, I shared some advice about how to get up and running for coding with Java. I invited you to review some of the sources I used so you could start practicing. If you didn't have time, I understand, it's a lot of reading and experimenting. I have less hair now but more knowledge about algorithmic design in programming. Once again, I invite you to benefit from my struggles to help you along your way.

As you learn more about the syntax of Java and the concepts of object-oriented programming (OOP) you will appreciate the importance of data structures, and how to choose one over another when solving a problem. At its simplest, a data structure can be a list. If you need that list to be an ordered list it becomes slightly more complex. An even more complex structure would be an array containing arrays. It will be your responsibility as a programmer to choose the best structure for storing and manipulating data.

Every choice you make is a trade-off between time and space complexity. For example, you have a set of data that is accessed frequently by a search algorithm. As the size of the dataset increases, the space it consumes in memory grows, and the time it takes to search it increases. Choosing an implementation of a list that is sequential is better for a large data set because a binary search algorithm can locate values much faster. The trade-off is in the resources it takes to order the list as new elements are added, changed, or removed. The larger the dataset and the more often it is accessed, the greater the benefit of a sequential list.

The best tool for making choices in your design is Big 0 notation. Learn this first, and learn it well. Here is an excellent resource for learning how to apply it in your design choices. After you cognate on that, have a look at this and try some of the exercises to get a good handle on these concepts.

Thursday, June 25, 2020

Object-oriented Programming for Newbies

If you are new to object-oriented programming (OOP) like I am, you may find it helpful to read what I just learned through reading a few articles about it. For a programming language to qualify as OOP, it must include functionalities based on four principles.

First, there is encapsulation, which is kind of what it sounds like. We take an object and wrap it up so its inner workings are not visible so that we can control access.

Next, there is data abstraction, which is a fancy way to say, model, or template. If I were to describe to you a garden hose without showing it to you, I would tell you its color, diameter, length, material, and the type of fittings on either end. You would have a general idea of what class of hose I am describing and know if it can do the job you might have for it.

A third principle is inheritance. If my garden hose were a programming object, I could create copies of it, then add additional descriptions that correspond with a similar real-world object, like how long the warranty is, or what temperature range it can handle. I could change the default color inherited to another color.

And finally, we have polymorphism. Who comes up with this stuff? It just means an object has one name but can run in different forms. It is very complex, though, and I don’t quite understand it yet. 

I’ll be writing some basic programs in Java in the next few weeks, so I expect to have a better explanation for you soon. For now, I’ll provide links to resources I’ve been using to get up to speed.

Starting with the basics, here’s an excellent tutorial. When you’re ready to learn from the developers of Java, here’s the definitive reference. And here’s an older article, but still worthwhile, relating OOP concepts in laymen terms.

Thanks for reading.