CST 338 - Week 1
CodingBat Experience and Challenges
I completed every single challenge this week and saw the many ways that Java's different elements can work together. I did challenges from all 6 categories (String-1, String-2, Logic-1, Map-1, Functional-1), and each category needed to use a different way of thinking.
For the String-1 and String-2 challenges, I focused mostly on manipulating strings. For these, I thought about methods such as .substring(), .equals(), and .indexOf(), which I found in the Java Help section. I had difficulty initially with these challenges since I had to be so particular about the position of the strings and also keep in mind that Java strings cannot be modified once created. When I finally took a deep breath and broke down what I was going to write, I began to get them correct. I have come to realize that when I take the extra minute to write an example or two on paper before writing a program, it makes it infinitely simpler.
The Logic-1 category was completely different - it was more about logic and using boolean expressions like if, &&, and ||. I enjoyed how these puzzles required you to use your logical thinking versus the Java syntax. Initially, I would overcomplicate these and write too much code, but then I learned to condense my conditions into one line. The Java If and Boolean Logic help pages and videos were a huge help to me as they provided simple examples that made the logic click.
I worked on Map-1, which introduced me to using map.get() and map.put() without loops. I enjoyed this section of challenges as I was able to see how maps will store and update key-value pairs. It felt good to organize data efficiently and print out results, rather than just printing results. The Java Map Introduction and Map WordCount sections in the help menu were helpful to me in understanding how to avoid overwriting values or encountering null errors.
Functional-1 was probably my favorite section although it was the most unique. These challenges utilized functional programming with lambdas - such as using .replaceAll() and .map() to manipulate lists. Although the syntax for these confused me initially, after viewing the Java Functional Mapping and Functional Filtering videos, it clicked. I liked how the solutions for these challenges were very compact - i.e., strings.replaceAll(s -> s.toLowerCase()), nums.replaceAll(n -> n n). It made me appreciate how powerful Java's newer features are for working with collections.
While solving the challenges, I attempted to plan out my strategy, instead of just randomly writing code and hoping something works. When I stopped to think about the problem.. like what am I trying to accomplish here? I almost always got it right in two or 5 attempts. When I rush and just guess, I tend to spend more time trying to figure out why its all failing. I've discovered that taking the time to thoroughly read the examples, and test small cases first, saves a tremendous amount of time.
In total, the CodingBat challenges allowed me to see how I can utilize all of the techniques I've learned this far, like string manipulation, logical thinking, mapping, and functional programming. By the end, I was solving problems faster and writing cleaner, shorter code. While it took more than a few attempts per problem, each attempt helped me better understand the "why" behind the solution.
I believe I'm much more confident in utilizing Java's built-in methods especially replaceAll, toLowerCase, and substring and its newer functional tools. The CodingBat challenges illustrated to me that coding is actually about problem-solving and thinking logically, not just simply memorizing syntax. I feel much more prepared for future programming assignments now that I have practiced breaking down problems and developing efficient solutions.
Comments
Post a Comment