• Post Reply Bookmark Topic Watch Topic
  • New Topic

my head is breaking apart thats all i can say  RSS feed

 
joseph dela cruz
Ranch Hand
Posts: 38
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am just new to OOP and i am trying to do some self study and experiments. i am trying to retrieve an Item name from derby together with its characteristics then put it in a list of bags together with its characteristics but i am having problems in getting a specific Object declaration that has a specific attribute like "name"
i have tried
putting the attribute in a list but it only says get index
i have tried to make set methods too but my mind is blank

and by the way comment also on the program if its Object Oriented or no.

thanks a lot more power to this forum

and lastly i have not run this program yet since i am stuck in retrieving a specific object so i do not know if the rs.executeQuery() in loadItemsToList() will work
just fine or if its even possible

 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joseph dela cruz wrote:and by the way comment also on the program if its Object Oriented or no.

The fact that every method and field in your class is staic would definitely point to it being NOT object oriented. The clue is in the name - object oriented programs will most likely make use of objects - you never create any.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
writing 100+ lines of code and only THEN trying to get it to work is going to cause you a LOT of pain.

a LOT.

Never never never write more than 2-3 lines before compiling and testing. This CANNOT be stressed enough.

Do not write a second setter until the first one works.

I probably wouldn't write any setters until my getter works.

ok, i may write them in pairs, but if I did, my first go at the setter would so nothing more than set exactly what is passed in. once that worked, i'd start adding the logic (if needed) to validate the data a piece at a time.
 
joseph dela cruz
Ranch Hand
Posts: 38
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but if i removed the static in the nested classes it will say cannot reference from a static context etc. etc. and if ill make a different separate class that has separate file then it would be too bulky please help me
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joseph dela cruz wrote:and if ill make a different separate class that has separate file then it would be too bulky

This is an attitude that you need to unlearn, and quickly!
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joseph dela cruz wrote:if ill make a different separate class that has separate file then it would be too bulky please help me


No. It will NOT be "too bulky" if you do a proper object-oriented design and use two classes. It's hard to say anything nice about the idea that you have to put everything in one class, so I'm just not going to say anything about that idea at all.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and if ill make a different separate class that has separate file then it would be too bulky

When does software or source code become "too bulky?" From where did you get that idea?
 
joseph dela cruz
Ranch Hand
Posts: 38
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
joseph dela cruz wrote:and if ill make a different separate class that has separate file then it would be too bulky

This is an attitude that you need to unlearn, and quickly!


so separate file is better than nested classes? or non static Object class plus nested class within is ok or i should really make separate files? and also when to use nested classes? anyway thanks ill try to unlearn the bulky thing as soon as possible
 
joseph dela cruz
Ranch Hand
Posts: 38
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Brannon wrote:
and if ill make a different separate class that has separate file then it would be too bulky

When does software or source code become "too bulky?" From where did you get that idea?


it is when you have to do extra clicks anyway thanks for the comments i am really below beginner level
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what is called a "Big Ball of Mud" - everything is lumped together into one class. I don't think you should even try to hit a database right now. Get the basics right first. What you have is not very OO.
 
joseph dela cruz
Ranch Hand
Posts: 38
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:This is what is called a "Big Ball of Mud" - everything is lumped together into one class. I don't think you should even try to hit a database right now. Get the basics right first. What you have is not very OO.


yeah but my two subjects now requires database and one is case study i guess this is the price of not studying my previous subjects seriously im stuck in a big ball of mud

i have already hit the end of the tutorials i want to further my knowledge Kabayan junilu do you have small oop sample that i might have to look at its ok with me if you will empty methods just like on your old example before
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, here are some initial tips for you:
1. First, start with the core classes - identify the entities that you want to model as objects
2. Identify what each class is responsible for in the overall system - one class: one responsibility
3. Identify other classes that each class will work with to accomplish a task
4. Databases and data storage are infrastructure concerns - worry about those later
5. User input and display are presentation concerns - worry about those later as well

As Fred advised earlier, test each bit of functionality as you write it. Only build out more functionality as get everything you have so far working.

So, to start you off, what exactly is the problem you are trying to solve? What is this program all about? Tell the story from the point of view of the user who will get a benefit from your program. Remember, the user doesn't care about databases or objects or classes. He cares about getting something done. What is that "getting something done?"
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joseph dela cruz wrote:yeah but my two subjects now requires database and one is case study i guess this is the price of not studying my previous subjects seriously...

The partygoers lament. Sorry chum, can't help much except to say: been there, done that; got the T-Shirt.

If your latest project/case study involves a database then you need to look up the tutorials for JDBC PDQ...and there's a lot to read.

And, as Fred says, writing a hundred lines of code and expecting it to work first time is stupid (and again, I say that as someone who's done it).
I'm not so sure about his 3 lines of code, but a method? Certainly. That deals with a database? Duplo-certainement-absolutamente.

Write a database connection method. Test it. Does it work? If yes -file it; if not - find out WHY NOT before you write another line of code.

And do the same thing for everything you write; otherwise you are doomed to a life of trawling through stack traces in search of the 'embedded bug'.

Winston (ex-partygoer)
 
joseph dela cruz
Ranch Hand
Posts: 38
Chrome Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i do not go to parties i just play online games before and get less than 5 hours sleep anyway thanks guys ill ditch the nested classes and read again then i will post again if i encounter a problem and hopefully i wont make a big ball of mud. and by the way junilu i have searched the word big ball of mud and i said the thats me haha anyway is



considered big ball of mud already if yes then char[] return type is preferred? because i have done that numerous times in my previous programs
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!