• Post Reply Bookmark Topic Watch Topic
  • New Topic

Whats the point of an Object/Class?  RSS feed

 
Jonathan Vazquez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats the purpose of creating an Object? Whats the purpose of creating a Class?

i was told a class is to emphasize a better understanding and cleaner code however, can you just put all your code in the main()?

Also i dont understand the Object. I understand a ton of other stuff but not the object.

Cant we just use variable assigning for everything?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question isn't wether you can or can't put all your code in a single method, or if you can or can't just use variables in your application. The answer to those questions are yes: you can just use one method, and yes, you can do it all without Objects. But the question should be, can you do it well?

Imagine a library where all the pages to all the books were not bound together in books and the books weren't stacked in shelves and organized by author, subject, and name, but were rather stacked in lopsided piles in the order in which they were acquired or last used. Could this library function as far as storing books? Sure. Can it do so effectively? No. Can you find the book you want later on in this library? Sure, but it would take a long time. Are there better ways to store books and make them findable, referenceable, and make the library run more efficiently? Yes, by organizing the books, buy keeping the pages to the books bound together so they are always stored and locatable together, and having a system of referencing a single book in the large collection.

That is what methods, Objects, and Classes do. They organize your code (classes and methods) and data (Objects) so you can find it, re-use it, edit it, describe it, reference it when you need it in a quick and meaningful way.
 
Jonathan Vazquez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:The question isn't wether you can or can't put all your code in a single method, or if you can or can't just use variables in your application. The answer to those questions are yes: you can just use one method, and yes, you can do it all without Objects. But the question should be, can you do it well?

Imagine a library where all the pages to all the books were not bound together in books and the books weren't stacked in shelves and organized by author, subject, and name, but were rather stacked in lopsided piles in the order in which they were acquired or last used. Could this library function as far as storing books? Sure. Can it do so effectively? No. Can you find the book you want later on in this library? Sure, but it would take a long time. Are there better ways to store books and make them findable, referenceable, and make the library run more efficiently? Yes, by organizing the books, buy keeping the pages to the books bound together so they are always stored and locatable together, and having a system of referencing a single book in the large collection.

That is what methods, Objects, and Classes do. They organize your code (classes and methods) and data (Objects) so you can find it, re-use it, edit it, describe it, reference it when you need it in a quick and meaningful way.


WoW simply just WoooooW. I just completetly understood everything you've told me with such clarity i understood that efficiently and have a better understanding. Thank you for your time as i was able to understand with your very detail description of books and library. thanks
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand a ton of other stuff but not the object.


This reminds me a friend of my brother. He was good at math and understood a lot of stuff up to the point where "x" came. Because "x" could be 1 or 2 or anything!

(He became successful in the advertising profession even without "x".)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!