|
I think the template class you're proposing is overkill.
(InventoryClass<E> is a template class. Fairly new to Java but has been
around for years in C++). Sounds to me like what you need is an
InventoryClass class that handles the difference between the two ERP
packages and can .toString() either one of them. The Item class doesn't
need to know. It just calls inventoryClass.toString() when it needs to.
Template classes are used primarily with collections, not singletons as
you propose. The classic example is List<E>. The old fashioned List
class is a generic class. It will manipulate a list of Object instances.
With List<E> where you use List<String>, you can construct an object
that manipulates a list of String instances. That eliminates the need to
cast those Object instances back to String and removes one more
potential for mistakes from your coding.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of James Perkins
Sent: Friday, March 06, 2009 1:48 PM
To: Java Programming on and around the iSeries / AS400
Subject: Re: Java and OO Concepts
Well, I guess I'm basing it on a file. The file obviously has a lot more
information than that, but the InventoryClass is used a lot for various
sorting or selections.
I would consider it an Item "has a" inventory class.
At this point we support 2 main ERP packages. One stores the inventory
class as a numeric field and the other as a string. The idea behind the
generics is that I would define 1 Item class and have it constructed
with the correct (Integer or String) generic type.
Like I said, I could be way off. I don't really have any other Java
developers I work with and I'm still learning myself. While I know there
are loads of Java examples out there, I don't ever really see any good
production code. So I apologize if this is kind of a dumb question.
--
James R. Perkins
On Fri, Mar 6, 2009 at 11:36, Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
wrote:
I'm having trouble understanding what it is you're trying to do. What
is the relationship between Item and InventoryClass? Is it a "has a"
or "is a" relationship. If it is "is a" then you want Item to extend
(or
implement) InventoryClass. What classes are you thinking about using
for E when you instantiate InventoryClass?
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of James Perkins
Sent: Friday, March 06, 2009 1:04 PM
To: Java Programming on and around the iSeries / AS400
Subject: Java and OO Concepts
Hi All,
Just looking for a little advice here. I'm trying to (still) wrap my
head around OO design.
I'm working on an application for order entry. I want to take a list
of items and turn them into an order. Not really a big deal, but just
the high level overview.
I have a class Item that looks something like this, mainly the
properties is where my question is.
public class Item {
private boolean active;
private String description;
private int inventoryClass;
private String ean;
private int inventorySubclass;
private String itemNumber;
private String keywords;
private String uom;
private String upc;
private double weight;
...
}
I'm wondering now, if inventoryClass should now be a new class
InventoryClass same with inventorySubclass and uom. Make it more
generic has I could make it more generic like so:
public final class InventoryClass<E> {
private final E inventoryClass;
public InventoryClass(E inventoryClass) {
this.inventoryClass = inventoryClass;
}
public final E getInventoryClass() {
return inventoryClass;
}
}
So, my question is this. Am I heading down the right track? Am I
thinking to RPG/procedural programming like?
Any advice is welcome.
Thanks in advance,
--
James R. Perkins
P.S.
If anybody is interested I have created a List factory class that will
return a generic version of a List without having to infer the
generics on the static factory method.
Example:
List<String> list = newArrayList();
If anybody is interested, I'm willing to share. I'm almost done with a
Map one too.
--
This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list To post a message email:
JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives athttp://archive.midrange.com/java400-l.
--
This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list To post a message email:
JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at--
http://archive.midrange.com/java400-l.
This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/java400-l.
--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
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.