C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 07-16-2009, 11:43 PM   #1
Registered User
 
linuxdude's Avatar
 
Join Date: Mar 2003
Location: Louisiana
Posts: 926
Java question

I have a particularly bad time with java forums, and I have a question. I was thinking that this question is more for c/c++ people anyway. I created some functions that I want to use. However, it isn't object oriented and java forces me to put them in a class. So, like the Math class, I made it static. However, static proliferates and is everywhere in my code. I was wondering if there is a better way to do this without shoving all the methods in a class and then making everything static. Java seems to force object orientedness down your throat arg!
linuxdude is offline   Reply With Quote
Old 07-16-2009, 11:51 PM   #2
Webhead
 
Spidey's Avatar
 
Join Date: Jul 2009
Posts: 278
Quote:
Java seems to force object orientedness down your throat arg!
Ah, So does C#. It does get annoying sometimes, I don't know how to avoid it other than using a different language.
Spidey is offline   Reply With Quote
Old 07-17-2009, 01:05 AM   #3
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 5,034
>> I have a particularly bad time with java forums

You too, eh?

>> I created some functions that I want to use. However, it isn't object oriented and java forces me to put them in a class. So, like the Math class, I made it static. However, static proliferates and is everywhere in my code. I was wondering if there is a better way to do this without shoving all the methods in a class and then making everything static. Java seems to force object orientedness down your throat arg!

Unfortunately, no. Java doesn't provide a facility for "importing" a namespace, so you're basically stuck with using the fully qualified name (short of writing a wrapper function, of course).
Sebastiani is offline   Reply With Quote
Old 07-17-2009, 02:43 AM   #4
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,783
Java is made to be an OOP language, so it only offers this paradigm AFAIK, unfortunately.
If you wanted more choice, you could try C++.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 07-17-2009, 03:49 AM   #5
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
I don't think he has a choice in the language here.

Java 5 and up offers import static to reduce the typing necessary.

Code:
import static com.example.Utility.*;
imports every static member of the Utility class for unqualified access.

I'm not sure what you mean by "static proliferates".


Also, programming questions about misc. languages belong in the tech forum. I'm moving this thread.
__________________
All the buzzt!
CornedBee

"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
CornedBee is offline   Reply With Quote
Old 07-19-2009, 05:25 PM   #6
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,295
No one said you _have_ to use OOP. You can have one class, which is hardly OOP if it doesn't interact with other classes. And use a pre-processor to include other files and go procedural :-)
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mats, the java answers Jaqui General Discussions 1 04-22-2008 02:12 AM
Java vs C to make an OS WOP Tech Board 59 05-27-2007 03:56 AM
Windows GDI vs. Java Graphics Perspective Windows Programming 7 05-07-2007 10:05 AM
How to use Java with C++ Arrow Mk 84 C++ Programming 2 02-27-2003 04:12 PM
A question for .. java! McAuriel A Brief History of Cprogramming.com 4 12-01-2002 11:16 AM


All times are GMT -6. The time now is 09:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22