Forums Register Login

moved class files into new package, application stopped working...

+Pie Number of slices to send: Send
Hi guys, I'm using eclipse, I've created a new project call part2 and a new package (a). copy classfiles from part1 into part2's package a and add

"package a;" to the first line of all class files but the things still doesn't work properly, some class file cannot access other class files. what should I check for?
+Pie Number of slices to send: Send
You should check for broken imports, since you moved your sources to a different package.
You can check the compilation errors easily by viewing the Errors tab.

Cheers
Claudiu
+Pie Number of slices to send: Send
 

Claudiu Chelemen wrote:You should check for broken imports, since you moved your sources to a different package.
You can check the compilation errors easily by viewing the Errors tab.

Cheers
Claudiu



everything compiled without issue, but certain methods doesn't work anymore. for example, static objects created are no longer accessible. that is very strange... those are marked as public, so it doesn't make any sense
+Pie Number of slices to send: Send
 

Randy Smith wrote: doesn't work anymore.


Are you seeing any Exceptions? Can you try deleting all previously created class files and then re-compile and run?
+Pie Number of slices to send: Send
 

John Jai wrote:

Randy Smith wrote: doesn't work anymore.


Are you seeing any Exceptions? Can you try deleting all previously created class files and then re-compile and run?



i'm not getting any exceptions, but methods ..e.g. class 1 that call methods in class 2 is use to work, now class 2 methods are not returning anything.
+Pie Number of slices to send: Send
Can you try to post some code of Class1 and Class2?
+Pie Number of slices to send: Send
Ok...I found out what is wrong now..

certain method execution are dependent on the name of the class, so if there is a package, it must be renamed into this formate package.classname
+Pie Number of slices to send: Send
Sounds like iffy design. If possible it's better to compare to class literals. So not but Can you show us the pieces of code that's using class names to perhaps help you find alternatives?

Also, Eclipse allows you to move classes from one package to another while updating references, both in code and in comments. I'm sure Strings can be updated as well. Just right-click, select Refactor, Move.
+Pie Number of slices to send: Send
 

Rob Spoor wrote:Sounds like iffy design. If possible it's better to compare to class literals. So not but Can you show us the pieces of code that's using class names to perhaps help you find alternatives?

Also, Eclipse allows you to move classes from one package to another while updating references, both in code and in comments. I'm sure Strings can be updated as well. Just right-click, select Refactor, Move.



Yes I did just that, i realise that it's bad design, and I'll get penalised for that. I'm too far out to fix that. I'm working on an inventory system and I was thinking having a massive arraylist that hold different kinds of item would be better than having to manage several arraylists that each hold just one kind of item. I wrote a a base class and extended subclasses. One arraylist defined as base class and I dumped eveything inside.

man... i'm so wrong, i had to write code here and there to keep things together. Any minor modifications or type-po breaks the code.
+Pie Number of slices to send: Send
 

Randy Smith wrote: . . . Any minor modifications or type-po breaks the code.

That is called tight coupling. If you depend on the name of the class, or its package, you are tightly coupling the implementation of one part of the code to the implementation of another. And you have seen how easily one can break such code.

I would have thought that you are linking number of items to type of items for an inventory. That doesn’t sound like a List at all, but a Map<Item, Integer>.
Bring out your dead! Or a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2105 times.
Similar Threads
questions about part2
Some confusing ones part2
Packages in class diagram (part2)
Doubt on SCEA Part2 Deliverables
Passed Part2/3 With 92
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:49:19.