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 Beginning Java and the fly likes lame objects question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "lame objects question" Watch "lame objects question" New topic
Author

lame objects question

Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
Hi,

It makes me feel inferior to ask this, but I have a question about objects in classes. Well I am working with a canvas, and I decided that I want to make a seperate object to have contructors that keeps track of screenwidth ect.

like:




i constructed it in WorldGenerator (which contains my main class)



I can refer to the setting object anywhere i want in the world generator class. BUT i cant refer to the setting object in a different TileMap class, because it cant recognize symbol because i didnt construct the object in the TileMap class:



So i guess i pretty much messed up my design...
i also tryed using things like static and public, but it feels "wrong" and, it doesnt work anyway. I even tryed to extend the WorldGenerator class, but it causes compile errors with the paramaters in the TileMap constructors.
[ December 06, 2006: Message edited by: Keenan Staffieri ]
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
The reference to ProgramSetting could either be another parameter of the TileMap constructor, or the TileMap class could have a "setProgramSetting(ProgramSetting)" setter that is invoked after a TileMap object is constructed.
Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
but i never want to change the screenwidth ect, in tile map. i want to make it so i can use the 'setting' object in ANY class, but i guess my design is messed up since i am using the setting thingy in a class that shouldnt have to take screenwidth parameters in the constructor. any recommendations?
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
You can also make the ProgramSetting object in TileMap public and static, so that any class can get access to it without needing to have a reference to it.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: lame objects question
 
jQuery in Action, 3rd edition