“A building contractor can understand a blueprint designed by
an architect because both of them use the same set of rules and conventions.
When you create a class, you’re the architect. The blueprint you must create
must communicate your ideas to the computer” (Mueller 250). A class is a set of
instructions used to describe the structure of the data. Through the book, I
learned what classes are and some of the fundamentals of creating a class.
First in
programming, a class is written out as “class” followed by a title. For
example, if I were to write out a program about books it would be written out
like this.
So far, I just
created my class, but it is not doing anything. So, to make it do something, I
can add a class constructor which basically creates an object in the class and
it is written out like this.
Now that I have the constructor, I can add specific details
that I want to include to the class. This would be called instance variables. For
example, I could add a publish date to the book class. An instance variable
would be shown as the “int” data type and it would be written out like this.
Now that I have the object and its specifics I can make it
more detailed by adding parameters to the class constructor. Parameters uses data
types with specific attributes. If, I was to input the date of the year of a
book published, it would just output the year date but not say it is the
publish date. To fix that, parameters are used, and it is written out like
this.
To recap, a class is a blueprint of how the data are laid
out. A constructor creates the object and an object stores the state of the class
in the parenthesis. Lastly, a parameter helps the object be specified when
given a value. There is more to creating a class, but this is what I have
learned so far. What do you think is the most important things to remember when programming?
Mueller, John Paul. Java eLearning Kit For Dummies. Wiley, 2014.
Hello Andrew, programming seems to be a difficult and interesting subject. I'm currently reading about chess and the idea that everyone uses the same rules and conventions also apply. Overall, this is a great post, it simplified class and made it a lot easier to understand. Is there anything else your expecting to learn about class?
ReplyDeleteHi Jay, I appreciate your comment. Just like how you stated about how chess uses rules and conventions, classes in programming also have certain rules and conventions as well. I am interested in learning more about the rules of programming and certain shortcuts when writing out a piece of code.
ReplyDelete