The first few things i struggled with in CSC148 was the fact that i had to give up coding the way i was comfortable with and start coding in an object-oriented manner. How does someone give up something they're comfortable with and start following the convention? It's like handing a crayon to a kindergarten student who has gotten used to scribbling and then telling them to colour inside the lines. Not so easy, i say. However, i learned a lot and realised it's much more organised.
When we were doing the assignment, i was told numerous times, "create a class for game strategy that is generic for all games, create a class for game strategy that is generic for all games". I would hear this every day and i got the gist but i never clearly understood how to apply it. We got the marks for our assignment back and i lost a few points for the fact that "generic class still contains aspects of subtract-a-square. Not generic enough". After a few more readings and a little bit of hitting my head against the wall, i realised that you LITERALLY just separate everything that's common into a main class and everything that's specific into a subclass. Simple enough. Reading this you may think "duh, wasn't that obvious?" but trust me, i'm a first year student and i may not be as sharp as the other kids in the class so it really takes some time to solidly understand these concepts when you're doing it for the first time.
Here's what i've learned so far:
- Everything with a state and behaviour is an object
- When you create a class, you create a design that allows the creation of objects
- Classes are generic so they're the most simplified version of any object that is created eg. the object "laptop"
- Inheritance allows the generic class to be taken further and made into something that is more specific eg. "Macbook", "Sony", "Asus" etc...
So hopefully, i have gotten the hang of it by now and perhaps in the future, i will be able to write codes that are more object oriented and not screw up. I guess that's how learning works, right? At first you're just like "umm...what?" and then later you laugh at yourself for not knowing how to do it the first time. "What the heck? Was i really that dumb?"
Ideas in this blog were stimulated from this website: http://docs.oracle.com/javase/tutorial/java/concepts/index.html
No comments:
Post a Comment