Sunday, March 28, 2021

CST 338 - Week 4

Polymorphism


Polymorphism in Java deals with the concept of "late binding." Late binding allows objects to be assigned the proper method definitions after compile time. This is important because inherited objects may need to override a method from an ancestor class. If the parent method was bound at compile time, derived objects would be unable to override it. The Java runtime determines if a derived object needs to use its own version of a method and binds that version to the object, allowing polymorphism to occur. Polymorphism allows a derived class to inherit the properties and methods of its ancestor classes while retaining the ability to morph those methods for its own purposes.  

A quick example of polymorphism would be if you created a Ball class with the basic properties and functions of a ball, such as color, size, and move(), and then you used the Ball class as a base class for different kinds of ball classes, like Basketball, Baseball, Bowlingball, etc. Each type of ball inherits the basic properties of the Ball class, but their move() methods are all different. A basic ball's move() method may simply be to roll, which works for Bowlingball(), but a basketball's move() method requires it to bounce, and a baseball's move() method requires it to be pitched. Polymorphism allows each derived ball class to modify the inherited move() method for its own specific purpose. Furthermore, a programmer can conveniently store different kinds of balls in the same Ball[] array since they are all derived from the same Ball class.

Abstract Classes & Interfaces


An interface can be thought of like a blueprint for a class. Methods are declared in an interface but not defined. Interfaces work as a guide for programmers to create a working class. For example, a Map interface would declare all methods required for a derived class to actually be a "Map." The derived class must define all methods declared in the interface. Any programmer who uses the Map interface can be confident that their derived program has the minimum functionality of a map because they based it on a blueprint.

An abstract class is similar to an interface but can be thought of as more of a skeleton than a blueprint. It is not a complete (concrete) class and cannot be instantiated on its own. It must be extended by another class. Abstract classes contain abstract methods which are left undefined. These methods are meant to be defined by an implementing class. Unlike an interface, however, abstract classes are able to define other methods. For instance, abstract classes can implement interfaces. 

Keeping Up


This week was less stressful for me than last week because I was not the project manager. I was able to just focus on my part of the assignment while still being available to help my teammates if requested. Oubarcode scanner seemed to come together easily, despite having a couple of tricky parts. I am still learning how to collaborate with others. It can be hard for me not to just fix code myself if the errors are trivial. Sometimes it does make more sense given the limited time we have, but I need to also be respectful of my teammates' boundaries.

Sunday, March 21, 2021

CST 338 - Week 3

Arrays & Inheritance


This week we reviewed arrays and inheritance. I cannot recall ever using an array larger than 2 dimensions. I can visualize and (probably) use a 3-dimensional array, but 4-dimensional arrays and beyond become harder to grasp. I suppose a 4-dimensional array could be used to augment a 3D array with a time scale. Anything beyond that would certainly be unmanageable for me. I am not even sure what a 5th dimension would represent, although a Google search returns answers like this one.

Inheritance gives children (subclasses) access to the methods of their parents/ancestors (super classes). This creates a hierarchy of related classes that share common methods but also retain their own unique methods/properties. I have used it for various assignments, one of which had me create different vehicle classes, like Truck and Car, that inherited from the Wheel class. A real-world example is the C++ I/O library, where all input/output classes ultimately inherit from the ios_base class. Java uses a similar concept.
 

Keeping Up


This week brought our first team assignment. It was also my week to make a video about how to solve the programming problem. That alone brought some new experiences and challenges, but I am mostly satisfied with how it turned out. I also volunteered to be the project manager for the week since I would be analyzing the entire program for my video anyway. The role has allowed me to learn more about using Git to collaborate on and manage a software project. My group intends to rotate the project manager role for the remainder of this course.

Thursday, March 11, 2021

CST 338 - Week 2

Object-Oriented Programming (OOP)


The first programming language I learned, mSL, uses a combination of event-driven and procedural programming. Each script I wrote was in a single source file, no matter how long. My largest script was over 1400 lines. The IRC connection portion was procedural and the channel protections were event-driven. Source files were loaded individually into the IRC client and interpreted. This was all normal to me as I had little-to-no exposure to other programming languages.

A few years down the road I discovered Java and, by extension, OOP. My first programs were styled similarly to my old mIRC scripts: one massive source file. I don't think I really understood what OOP was even though I was writing Java programs. I didn't really begin to understand until I attended community college. In any case, I have written a few useful programs outside of the classroom (mostly in Java). My latest project incorporates flow charts that I created when re-writing the project. It was a massive help. I have not created my own UML diagrams, but I was exposed to them in a previous class.

Keeping Up


Our lab assignment this week was a simple casino app. The point of the project was to test our ability to follow program specifications. We've been told this is not a creative design class and that we need to refrain from going off-script. I am often guilty of trying to reinvent the wheel. It's challenging for me to implement code that has been designed by others. I like doing things my own way. Hopefully some day I will be in a position to make the rules instead of follow them. Until that day, however, it is important to follow the blueprints that have been provided. I am looking forward to our first group assignment. 

Saturday, March 6, 2021

CST 338 - Week 1

Intro to Java


This week brings the start of our software design class. We will learn the standard way to develop applications for the rest of this program and beyond. It is recommended that we use Eclipse IDE, which is the first one I ever used. However, my preferred IDE is now IntelliJ. I plan on using it for this class and future Java classes. As it turns out, Java is my favorite programming language. I have written programs in other languages, but most of my experience is in Java. I love it. 

The biggest drawback to specializing in Java is that, assuming I become a developer, I will likely have to use another language for my chosen field. I have an interest in computer security, particularly antivirus software. I doubt that Java plays much of a role in that realm because of its slower speed and lack of direct low-level facilities. However, I am confident that I can quickly learn a new language as long as it's C-based.

Since this was the first week of class, we did not do very much. We had a simple lab that was meant to familiarize students with Eclipse and Java. A large list of style rules was provided for us. It is important that students learn a proper coding style before hitting the workforce. I believe the style I use is a form of K&R. I don't anticipate losing many points for style infractions, but there often seems to be something that I overlook. 


Beneath the Old Pine

I’m sitting under the old pine tree in Sunrise Park — the one that leans gently toward the fence line behind my childhood orchard. From here...