DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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....

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links