Classes or Methods


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Classes or Methods

  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Classes or Methods

    Using java, is it better coding practise to use classes or methods to carry out tasks?

    Currently doing a project so want to get the most marks possible so would like to know the better way!

    Thanks..

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    This is a rather strange question. Classes are definition if methods and state, so it doesn't make much sense asking which one you should use since to use a method you need a class and for a class to do anything useful, it has to have a method!

    However, what I suspect you might be talking about is something like this:
    Code:
      public class MyLibraryMethods {
        public static void function1() {
          ...
        }
        public static void function2() {
          ...
        }
        public static void function3() {
          ...
        }
        ...
      }
    ...where a class is definied which does pretty much nothing but hold unrelated methods. There are a few cases where classes like this are need (such as java.lang.Math), but generally this is bad practice.
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Dec 2003
    Posts
    10
    I have yet to create a method without creating a Class. I know I will get it one of these days....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center