• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Whats the point of an Object/Class?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic