Author Topic: Java objects  (Read 2043 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Java objects
« on: August 24, 2011, 10:18:54 AM »
So in my class, I'm pulling all of the records of a certain type out to be displayed in a table.  Each record will have about 4 elements.  What is the best object to store the records in to pass that back to the JSP for display?

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Java objects
« Reply #1 on: August 24, 2011, 11:34:56 AM »
Create a class that represents the object and pass a List of those objects. Like class "Person" or "Sale" or whatever each record represents.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Java objects
« Reply #2 on: August 24, 2011, 11:59:57 AM »
Ok, unrelated question... what does it mean when something has a cast of <T>???

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Java objects
« Reply #3 on: August 24, 2011, 01:09:19 PM »
It means that class takes another class as a parameter, just like C++ templates. For example, if I want to make a Map class that maps strings to some arbitrary objects, I could make it be Map<T> and have it map Strings to objects of type T. The benefit is that I can have functions take parameters of type T, or have return type T and not have to constantly down-cast java.lang.Objects. Down-casting can be dangerous and results in run-time errors instead of catching compile time errors. Also, you can have things like Class<T extends OtherClass> and know that whatever class T is, it will extend OtherClass.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Java objects
« Reply #4 on: August 24, 2011, 01:09:39 PM »

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Java objects
« Reply #5 on: August 24, 2011, 01:51:19 PM »
I should have taken at least one more Java class in college.

charlie

  • Jackass In Charge
  • Posts: 7903
  • Karma: +84/-53
Re: Java objects
« Reply #6 on: August 24, 2011, 02:39:19 PM »
I don't know if Java generics existed when you were in college.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Java objects
« Reply #7 on: August 24, 2011, 02:59:41 PM »
Oh.  Well, regardless, I get hung up on stupid Java shit constantly.  Well, that and the massive amount of java objects in this code base that I don't fully understand.  I know what I need to do, but the simplest things, like reading from the DB are so fucking convoluted. 

webwhy

  • Jackass IV
  • Posts: 608
  • Karma: +15/-10
Re: Java objects
« Reply #8 on: August 24, 2011, 03:07:26 PM »
totally agree...raw jdbc is fucking terrible, and i'd imagine that's what you guys are using in an old JSP/Servlet app

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Java objects
« Reply #9 on: August 24, 2011, 03:17:05 PM »
Well... we are using Oracle's TopLink for cache management, which has it's own set of shit to deal with.  Like you have to create a descriptor of the class you're using and worry about which objects stay in the cache and which don't and a bunch of other things I haven't even figured out yet.

We have other libraries to write direct queries if we need to but I wouldn't say those are any easier.