CST 338 Week 4: Polymorphism

Give an example of polymorphism and what will be inherited between classes. Polymorphism literally means many forms. In an object oriented programming language, we can make methods take different forms through dynamic or late binding. For example, we may want to represent geometric shapes in our program, such as circles, rectangles, and triangles. We could simply code these classes independently. However, we might find there are some commonalities between each of the shapes and what information we want to encode about them. For example, it may be important to find the area of each of these shapes. We can declare all these common functions into an abstract class named Shape.

Shape would declare but not define the method int calculateArea(). We would create subclasses–Circle, Rectangle, and Triangle–that extend Shape. When these subclasses extend Shape, we are making a promise that we will define calculateArea in each of these classes. However, how we calculate the area for each of these geometric shapes is going to differ based on the individual formulae for each geometric shape. Although we have the same method defined in each of our three subclasses, they take different forms. This is the notion of polymorphism.

After the learning this week, can you identify the difference between Abstract classes and Interfaces?  Be specific.

Abstract classesAbstract classes AND InterfacesInterfaces
CAN contain instance variablesCANNOT instantiate an objectCANNOT contain instance variables
Subclasses can extend ONE class (can be abstract)Subclasses can implement more than one interface
Can provide implementations for some of its methods in addition to declaring abstract methods.Declares abstract methods to be defined in subclassesInterfaces don’t provide implementations for its methods (*as of Java 8, interfaces can define default methods)

Update your learning journal from what you experienced this week with class. I enjoyed this week’s project in creating an implementation of a barcode scanner. There was a lot of information to digest in the specifications and, after doing the UML (see below), I found it particularly helpful to draw out the various pieces and how they interact, especially when it came to implementing the DataMatrix class.

Below, you can find illustrations of my approach to most of the DataMatrix class implementation:

Week 3 CST 338: Inheritance & Arrays

What is the largest multi-dimensional array that you have used? For the scope of my previous classwork, I have only used 2D arrays (matrices).

What is the largest that you think would be unwieldy and why? I would imagine that anything above a 3D array would be hard to conceptualize as we live in a three-dimensional world.  

What does inheritance do for your classes?  Have you used it in the past? How? Inheritance allows us to generalize behaviors (methods) and characteristics (instance variables) from superclasses to subclasses. Overriding methods specified in superclasses allows us to redefine the behavior more specific to a subclass. For instance, you can create a general Bird class with a speak method that returns a String “chirp”. You could extend this Bird class in a subclass called LoudBird that returns the uppercase version of this String (super.talk().toUpper()).

Update your learning journal from what you experienced this week with class. This week was my first experience using an enum. I discovered that comparing two enum types via the class’ equals method really just utilizes the == operator so comparing with the method and comparing with the operator are essentially equivalent.

Week 2 CST 338: OOP

OOP is not in all languages.  Have you used one that does not?
Previously, I have the LISP language (more specifically Common LISP or CLISP) in a course in Artificial Intelligence.

What was your experience? My experience with functional programming was fun. I learned functional programming before OOP, but I see the merits of both depending on whether or not one wishes to isolate data (classes/objects) from behaviors (methods/functions).

How extensively have you used OOP outside of the classroom? Besides my own personal projects, not a whole lot. I am currently seeking opportunities to exercise this skill more through internships.

Are you experienced with UML diagrams and do they help? I am familiar with creating UML diagrams and I believe they do help me visualize and plan out a program with many different classes and methods.

Update your learning journal from what you experienced this week with class. So far this week has been more review for me since I am familiar with OOP using Java.

CST 338 – Week 1

Have you used Eclipse before?  While I have used Eclipse before, I am more proficient with and used to Jet Brains’ IntelliJ. Therefore, I will be sticking with IntelliJ, as permitted by the professor.

What languages are you proficient in at this point? I am most proficient in Java and Python. I have some experience with C, but I would like to continue to developing my experience with it. I’d also like to spend some time with C# working with the Unity Game Engine this summer. For web development, I have experience working with JavaScript, HTML, and CSS. After having recently completed the databases course, I feel pretty proficient with MySQL as well.

What is your desired field of Computer Science at this point? Software engineering. I’d also like to maintain a presence in CS education as well.

What have you learned this week? This week primarily focused on String manipulation. Having taught AP Computer Science A for the past three years at the high school level, in which the language of study is Java, this was a review for me. However, it was necessary to adhere to the professor’s programming guidelines, so I did have to review his guidelines as well. They are not dissimilar to what I expect my current students to follow.