Wk02: Learning Journal HW 01
Flavio Cervantes
CST338-40_2252
March 18, 2025
The unit test that was a challenge to pass was
addLine(string), this is because at first I didn't fully understand what it
mean stating " String is split into individual words", once I figured
it out I felt that this one made me the
most proud of figuring it out. I thought that toString() of the HashMap
words was the easiest since it simply returns the toString of the HashMap
words.
This week entailed of a further understanding of
HashMaps<String, Int>, these are used to store pairs of data that can be
accessed by using .get(String) and to finally iterate through the hashMap, one
can use a for loop. I also learned about inheritance using interfaces, these
are helpful because one can build a class and build "sub" classes
from the main. This is helpful because one can structure their code in a
methodical manner that is hierarchy focused. Which is commonly known as a
"is-a" type of relationship. I also learned that interfaces are for
classes that are not related closely, quite the opposite; abstract classes are recommended
being used for related classes. Learning about deep copy vs. shallow copy was also interesting, now I understand when to use one and the difference between them both. These topics were a bit challenging, but
they are getting easier to understand as I am utilizing it.
What went well was getting a better understanding of static.
I learned that static members cannot be utilized in this or super inside static
blocks. They [static methods] cannot access non-static members. Static blocks
are best used for initializing static variables, executed once the class is
called. In a nutshell, these statics can be used in scenarios when one is
working on Math/Collection related classes, constants such as PI, or global
variables that are shared throughout the rest of the instances. These lessons
will influence my work in the future by giving me a better understanding of
these certain functions and knowing when to apply them.
Comments
Post a Comment