This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes What Are The Guidelines For The Class Where The main Method Is? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What Are The Guidelines For The Class Where The main Method Is?" Watch "What Are The Guidelines For The Class Where The main Method Is?" New topic
Author

What Are The Guidelines For The Class Where The main Method Is?

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Suppose that I have a system. There are many classes within that system. What are the attributes and methods supposed to be in the class where the public static void main (String [] args) {} is?
And my second question follows: What if I have more than one system and these systems interact with each other?
Is there any principle to follow? Are there guidelines (patterns)? I raised these questions because from reading UML, I start to understand that
"an object-oriented system is composed of objects sending messages to other objects to complete operations. There is great variability in the potential quality of object interaction design and responsibility assignment.
Responsibilities are related to the obligations of an object in terms of its behavior and follow two types:
Knowing
oKnowing about private encapsulated data
oKnowing about related objects
oKnowing about things it can derive or
calculate
Doing
oDoing something itself
oInitiating action in other objects
oControlling and coordinating activities
in other objects
Responsibilities related to �knowing� are often inferable from the conceptual model because of the attributes and associations it illustrates. Responsibilities are implemented using methods that either act alone or collaborate with other methods and objects.
Some of these principles, applied during the creation of interaction diagrams and/or responsibility assignment, are codified in the GRASP patterns: Expert, creator, Controller, High Cohesion and Low Coupling. GRASP is an acronym that stands for General Responsibility Assignment Software Patterns. The GRASP describes fundamental principles of assigning responsibilities to objects, expressed as patterns."
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111
Well you main should be as small as possible !

public class Main
{
public static void main (String[] args)
{
new MyRealMainClass().do();
}
}

So the entry point can be the same while changing all the rest.
Your second question is far too generic to be answered in one post !
Choose a technology first (RMI, EJB's, JDBC, ...) & then you will be able to post a proper question i believe.


Thomas Smets
Just another developper
 
 
subject: What Are The Guidelines For The Class Where The main Method Is?
 
Similar Threads
simple question for u! - Urgent
Design Patterns...
Is There A Pattern For The Class Where The main Method Is?
PreAssessment Questions and Answers
Few Question For J2EE Developer