× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



James Perkins skrev:
Thorbjorn,
Thanks for the information. I had a feeling I was not going about this in
the best way.

So, if I understand correctly, ideally you don't want to care what an item
"has", just what an item does.
Ideally you do not want to spread responsibility. The moment your item "knows" about inventory classes and inventory sub classes it has received the responsibility to handle those lookup values correctly, which doesn't necessarily make sense.

"Something" knows about the correspondence between these values and behaviour and I am pretty sure it isn't the item itself :) but perhaps the "load item from database" thing.

public Item createItemFrom(row) {
....
.... item.inventory = InventoryHelper.newInventory(row.inventoryClass, row.inventorySubClass);
return item;
}

then later you can do stuff like

item.getInventory.doInventoryStuffWithItem(item)

Decouple if you can. Will make your code less brittle.

In RPG I would look the item up in the item file and do what I want with the
data. I'm still trying to break that mindset and I'm finding it hard. Once I
introduce data into an object I keep having the idea I need to be able to
look at that data. Still don't understand it yet, but I think/hope I'm
getting it.
The major thing to get your head around with, is that code and data mentally sort of go together. If some kinds of data warrant special treatment you want to see if you can isolate that treatment and put it along with the data using inheritance.

That is hard to learn! Really hard :) (Pointers are easy in this regard) It has taken me a long time but I am getting it slowly.

As you are learning by yourself, I would recommend you look at "Head first Java", as they have a very different way of teaching these concepts. I learned a lot from their Design Patterns book. Available online at http://my.safaribooksonline.com/0596009208. ISBN 978-0-596-00920-5.

re, but here is a link to the source
for the ListFactory.
http://code.midrange.com/9b26a9bd93.html

It appears to be there :) I think I need to poke at it in Eclipse before I can figure out what the smart part is :)


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.