This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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

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

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:
oKnowing about private encapsulated data
oKnowing about related objects
oKnowing about things it can derive or
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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: What Are The Guidelines For The Class Where The main Method Is?
It's not a secret anymore!