File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to split my code to make it more understandable and comfortable? 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 » Beginning Java
Bookmark "how to split my code to make it more understandable and comfortable?" Watch "how to split my code to make it more understandable and comfortable?" New topic
Author

how to split my code to make it more understandable and comfortable?

sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
Dear friends,
I have a class which is about 1000 line. So, I decide to break it down into small methods or classes. But, here is my problem, in the new method, I can not call some methods which are pre-defined for this class object. let me give you an example:
I have a Class which extends Agent class from"jade.core.Agent".


So I am capabale of using:
1)myAgent(which is a member variable)
2).send() method which let me to send a message from myAgent to another agent.



How can I define a method that let me to access this member variable and predefined methods of this class???
Do I need to define a method and then make a new object from class CoordinatorAgent? (But it means that all the code hat are in CoordinatorAgent will be executed again!!! which I dont want!!!)

Please help me out, Thank you beforehand.
Sahar.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Don't understand the question. Sorry. Why can't you cope with a 1000-line class?
sahar sa
Ranch Hand

Joined: Jul 06, 2009
Posts: 102
dear
actually I have several class and each of them contain about 1000 line. Well, it makes me confuse, some times Im lost in my code, there are many if s and for s which makes it hard to manipulate the code. So, I decide to cut some parts of my codes and then put it for example in some methods inside of my class. So, its more easy to read and change!
Sorry, let me explain again:
I have a class called A which extends jade.core.Agent class. I want to cut some part of codes from class A and put in a method called B. I make put method B at the end of class A.
e.g. In class A I have a piece of code like :

So I cut it and put it in method B. But its not accessible!! myAgent variable and .send method are from class Agent!
How can I have access to this variables and methods of class A?


Thanks,
Sahar.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
If it ain't broke, don't fix it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to split my code to make it more understandable and comfortable?
 
Similar Threads
null passed as parameter
Interface and Abstract
private constructors
Extending classes in which member variables also need to be extended
inheritance homework assignment - im stuck