| Thinking in terms of Objects. |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Learn Java Programming Language Onlinehttp://learnjava.awardspace.com
This site includes JAVA lessons from the beginning to advanced level.
So this site appropiates for the beginner or non-basic of Java
language.
Guidelines:
1.Introduction 2.Fundamental Programming Concept 3.Decisions
4.Applets&Graphics 5.Introduction to Classes 6.Methods
7.Arrays&Vectors 8.Inheritance&Interfaces 9.Streams and Exceptions
10.Event Handling
- 2
- Running Ant from BATCH FILESHi
Does anyone know is it possible to conditionally continue with a batch
file depending on the result of an ant script.
I want to only continue with the batch file if the ant command was
succesfull - otherwise abort the script for user to see the error.
Thanks in Advance.
- 2
- Apache Project Xalan XML/XSLT Processor Is Good, But Its Extension Not Work on Netscape/IEFirst, let me say I couldn't find a group discuss
XML/XSLT. So I only choose the closest groups to
post this message.
Here is part of my *.xsl file
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:my-javascript-ext="my-ext1"
extension-element-prefixes="my-javascript-ext"
version="1.0">
<xalan:component prefix="my-javascript-ext" elements="whichever"
functions="hello">
<xalan:script lang="javascript">
function hello(w) {
return ("Hello " + w + "!");
}
</xalan:script>
</xalan:component>
....
<xsl:if test="function-available('my-javascript-ext:hello')">
<xsl:value-of select="my-javascript-ext:hello('World')" />
<br></br>
</xsl:if>
....
And this is part of my *.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<?xml-stylesheet type="text/xsl" href="http://myHostName/XML/myfile.xsl" ?>
....
This is working greate for an XML file iff (if only if) I type
java org.apache.xalan.xslt.Process -in myfile.xml -xsl myfile.xsl
or
java org.apache.xalan.xslt.Process -in myfile.xml
That is wonderful, when I set CLASSPATH with
/usr/local/xalan/bin/xalan.jar:/usr/local/xalan/bin/bsf.jar:/usr/local/xalan/bin/js.jar
So I can make my own extension to call my JavaScript functions and/or
Java Class methods inside a XSL file with XALAN Processor.
But unfortunaely this will NOT work on Netscape, Firefox, IE browsers,
even all these browser support XML/XSLT.
Anyone has some idea how should I make Apache Project XALAN's extension
work on a browser?
Thank Q!
- 3
- BDK for J2SDK 1.4 onwardsDoes anybody know about BDK for J2SDK 1.4 onwards?
If yes please let me know the website or downloads
Regards
MAnjiri
- 3
- Differences between getImage and createImage and using ToolkitHello,
What are the differences between getImage and createImage,
and what if I want using toolKit - (getImage and createImage are static,
and I didn't find a way to create an Image object from a function of
toolkit).
I need a sample code, please.
Thanks :)
- 5
- Layout in J2ME, MIDP 2.0Hi,
I wrote a little Midlet and want to have a StringItem and a TextField
next to each other, i.e. they should be in the same row. After
considering MID Profile I coded my Midlet as listed below.
So in my understanding they should be in the same row. The only
condition, which I cannot be sure of is "this Item has a LAYOUT_LEFT,
LAYOUT_CENTER, or LAYOUT_RIGHT directive that differs from the Form's
current alignment." (MIDP, class Form).
But how can I set the directive of a Form? Or did I misunderstand sth?
Why are the two items not in ONE row?
Thanks in advance!
Best regards, Franz
---BEGIN CODE---
public class Layout extends MIDlet implements CommandListener {
private Display display;
private Form form;
private Command EXIT;
public Layout() {
display = Display.getDisplay(this);
}
public void startApp() {
form = new Form("LayoutTest");
EXIT = new Command("Exit", Command.SCREEN, 1);
StringItem s1 = new StringItem("", "Eingabe:");
TextField tf1 = new TextField("", "", 20, TextField.ANY);
tf1.setLayout(TextField.LAYOUT_2);
form.append(s1);
form.append(tf1);
form.addCommand(EXIT);
form.setCommandListener(this);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable
displayable) {
if(command == EXIT) {
destroyApp(false);
notifyDestroyed();
}
}
}
---END CODE---
- 7
- BufferedInputStream vs BufferedReaderHas anyone done any experiments on which is preferable -- putting your
buffering at the BufferedInputStream level or the BufferedReader level
when you have a Reader?
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
- 8
- Squeeze tabs closer together in JTabbedPane??Is there a way to squeeze the tabs closer together in a JTabbedPane? I
noticed there is some free space in the tab itself to the right of the
text in the tab. Don't want to overhaul the look of the GUI. Just want
to move the tabs closer together. An option I thought of, don't know
if it's the best, is to make the tab text image icons and show the
icons instead of text. Don't know if this will free up space.
- 8
- Tomcat 4.1.29 connectors on Linux problem ?
Hallo,
I have very strange problem with apache/mod-jk/tomcat installation
on Linux. I have installed very simple test servlet HelloWorld.class.
Well when I try to do some easy stability test and I call this
servlet from the same IE browser session more times I bring whole
tomcat to the state when it is not responding any more, even other
servlets from other sessions are not served. I have allready tried to
change acceptCount= and connectionTimeout= (even 0,-1) in server.xml
but without any satisfactionary results. Only the complete restart of
tomcat helps afterwards (!).
Thanks
Jan Kopinec
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<Service name="Tomcat-Apache">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="300" debug="0" connectionTimeout="5000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="300" debug="0" connectionTimeout="5000"
useURIValidationHack="false" disableUploadTimeout="true" />
-->
<Engine name="Standalone" debug="0" defaultHost="localhost">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="/var/log/jakarta/" prefix="apache_log." suffix=".txt"
timestamp="true"/>
<Host name="localhost" debug="0" appBase="/home/tomcat"
unpackWARs="true" autoDeploy="true">
<Context path="/test" docBase="test" debug="0"
reloadable="false" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="/var/log/jakarta/" prefix="localhost_test_log."
suffix=".txt"
timestamp="true"/>
<ResourceLink name="linkToGlobalResource"
global="simpleValue"
type="java.lang.Integer"/>
</Context>
</Host>
</Engine>
</Service>
</Server>
- 10
- new to java, need helpSirs/Madam
I encounter the problem on date field.
Sometimes, when there is no date, then it will return the null object. When
I want to check by
aDate.toString() = "" or null, it throws exception.
How can I ensure they return the value or not.
Please help
- 10
- JAXB unmarshalling - missing referenced objectsHi
I've come upon a problem which I just can't figure out.
So, here's a little about the context. An enterprise-application is
running on a Java EE-server. Some POJOs are annotated as Java
Persistence entities aswell as JAXB-annotations to create wanted XML-
representation for them. All annotations are added manually (meaning
no auto-generated classes/factory). A Servlet acts as an interface
against an Ajax-enabled webpage. The script in the web-page retrieves
xml-representation from the servlet and should also send xml back on
the same form for persisting on the server. The script returns the xml
in string-representation.
And here's the problem. Marshalling to xml works just as it should.
The script returns an xml in the exact same form, but the
unmarshalling of it does not produce what is expected. An object for
the main class is created, however any referenced objects are not
created. Primitive fields are generated correctly. No error is thrown.
Simplified, this is how it looks:
---List.java---
@XmlRootElement(name="list")
@XmlType(name="ListType")
@Enitity //JPA
public class List implements Serializable {
private Long id;
private weekNumber;
private Set<Element> elements;
@XmlAttribute(name="weeknumber", required=true)
public void getWeekNumber() {
//...
}
@XmlAttribute(name="id", required=true)
public void getId() {
//...
}
@XmlElementWrapper(name="elements", nillable=false)
@XmlElementRef
@ManyToMany( //JPA
//...
)
public void getElements() {
//...
}
}
---Element.java---
@XmlRootElement(name="element")
@XmlType(name="ElementType")
public class Element implements Serializable {
//...
private Long id;
@XmlAttribute(name="id", required=true)
public void getId() {
//...
}
//...
}
---xml---
<?xml .....>
<ns2:list ..... weeknumber="3" id="21">
<elements>
<ns2:element ... id="42">
...
</ns2:element>
<ns2:element ... id="43">
...
</ns2:element>
...
</elements>
</ns2:list>
In this example, a List-object would be created by the unmarshaller,
however the referenced elements of class Element will not. And I have
no idea why! The package contains a jaxb.index with all class names,
and I also added an ObjectFactory, but the result was the same. Here's
the unmarshalling:
private <T> T recieve(Class<T> classType, String xml) {
JAXBElement<T> obj = null;
try {
JAXBContext jc =
JAXBContext.newInstance(classType.getPackage().getName());
Unmarshaller um = jc.createUnmarshaller();
obj = (JAXBElement<T>)um.unmarshal(new StreamSource(new
StringReader(xml)));
} catch(JAXBException jex) {
jex.printStackTrace();
}
return obj.getValue();
}
I hope someone has something wise to say about this. I've really
twisted my brain to try to figure it out!
Thanks.
- 12
- simple beginners questionHello,
I just got the SUN Java IDE. (Netbeans IDE 3.5.1)
Very very nice, and I worked myself through the tutorial (about making a
colorswitch).
Now, When I compile it gives no errors at all. So far so good.
But when I want to execute, it askes to "set project main class".
The only option it displays is the default project. But the "okay" button
won't highlight.
I cannot select anything else, nor can I roam directories to select
anything.
Can someone please help me out.
I feel kinda silly not even knowing how to start a kind of hello-world
applet. ;-)
best regards,
martin
- 15
- Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novellhttp://www.web20developers.com
http://www.web20developers.com/index.php?option=com_content&task=view...
Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell
AJAX - microlink pattern tutorial : A microlink is a link that opens up
content below it.
Ajax BBC News RSS Reader : demo by Nigel Crawley
AJAX Chat in Python with Dojo : at AquaAjax
Ajax Chess : multiplayer chess
Ajax examples at BackBase : examples demonstrating several aspects of
the Backbase technology.
Ajax examples at Rico : Inner HTML, JavaScript updater etc.
Ajax examples using ColdFusionMX, SQLServer, SOAP : Contact Manager,
NOAA 7 Day Forecast code and demos.
Ajax Feed TV : News feed
Ajax inline dictionary : Highlight any text on this site then right
click. A tooltip containing the definition of the selected word should
show up.
Ajaxload : Ajax loading gif generator.
Ajax Login Demo : Creating a secure login system using XMLHttpRequest
Ajax Newsletter Signup : A newsletter signup form that shows Thank You
on the same page.
ajaxProject : Project Management applicaiton with rich UI
Ajax Rater : A star rating system that uses Ajax.
AJAX-S : An Ajax-based slideshow system.
AJAX Spell Checker : spell check text / form content.
Ajax Toolbox : Tools for the Ajax Developer
Amazon Catalog Tree : Amazon Catalog Tree
Amazon Zuggest : Amazon product suggestion (like google suggest)
Askeet by symfony : Digg-like AJAX interactions; open source
Backbase - Ajax Demos : Ajax demos at BackBase
Basic Ajax Examples : Ping, track changes, drop down, Google suggest
hack etc at Clearnova
Behaviour : Fading lists, Sortable lists, Dropout boxen, Shaky lists
chat.app : ajax chat
Chihuahua Word Puzzle : daily word puzzles
Coloir : Ajax Slideshow
DHTML arcade/action games : a collection that demonstrate the power of
DHTML
DomAPI : Windows Desktop, Outlook-like, RSS Reader
Drag and Drop Shopping Cart Demo : at CyberDummy
Easy AJAX inline text edit 2.0 : edit a piece of text inline
Gmail Style Check Username AJAX Demo : at CyberDummy
Google Web Toolkit Example Projects : Hello World, Dynamic Table,
Desktop App Clone etc
GreyBox : Pop up window using idea of light box.
FiftyFourEleven: Ajax Examples
IntuiCat - ajax Catalogue : Ajax-based Catalogue Demo
jsLINB programming demos : LINB(Lazy INternet and Browser)
JSlog : Ajax logging tool.
JS/UIX Unix Shell : JS/UIX is an UN*X-like OS for standard
web-browsers, written entirely in JavaScript.
Lace : free web chat application
Lightbox : simple, unobtrusive script used to overlay images on the
current page.
Leightbox : Light Box with inline div's instead of AJAX calls.
Live Quote Demo : Simple way of creating an updating stock quote table
in ajax.
Magnetic Poetry : drag and drop poetry
Metatron Chat Engine : PHP/MySQL/JavaScript powered chat engine
Monket Calendar : online calendar
Multi List Drag Drop Demo : at CyberDummy
NetDirector : open and extensible framework for managing configurations
of common open source network services.
nexImage : Image processing demo
Opera Platform : Enabling AJAX applications on mobile phones
Orbeon examples : various examples illustrating the capabilities of
OPS, from the OPS Tutorial examples to XForms examples
OVO Suite : Online Virtual Office : virtual office limited demo
phpFreeChat : php Free Chat
S5: A Simple Standards-Based Slide Show System : S5 is a slide show
format based entirely on XHTML, CSS, and JavaScript.
script.aculo.us Reflector : image reflector script that uses uses
opacity-based fades
Slider Bar Demo : at CyberDummy
SmallestAjax : Smallest Ajax example in the world?
Spell Check demo : by Primal Grasp
Super Maryo World : Japanese game demo
Tacos : Tacos provides a library of useful Tapestry components. This
application provides some examples to get you started.
theList : to-do list / bug-tracker
ThickBox : ThickBox is a Lightbox than can show html pages as well as
images.
Tooltip.js : Tooltip.js is a simple class to make it possible to add
tooltips to your page.
Treehouse Chat : ajax chat
Tudu Lists : open-source to-do lists
WeBoggle : Ajax Boggle
XHTML live Chat : ajax chat
YahooSearchAsYouType : Yahoo search as you type
ZK Demo : demo programs for various components
- 16
- Random Access On a TableHi,
I've got a problem with 2 open Dataset:
That's I had opened a table running an SQL command like this "SELECT *
FROM XXX WHERE YYY=ZZZ" and i want to access to another table with the
keys came from previous ResultSet; BUT I dont want to run an SQL
command ; I'm looking for a command like
setnearest(keylist,keylist,...) then I want read the second table with
a while loop ( ex. (while !eof(second_table))).
Is there a way for me ;)
Thx in advance;
- 16
- comments when decompilingAnother newbie question:
When I decompile Java bytecode, will my comments come back through?
Makes sense that they woudln't, but I just wanted to check.
|
| Author |
Message |
naveen_reddy_2004

|
Posted: 2004-1-24 13:13:00 |
Top |
java-programmer, Thinking in terms of Objects.
Hello all,
I come from a background of Unix C-shell, WIN .bat programming and am
entirely new to the concepts of Object-Oriented programming.
I'm having a hard time geting the concept of 'objects', 'classes',
'why to use them', 'when to use them' etc. I have bought couple of
books on OOPS, but they dont tell me why I should use objects and not
the regular 'functions' or whats the diff. between the two.
I'm sure a lot of people out there would've had a similarly
frustrating experience when making the switch from Structural to
Object-oriented, like the switch from C to C++ or the first time OOPS
was introduced in Visual Basic or Perl. I'm interested to know about
your experiences during the transistion and what you had to do?
Also, for starters, I've made couple of home-grown definitions of what
I think are OOPS fundamentals. Could you please tell me if I'm on the
right track?
1. Objects are glorified functions:
Ojects are just like functions, as in, you have a code-block you think
might have to be repeated over and over again in your program. Might
as well write it once and keeping using it. Objects are these
code-blocks.
2. Objects are user-defined data-types:
Objects are just like int, float, double etc., but you get to define
them!
User defines what sort of data and its attributes an object has holds.
I know they are defined in a gazillion different ways but, is this a
good way to start? Did I miss any other fundamental concepts of
Objects?
Another thumb-rule I'm thinking of implementing till I get a hang of
the Objects: Always try to objectify every darn piece of executable
statement as a first resort.
Your comments, please.
Also, any books/URLs you'd recommend for the absolute beginner in
Objects( with reference to Java, especially).
Thanks for your time,
Reddy
|
| |
|
| |
 |
JavaJunkie

|
Posted: 2004-1-24 13:56:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Check this free book out: Thinking in Java, 3rd ed. Revision 4.0 at
http://www.mindview.net/Books/TIJ/
Section 1 (Introduction to Objects) is probably the best description of this
concept I have found.
"Naveen Reddy" <email***@***.com> wrote in message
news:email***@***.com...
> Hello all,
>
> I come from a background of Unix C-shell, WIN .bat programming and am
> entirely new to the concepts of Object-Oriented programming.
>
> I'm having a hard time geting the concept of 'objects', 'classes',
> 'why to use them', 'when to use them' etc. I have bought couple of
> books on OOPS, but they dont tell me why I should use objects and not
> the regular 'functions' or whats the diff. between the two.
>
> I'm sure a lot of people out there would've had a similarly
> frustrating experience when making the switch from Structural to
> Object-oriented, like the switch from C to C++ or the first time OOPS
> was introduced in Visual Basic or Perl. I'm interested to know about
> your experiences during the transistion and what you had to do?
>
> Also, for starters, I've made couple of home-grown definitions of what
> I think are OOPS fundamentals. Could you please tell me if I'm on the
> right track?
>
> 1. Objects are glorified functions:
> Ojects are just like functions, as in, you have a code-block you think
> might have to be repeated over and over again in your program. Might
> as well write it once and keeping using it. Objects are these
> code-blocks.
>
> 2. Objects are user-defined data-types:
> Objects are just like int, float, double etc., but you get to define
> them!
> User defines what sort of data and its attributes an object has holds.
>
> I know they are defined in a gazillion different ways but, is this a
> good way to start? Did I miss any other fundamental concepts of
> Objects?
>
> Another thumb-rule I'm thinking of implementing till I get a hang of
> the Objects: Always try to objectify every darn piece of executable
> statement as a first resort.
>
> Your comments, please.
> Also, any books/URLs you'd recommend for the absolute beginner in
> Objects( with reference to Java, especially).
>
> Thanks for your time,
> Reddy
>
|
| |
|
| |
 |
Linus Norton

|
Posted: 2004-1-24 15:08:00 |
Top |
java-programmer >> Thinking in terms of Objects.
although i have little 'real' experience with programming i did start out
doing functional stuff and move to OOP and i did also think that OOP didnt
really offer many differences but the more u use it the more useful it
becomes. For me id say that the main advantage is that it is much easier to
modularize the code and maintain it. Id say most of the benifits are in the
design stage.
Linus
|
| |
|
| |
 |
Patrick B. Haggood

|
Posted: 2004-1-24 17:58:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Another good source would be the bluej ide (www.bluej.org). Located there
are some tutorial links, the free IDE itself and some other resources.
Also, a really good learning tool is nakedobjects @ www.nakeobjects.org;
there's some really nifty OO-based tools and other resources to be had
there, too.
Naveen Reddy wrote:
> Hello all,
>
> I come from a background of Unix C-shell, WIN .bat programming and am
> entirely new to the concepts of Object-Oriented programming.
>
> I'm having a hard time geting the concept of 'objects', 'classes',
> 'why to use them', 'when to use them' etc. I have bought couple of
> books on OOPS, but they dont tell me why I should use objects and not
> the regular 'functions' or whats the diff. between the two.
>
|
| |
|
| |
 |
Jon A. Cruz

|
Posted: 2004-1-24 18:26:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Naveen Reddy wrote:
> I'm sure a lot of people out there would've had a similarly
> frustrating experience when making the switch from Structural to
> Object-oriented, like the switch from C to C++ or the first time OOPS
> was introduced in Visual Basic or Perl. I'm interested to know about
> your experiences during the transistion and what you had to do?
Mine's a bit different than that. I had been getting more and more
"OO-ish" in my C programming when C++ became a more viable solution and
I started to transition. Plus I had already learned OO with Lingo in
Director, plus a little others.
> 1. Objects are glorified functions:
> Ojects are just like functions, as in, you have a code-block you think
> might have to be repeated over and over again in your program. Might
> as well write it once and keeping using it. Objects are these
> code-blocks.
Nope. Not really.
Objects are abstract concepts of things. They have data members for
properties of their "thingness", and functions or methods for doing
operations with them as "things".
>
> 2. Objects are user-defined data-types:
> Objects are just like int, float, double etc., but you get to define
> them!
> User defines what sort of data and its attributes an object has holds.
No. Not really.
> I know they are defined in a gazillion different ways but, is this a
> good way to start? Did I miss any other fundamental concepts of
> Objects?
Yes. Stop thinking in terms of functions and data. Take a step higher up
and see if you can represent your primitives and functions as dealing
with concepts of 'things'.
>
> Another thumb-rule I'm thinking of implementing till I get a hang of
> the Objects: Always try to objectify every darn piece of executable
> statement as a first resort.
Well... close. But rather, try saying "what 'thing' does this code
belong to?" If it belongs to none of the 'things' you already have
defined, then it could belong to a new 'thing' you have yet to define
for your program.
For example, if you have a function to split a person's name into parts,
don't. :-)
Instead, think "gee, what 'thing' does this work with?" In this case it
could be a class "ProperName", or perhaps as part of a "Person" class.
Then maybe you'd start to thing of what you'd have more than just a bare
string for a name. Maybe have Person.getFirstName(),
Person.getLastName(), Person.getFullName(), Person.compareName(String)...
> Your comments, please.
> Also, any books/URLs you'd recommend for the absolute beginner in
> Objects( with reference to Java, especially).
'Thinking in Java' is probably a very good one for the sort of approach
you seem to need.
|
| |
|
| |
 |
Oscar Kind

|
Posted: 2004-1-24 18:53:00 |
Top |
java-programmer >> Thinking in terms of Objects.
In comp.lang.java.help Naveen Reddy <email***@***.com> wrote:
[A C coder learning OOP]
>
> Also, for starters, I've made couple of home-grown definitions of what
> I think are OOPS fundamentals. Could you please tell me if I'm on the
> right track?
>
> 1. Objects are glorified functions:
> Ojects are just like functions, as in, you have a code-block you think
> might have to be repeated over and over again in your program. Might
> as well write it once and keeping using it. Objects are these
> code-blocks.
No. As long as you think this, you'll have difficulties. You are partially
correct about the code block though, but there is more to it (member
variables for instance).
Objects are an abstraction layer. They exist so each part of your program
has only a very limited set of data available. This makes each individual
part easier to understand and thus maintain.
Personally, I had difficulty understanding objects until I let go the
notion "a program consists of ocde". Instead, I see in now as:
- A program consists of interacting objects
- Each object has a state (member variables) and interaction possibilities
(methods).
Essential to understand this and also to correctly design the objects in a
program correctly, is this CRC tutorial:
http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/
It's a pity I didn't learn this in college, and had to learn it myself.
Using this method makes for much cleaner OO design then what I did for my
work: often we'd use "getters" and "setters" to manipulate the internal
state of an object (a big NO-NO in OO as you demote objects to glorified
structs).
> 2. Objects are user-defined data-types:
> Objects are just like int, float, double etc., but you get to define
> them!
> User defines what sort of data and its attributes an object has holds.
>
> I know they are defined in a gazillion different ways but, is this a
> good way to start? Did I miss any other fundamental concepts of
> Objects?
This is a first step (a good one), but objects are way more than structs.
First of all, objects are like datatypes in the way you assign them to
variables. There the simiilarities with the primitive datatypes end.
The similarity with structs goes a little further: objects contain member
variables. The difference being that structs are just that, and for
objects the (values of the) member variables only define the internal
state.
Objects are more: they are actors. Each method call on an object makes it
_do_ something. What an object does depends on your design.
> Another thumb-rule I'm thinking of implementing till I get a hang of
> the Objects: Always try to objectify every darn piece of executable
> statement as a first resort.
You are correct in that everything should be an object. C++ doesn't demand
this, but Java does. However, some pieces of code should be in methods in
the same object, while others should be in methods in different objects.
What code belongs where depends on your design.
However, you should never start with code, nor with a flowchart. Instead,
start with what the program should do and what the different parts of the
solution are. Then, use the CRC tutorial I linked to above to decide which
object does what.
> Your comments, please.
> Also, any books/URLs you'd recommend for the absolute beginner in
> Objects( with reference to Java, especially).
Assuming you already found the API documentation and have/are going to
read the CRC tutorial, I have nothing to add. After all, you're already a
programmer and only need to become familiar with the Java API and OO.
Good luck!
Oscar
--
No trees were harmed in creating this message.
However, a large number of electrons were terribly inconvenienced.
|
| |
|
| |
 |
Chris Smith

|
Posted: 2004-1-25 6:00:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Naveen Reddy wrote:
> I come from a background of Unix C-shell, WIN .bat programming and am
> entirely new to the concepts of Object-Oriented programming.
You may be simultaneously facing two transitions: first, from a
procedural approach to an object-oriented approach; and second, from
scripting tasks to software-development tasks. It's worth, from your
perspective, realizing that object-oriented programming in its popular
forms is intended for software-development kinds of tasks rather than
scripting kinds of tasks.
Of course, both of these generalizations (OO versus procedural, and
scripting versus software-dev) are rather fuzzy, but we're trying to
deal with trends here. In general, OO development differs from
procedural in the way that it ties together the pieces, and software
development differs from scripting by tackling problems that are more
complex by several orders of magnitude.
> 1. Objects are glorified functions:
> Ojects are just like functions, as in, you have a code-block you think
> might have to be repeated over and over again in your program. Might
> as well write it once and keeping using it. Objects are these
> code-blocks.
No, this is way off. Object-oriented language do have such code-blocks,
but they are called methods. (In some OO languages such as C++, they
even popularly go by the name "member functions".) You'd actually be a
lot closer if you compared an class (note the small change from
"object" to "class" there) to a *module* that contains a number of
different functions within one aspect of the application. That's the
first step toward object-oriented programming.
In shell scripting, that's a lot like defining a lot of functions in
another script, and then including that other script so you can refer to
those functions.
Of course, modular programming is everywhere, and the OO apprach
strategy hardly has a corner on that market. OO development does two
things differently from a lot of other "modular" applications.
1. It applies modular programming on a radically smaller scale. Instead
of having modules for each of maybe a dozen parts of an application, a
medium-sized OO project might have about a hundred times that many
classes.
2. It assumes that a logical grouping of similar methods will all
operate on the same data. For example, if your payroll code can do two-
dozen things to employee records, chances are good that these two-dozen
thing are related and should be grouped together in a "module", aka
class.
(It's worth noting that there are a number of situations where #2
doesn't strictly hold, mainly because there may be operations on
employees that belong in a completely different part of the application.
That's okay, and there are idioms and patterns for arranging that. What
matters is that #2 *generally* holds.)
> 2. Objects are user-defined data-types:
> Objects are just like int, float, double etc., but you get to define
> them!
> User defines what sort of data and its attributes an object has holds.
It would be correct to say that *classes* define types of data. (Note
the subtle change from "object" to "class" there.) That's in addition
to classes acting as containers for related "functions" (really
methods), as described above. Hence, the origin of the common platitude
that classes define link state (the data) and behavior (the methods).
As for what *objects* are (as opposed to classes), they are the data and
behavior itself. So a class says that a certain type of object has some
data and can do some things, but it's the object itself that has
specific data and does specific things. So if there your payroll
application is printing out checks for a department with 17 employees,
then your application may contain 17 employee objects, but there is
still only one employee class (the data type and definer of possible
operations on an employee).
> I know they are defined in a gazillion different ways but, is this a
> good way to start? Did I miss any other fundamental concepts of
> Objects?
Well, polymorphism is *the* fundamental property of objects and object-
oriented systems. You haven't gotten there yet, though. See if the
above makes sense, and then I'll move on.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Dave Glasser

|
Posted: 2004-1-25 6:05:00 |
Top |
java-programmer >> Thinking in terms of Objects.
email***@***.com (Naveen Reddy) wrote on 23 Jan 2004
21:12:58 -0800 in comp.lang.java.programmer:
>Hello all,
>
>I come from a background of Unix C-shell, WIN .bat programming and am
>entirely new to the concepts of Object-Oriented programming.
>
>I'm having a hard time geting the concept of 'objects', 'classes',
>'why to use them', 'when to use them' etc. I have bought couple of
>books on OOPS, but they dont tell me why I should use objects and not
>the regular 'functions' or whats the diff. between the two.
I think the best way I ever heard it explained was like this:
Computer programs contain state and capabilities. The "state" of a
program is generally it's data, while the "capabilities" are the
things that the program does to or with the data.
With procedural programming languages, like C, the state and
capabilities are pretty much separate and distinct from one another.
In OO programs, an "object" is something that has *both* state (its
member variables, or fields as they're called in Java) and
capabilities (the functions, or methods, that do things with/to the
state of the object.)
It's often said the OO programs allow you to more closely model things
like they are in the real world, because in the real world, objects
tend to have both state and capabilities. Take, for example, a
cassette tape recorder. It can be in various states -- turned off,
turned on, volume up, volume down, etc. -- it has attributes, like
brand, color, model, etc.-- and it can do things, like play a tape,
rewind a tape, erase a tape. This is intuitively understandable to
most people, and that's why, once you grok the basic concepts of OO
programming, it will seem more intuitive and natural than procedural
programming.
(Hat tip to Mike McCarthy.)
--
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.
http://qform.sourceforge.net
|
| |
|
| |
 |
Steve Horsley

|
Posted: 2004-1-25 22:11:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Naveen Reddy wrote:
> Hello all,
>
> I come from a background of Unix C-shell, WIN .bat programming and am
> entirely new to the concepts of Object-Oriented programming.
>
> I'm having a hard time geting the concept of 'objects', 'classes',
> 'why to use them', 'when to use them' etc. I have bought couple of
> books on OOPS, but they dont tell me why I should use objects and not
> the regular 'functions' or whats the diff. between the two.
>
> I'm sure a lot of people out there would've had a similarly
> frustrating experience when making the switch from Structural to
> Object-oriented, like the switch from C to C++ or the first time OOPS
> was introduced in Visual Basic or Perl. I'm interested to know about
> your experiences during the transistion and what you had to do?
>
I know that I found it hard to get my head round when people tried to
explain it to me. I think the best teacher that I had was probably the
java API itself. In writing little utilities, I slowly got to think in
terms of the objects (File, InputStream, StringTokenizer, Socket) that I
was regularly using. They are like tools on a workbench - you pick them
up, use them, put them down.
Then you start to realise that you are creating your own tools or
objects for ths jobs the standard library doesn't provide, from a simple
CsvLineSplitter that chops comma separated lines up, to big complex
object types that are made of lots of smaller object types.
You programming at the design level becomes just a question of
connecting all the right widgets together in the right way.
> Also, for starters, I've made couple of home-grown definitions of what
> I think are OOPS fundamentals. Could you please tell me if I'm on the
> right track?
>
> 1. Objects are glorified functions:
> Ojects are just like functions, as in, you have a code-block you think
> might have to be repeated over and over again in your program. Might
> as well write it once and keeping using it. Objects are these
> code-blocks.
>
> 2. Objects are user-defined data-types:
> Objects are just like int, float, double etc., but you get to define
> them!
> User defines what sort of data and its attributes an object has holds.
>
> I know they are defined in a gazillion different ways but, is this a
> good way to start? Did I miss any other fundamental concepts of
> Objects?
>
> Another thumb-rule I'm thinking of implementing till I get a hang of
> the Objects: Always try to objectify every darn piece of executable
> statement as a first resort.
I'm not sure if that'll work. You (or at least I can't) cannot think at
both object level and statement level. They are definitely two different
levels to my mind. As an example:
You are in the kitchen making a meal, and you need to puree a banana. Do
you think to yourself "Right, I need to have some sharp metal, moving
fast, which means I need dome electricity moving round some magnets in
wires, and some way of making the energy make the sharp metal spin..."?
No! You say "I need a blender". You don't mentally take the blender
apart or design it from scratch. You don't care if it runs on
electricity or pixie dust. It's a different mental level.
Steve
|
| |
|
| |
 |
Virgil Green

|
Posted: 2004-1-27 3:33:00 |
Top |
java-programmer >> Thinking in terms of Objects.
"Oscar Kind" <email***@***.com> wrote in message
news:40124e9b$0$135$email***@***.com...
> In comp.lang.java.help Naveen Reddy <email***@***.com> wrote:
> [A C coder learning OOP]
> Essential to understand this and also to correctly design the objects in a
> program correctly, is this CRC tutorial:
> http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/
>
Though I haven't taken an in-depth look, I was put off almost immediately
when I go the impression I was looking at a real estate course "Think in an
Object Oriented manor." Made me think I was going to have to buy a new house
before I could do OOAD.
I will "give it a chance" though.
- Virgil
|
| |
|
| |
 |
naveen_reddy_2004

|
Posted: 2004-1-27 8:02:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Thanks a lot everybody for your responses and suggestions.
Really appreciate it.
--Reddy
|
| |
|
| |
 |
sgmanohar

|
Posted: 2004-2-1 10:16:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Steve Horsley <email***@***.com> wrote in message news:<bv0icv$kju$email***@***.com>...
> Naveen Reddy wrote:
> > Hello all,
> >
> > I come from a background of Unix C-shell, WIN .bat programming and am
> > entirely new to the concepts of Object-Oriented programming.
> >
> > I'm having a hard time geting the concept of 'objects', 'classes',
> > 'why to use them', 'when to use them' etc. I have bought couple of
> > books on OOPS, but they dont tell me why I should use objects and not
> > the regular 'functions' or whats the diff. between the two.
> >
> > I'm sure a lot of people out there would've had a similarly
> > frustrating experience when making the switch from Structural to
> > Object-oriented, like the switch from C to C++ or the first time OOPS
> > was introduced in Visual Basic or Perl. I'm interested to know about
> > your experiences during the transistion and what you had to do?
> >
>
> I know that I found it hard to get my head round when people tried to
> explain it to me. I think the best teacher that I had was probably the
> java API itself. In writing little utilities, I slowly got to think in
> terms of the objects (File, InputStream, StringTokenizer, Socket) that I
> was regularly using. They are like tools on a workbench - you pick them
> up, use them, put them down.
>
> Then you start to realise that you are creating your own tools or
> objects for ths jobs the standard library doesn't provide, from a simple
> CsvLineSplitter that chops comma separated lines up, to big complex
> object types that are made of lots of smaller object types.
>
> You programming at the design level becomes just a question of
> connecting all the right widgets together in the right way.
>
> > Also, for starters, I've made couple of home-grown definitions of what
> > I think are OOPS fundamentals. Could you please tell me if I'm on the
> > right track?
> >
> > 1. Objects are glorified functions:
> > Ojects are just like functions, as in, you have a code-block you think
> > might have to be repeated over and over again in your program. Might
> > as well write it once and keeping using it. Objects are these
> > code-blocks.
> >
> > 2. Objects are user-defined data-types:
> > Objects are just like int, float, double etc., but you get to define
> > them!
> > User defines what sort of data and its attributes an object has holds.
> >
> > I know they are defined in a gazillion different ways but, is this a
> > good way to start? Did I miss any other fundamental concepts of
> > Objects?
> >
> > Another thumb-rule I'm thinking of implementing till I get a hang of
> > the Objects: Always try to objectify every darn piece of executable
> > statement as a first resort.
>
I've always thought the best phrase to explain it was 'data
encapsulation'.
It starts with the assumption that Data, i.e. raw bytes, are
meaningless. To make them Information, i.e. meaningful, you need to
know how to use them.
For example, you could store the state of a light switch as a bit, 0
or 1. In C, just declare "boolean lightState;"
Who is to know whether a 1 means the light is on or off? You need more
than to store a bit in a variable; you need the bit encapsulated in a
Class! You want a method of turning it on and off, and a way of
finding out if it's on.
That is data encapsulation, and to me, it seems, that's what OOP is
about.
|
| |
|
| |
 |
George W. Cherry

|
Posted: 2004-2-2 12:54:00 |
Top |
java-programmer >> Thinking in terms of Objects.
"S Manohar" <email***@***.com> wrote in message
news:email***@***.com...
> Steve Horsley <email***@***.com> wrote in message
news:<bv0icv$kju$email***@***.com>...
> > Naveen Reddy wrote:
> > > Hello all,
> > >
> > > I come from a background of Unix C-shell, WIN .bat programming and am
> > > entirely new to the concepts of Object-Oriented programming.
> > >
> > > I'm having a hard time geting the concept of 'objects', 'classes',
> > > 'why to use them', 'when to use them' etc. I have bought couple of
> > > books on OOPS, but they dont tell me why I should use objects and not
> > > the regular 'functions' or whats the diff. between the two.
> > >
> > > I'm sure a lot of people out there would've had a similarly
> > > frustrating experience when making the switch from Structural to
> > > Object-oriented, like the switch from C to C++ or the first time OOPS
> > > was introduced in Visual Basic or Perl. I'm interested to know about
> > > your experiences during the transistion and what you had to do?
> > >
> >
> > I know that I found it hard to get my head round when people tried to
> > explain it to me. I think the best teacher that I had was probably the
> > java API itself. In writing little utilities, I slowly got to think in
> > terms of the objects (File, InputStream, StringTokenizer, Socket) that I
> > was regularly using. They are like tools on a workbench - you pick them
> > up, use them, put them down.
> >
> > Then you start to realise that you are creating your own tools or
> > objects for ths jobs the standard library doesn't provide, from a simple
> > CsvLineSplitter that chops comma separated lines up, to big complex
> > object types that are made of lots of smaller object types.
> >
> > You programming at the design level becomes just a question of
> > connecting all the right widgets together in the right way.
> >
> > > Also, for starters, I've made couple of home-grown definitions of what
> > > I think are OOPS fundamentals. Could you please tell me if I'm on the
> > > right track?
> > >
> > > 1. Objects are glorified functions:
> > > Ojects are just like functions, as in, you have a code-block you think
> > > might have to be repeated over and over again in your program. Might
> > > as well write it once and keeping using it. Objects are these
> > > code-blocks.
> > >
> > > 2. Objects are user-defined data-types:
> > > Objects are just like int, float, double etc., but you get to define
> > > them!
> > > User defines what sort of data and its attributes an object has holds.
> > >
> > > I know they are defined in a gazillion different ways but, is this a
> > > good way to start? Did I miss any other fundamental concepts of
> > > Objects?
> > >
> > > Another thumb-rule I'm thinking of implementing till I get a hang of
> > > the Objects: Always try to objectify every darn piece of executable
> > > statement as a first resort.
> >
>
> I've always thought the best phrase to explain it was 'data
> encapsulation'.
> It starts with the assumption that Data, i.e. raw bytes, are
> meaningless. To make them Information, i.e. meaningful, you need to
> know how to use them.
>
> For example, you could store the state of a light switch as a bit, 0
> or 1. In C, just declare "boolean lightState;"
> Who is to know whether a 1 means the light is on or off? You need more
> than to store a bit in a variable; you need the bit encapsulated in a
> Class! You want a method of turning it on and off, and a way of
> finding out if it's on.
>
> That is data encapsulation, and to me, it seems, that's what OOP is
> about.
A good succinct phrase and description. A more verbose
description is that an object is a situation-action machine, that
is, a machine which maps situations (or situation types) onto
appropriate actions.
A situation is a conjunction of facts. For example, here are
some situation-action rules for a bounded stack:
situation1: pop() has been called & the stack contains an item.
action1: return the top item in the stack; move top down by one.
situation2: pop() has been called & the stack is empty.
action2: raise the empty stack exception.
situation3: push(x) has be called & the stack is not full.
action3: move top up by one; store x there.
situation4: push(x) has be called & the stack is full.
action4: raise the empty stack exception.
I call this "Situation-Driven Modeling" (SDM).
George W. Cherry
http://SDM.book.home.comcast.net
|
| |
|
| |
 |
George W. Cherry

|
Posted: 2004-2-2 13:11:00 |
Top |
java-programmer >> Thinking in terms of Objects.
"George W. Cherry" <email***@***.com> wrote in
message news:9KkTb.206675$xy6.1060450@attbi_s02...
>
> "S Manohar" <email***@***.com> wrote in message
> news:email***@***.com...
> > Steve Horsley <email***@***.com> wrote in message
> news:<bv0icv$kju$email***@***.com>...
> > > Naveen Reddy wrote:
> > > > Hello all,
> > > >
> > > > I come from a background of Unix C-shell, WIN .bat programming and
am
> > > > entirely new to the concepts of Object-Oriented programming.
> > > >
> > > > I'm having a hard time geting the concept of 'objects', 'classes',
> > > > 'why to use them', 'when to use them' etc. I have bought couple of
> > > > books on OOPS, but they dont tell me why I should use objects and
not
> > > > the regular 'functions' or whats the diff. between the two.
> > > >
> > > > I'm sure a lot of people out there would've had a similarly
> > > > frustrating experience when making the switch from Structural to
> > > > Object-oriented, like the switch from C to C++ or the first time
OOPS
> > > > was introduced in Visual Basic or Perl. I'm interested to know about
> > > > your experiences during the transistion and what you had to do?
> > > >
> > >
> > > I know that I found it hard to get my head round when people tried to
> > > explain it to me. I think the best teacher that I had was probably the
> > > java API itself. In writing little utilities, I slowly got to think in
> > > terms of the objects (File, InputStream, StringTokenizer, Socket) that
I
> > > was regularly using. They are like tools on a workbench - you pick
them
> > > up, use them, put them down.
> > >
> > > Then you start to realise that you are creating your own tools or
> > > objects for ths jobs the standard library doesn't provide, from a
simple
> > > CsvLineSplitter that chops comma separated lines up, to big complex
> > > object types that are made of lots of smaller object types.
> > >
> > > You programming at the design level becomes just a question of
> > > connecting all the right widgets together in the right way.
> > >
> > > > Also, for starters, I've made couple of home-grown definitions of
what
> > > > I think are OOPS fundamentals. Could you please tell me if I'm on
the
> > > > right track?
> > > >
> > > > 1. Objects are glorified functions:
> > > > Ojects are just like functions, as in, you have a code-block you
think
> > > > might have to be repeated over and over again in your program. Might
> > > > as well write it once and keeping using it. Objects are these
> > > > code-blocks.
> > > >
> > > > 2. Objects are user-defined data-types:
> > > > Objects are just like int, float, double etc., but you get to define
> > > > them!
> > > > User defines what sort of data and its attributes an object has
holds.
> > > >
> > > > I know they are defined in a gazillion different ways but, is this a
> > > > good way to start? Did I miss any other fundamental concepts of
> > > > Objects?
> > > >
> > > > Another thumb-rule I'm thinking of implementing till I get a hang of
> > > > the Objects: Always try to objectify every darn piece of executable
> > > > statement as a first resort.
> > >
> >
> > I've always thought the best phrase to explain it was 'data
> > encapsulation'.
> > It starts with the assumption that Data, i.e. raw bytes, are
> > meaningless. To make them Information, i.e. meaningful, you need to
> > know how to use them.
> >
> > For example, you could store the state of a light switch as a bit, 0
> > or 1. In C, just declare "boolean lightState;"
> > Who is to know whether a 1 means the light is on or off? You need more
> > than to store a bit in a variable; you need the bit encapsulated in a
> > Class! You want a method of turning it on and off, and a way of
> > finding out if it's on.
> >
> > That is data encapsulation, and to me, it seems, that's what OOP is
> > about.
>
> A good succinct phrase and description. A more verbose
> description is that an object is a situation-action machine, that
> is, a machine which maps situations (or situation types) onto
> appropriate actions.
>
> A situation is a conjunction of facts. For example, here are
> some situation-action rules for a bounded stack:
>
> situation1: pop() has been called & the stack contains an item.
> action1: return the top item in the stack; move top down by one.
>
> situation2: pop() has been called & the stack is empty.
> action2: raise the empty stack exception.
>
> situation3: push(x) has be called & the stack is not full.
> action3: move top up by one; store x there.
>
> situation4: push(x) has be called & the stack is full.
> action4: raise the empty stack exception.
duhhh. action4: raise the full stack exception.
> I call this "Situation-Driven Modeling" (SDM).
>
> George W. Cherry
> http://SDM.book.home.comcast.net
>
>
>
>
>
|
| |
|
| |
 |
paul brown

|
Posted: 2004-2-2 13:52:00 |
Top |
java-programmer >> Thinking in terms of Objects.
Here's my 2p while i wait for Websphere MQ to install...
i found it difficult when learning C++ to see where the actual work was
getting done in an OO program.
i would step through code and see loads of indirection and overloading, code
apparently doing very
little, etc...only after perhaps stepping through several classes would i
see the 'meat' of the program,
IO and business logic for example. now i realise a lot of the weird methods
and classes i was looking at
were there to structure the program to make it easier to maintain/extend and
(ironically) easier to understand.
i mean, if you came to the Visitor pattern straight from stepwise refinement
in C, wouldn't you be confused?!
i think a good place to begin is learning about Interface based programming.
the first few chapters of a
COM book, or a Java book (can't name any off hand sorry) would help you
grasp that. i also recommend
you read the 'Gang of Four' Design Patterns book which you can find on
Amazon. (ISBN: 0201633612).
this will show you common class structures you will see when you read Java
code so you'll be able to
grasp the features of a class without having to examine it in minute detail.
this book will also help you
understand the lingo used in a lot of other Java programming books and
articles, etc.
think of objects as black boxes with buttons on. each time you press a
button you change the 'state'
of the object. the way an object responds to a button push depends on what
state it's in - what's happened
to it up to that point in terms of button presses. certain combinations of
button presses cause the object to
exhibit certain behaviour. that list of behaviours and associated button
presses documents the object for its
clients. if you can list all the states an object can be in and how to get
between them, that's brilliant. you
can ideally make concrete assertions about an objects state based on what
button presses have occured
and its documented contract "if you press X, Y and Z in that order, i will
end up in state S1"...if you can
assert the state of all the objects in your system as a program executes,
then you remove the possibilty of some
objects getting into unknown states...when objects get into unknown states
(unknown to you as programmer)
then you have bugs in your system. modelling objects as state machines and
using assertions to check the
states are as you expect is less error prone but requires more effort up
front.
so there are two things to think about. the design time considerations are
structural. what classes comprise
the program, how they are associated.during this phase i personally am
thinking about what is likely to change
in the current solution. what don't i understand yet in this problem? these
areas require most flexibility to change
easily. the runtime considerations are about the states that the objects can
be in and how they interact to implement
a use case.
i think that if a class implementation starts getting complex, break out the
complexities into further abstractions
- use classes to do that, they are your basic tool in Java.
keep classes to under 10 methods if you can...and each one about a page (25
lines) of code...to make each
class readable and comprehendable
study plenty of source code (loads of free stuff on the web-stick to well
known stuff though) be sure to write
Java code on a daily basis...even if its really simple stuff. invent a
little project for yourself and work away at it
during your spare time.
last of all, don't forget all the good stuff you have learnt already.
objects aren't the be-all-and-end-all.
hope this helps,
paul
"Naveen Reddy" <email***@***.com> wrote in message
news:email***@***.com...
> Hello all,
>
> I come from a background of Unix C-shell, WIN .bat programming and am
> entirely new to the concepts of Object-Oriented programming.
>
> I'm having a hard time geting the concept of 'objects', 'classes',
> 'why to use them', 'when to use them' etc. I have bought couple of
> books on OOPS, but they dont tell me why I should use objects and not
> the regular 'functions' or whats the diff. between the two.
>
> I'm sure a lot of people out there would've had a similarly
> frustrating experience when making the switch from Structural to
> Object-oriented, like the switch from C to C++ or the first time OOPS
> was introduced in Visual Basic or Perl. I'm interested to know about
> your experiences during the transistion and what you had to do?
>
> Also, for starters, I've made couple of home-grown definitions of what
> I think are OOPS fundamentals. Could you please tell me if I'm on the
> right track?
>
> 1. Objects are glorified functions:
> Ojects are just like functions, as in, you have a code-block you think
> might have to be repeated over and over again in your program. Might
> as well write it once and keeping using it. Objects are these
> code-blocks.
>
> 2. Objects are user-defined data-types:
> Objects are just like int, float, double etc., but you get to define
> them!
> User defines what sort of data and its attributes an object has holds.
>
> I know they are defined in a gazillion different ways but, is this a
> good way to start? Did I miss any other fundamental concepts of
> Objects?
>
> Another thumb-rule I'm thinking of implementing till I get a hang of
> the Objects: Always try to objectify every darn piece of executable
> statement as a first resort.
>
> Your comments, please.
> Also, any books/URLs you'd recommend for the absolute beginner in
> Objects( with reference to Java, especially).
>
> Thanks for your time,
> Reddy
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- import="ShoppingBasket,Product,java.util.*" Error in JSP pagevivienne wykes wrote:
> Hi There,
> I am trying do a shopping cart tutorial and have the following error when
> compiling my shop products.jsp file.
>
>
>
> shop_0002dproducts$jsp.java [3:1] '.' expected
> import ShoppingBasket;
>
>
> <%@ page language="java" contentType="text/html"
> import="ShoppingBasket,Product,java.util.*"
> errorPage="errorpage.jsp" %>
>
>
> I am not sure if it has to do with mutiple imports of the ShoppingBasket
> and Product classes.....
> Would it be better to put these two classes into a package ? The classes
> compile ok but have a problem with the above import.
> Thanks
>
> Jim Ascroft
Stop asking the same question over and over again. You've gotten an answer
already.
--
Kind regards,
Christophe Vanfleteren
- 2
- Persistent Cookies vs. session cookiesHi all (please excuse the crosspost but I can't find an HTTP group as such)
I am trying to find out the difference between persistent cookies and
session cookies. I have found plenty of documentation saying what the
differences are from the user point of view, but I want to know how the
server and browser distinguish between the two types in terms of HTTP
protocol.
I have read RFC 2965 and the Java servlet programming documentation and I
can't find any information as to how I should specify (or detect) whether a
specific cookie is persistent or session.
Any clues please?
Andy
- 3
- Java and avoiding software piracy?On Jul 23, 10:40 pm, Joe Attacki <email***@***.com> wrote:
> On Jul 23, 9:04 pm, email***@***.com wrote:> No, I make a point, he calls me names, I call it an insult.
>
> Whoa, wait, what!? My head asplode.
>
> The post you marked as "insult deleted" contained simply some links to
> other discussions on Google Groups that invalidate your point, then
> simply said "Wrong again!"
>
> Where in that post did I call you names?
The very fact that you even tried to "invalidate" me, and then
proceeded to attack me by calling me "wrong". In fact you implied a
second such, since you said "again", implying there was at least one
additional occasion of incompetence on my part.
Publicly alleging incompetence on my part is unwelcome and will not be
tolerated. Don't do it again.
Furthermore, a few token on-topic posts years ago followed by
thousands of vicious attack posts since then in at least two major
flame wars does not change your stats much. Instead of 100% attacki
and off-topic you may be merely 99.9% attacki and off-topic, which is
still way more than anyone else posting to this froup. You also lurked
for a very long time, appeared to blast invective at various people
(chiefly me), lurked for another very long time, and again decloaked
with armed phasers and torpedoes. As far as I can tell you are an
Orion pirate lurking alongside a heavily-trafficked space lane waiting
for opportune moments to strike, rather than a constructive
participant of this group. So please go away.
- 4
- izpack 3.8Does anyone know where I might be able to find the free izpack
installer version 3.8?
Thanks!
Its totally free, and if the author ever sees this,,,, THANKS BUD!
This thing kicks ass, but 3.9, has a bug that makes it not work for my
purposes....
- 5
- JPanel - setVisible(true)Hello,
I'm creating a small test application with one main JFrame.
This JFrame has a default JPanel as its content pane and it has a
small menu that allows you to switch to change your content pane to
another JPanel.
The code to switch the contentpane in the JFrame:
private void changeContentPane(JPanel panel) {
setContentPane(panel);
setVisible(true);
}
If i don't include the setVisible(true) statement in this method and I
click the menu to change the content, the content pane is not visible
until I resize the screen.
What is the reason for this and what is the logic behind the
setVisible(true) statement in this method. (I do understand why the
"setVisible" is needed in the constructor of the JFrame: to show the
frame on screen)
Greetings,
Jos Bosmans
- 6
- signum of longRoedy Green wrote:
> On Fri, 03 Feb 2006 04:10:08 +0100, Piotr Kobzda <email***@***.com>
> wrote, quoted or indirectly quoted someone who said :
>
>>Hmm, 9th candidate is here:
>>
>>return (int)( diff >>> 32 ) | ( (int)diff | (int)diff << 1 ) >>> 1;
>
You have missed my advice. This one is my next candidate. :))
Following the code carefully, you should see the difference...
Your benchmark (version 1.1) has *eight* candidates (not nine).
I've added my new candidate (9th in the collection) under the name
"piotr" into your benchmark, the results are in my previous post.
Regards,
piotr
- 7
- Algorithms, Riddles, Puzzles Group - www.algogeeks.comHello All,
I have just put together a community site for all of us -
www.algogeeks.com
Request all of you to check out. I was able to finish doing this in
few hours (thanks to open source software).
If you guys like it, do join-in.
Objective is to put together discussions in more orderly and
algorithms/puzzles/problem solutions organized way.
Any feedback is welcome!
- 8
- list of arraysI have created a List with the intention of putting elements of
one-dimensional arrays within it. The arrays contain integers. The lines
I've used are:-
(for the purposes of this, I have set variableNumber equal to 5)
List<int[]>combinationList = new ArrayList<int[]>();
int[] degrees = new int[variableNumber + 1];
{ some routine which fills each element of 'degrees' with a random integer}
then, I wish to add the newly filled 'degrees' to the end of the list, using
:-
combinationList.add(degrees);
theres no problem just doing this the once, but if I attempt to add another
instance of 'degrees' to the list using the same above statement, then it
seems to overwrite the initial instance of degrees with the new one.
Why is it doing this? I cant seem to find a way around it. If I run
through say 10 iterations of the above then I am simply left with a list of
10 arrays all of which are identical to the last generated instance of
'degrees'.
Thanks
- 9
- NIO slow (no buffering?)Hi!
I probably yet don't understand some fundamental things about NIO. The
following code is painfully slow (8sec. for a 6MiB file):
final FileChannel in = new FileInputStream( f ).getChannel();
final ByteBuffer token = ByteBuffer.allocate( 4 );
while( in.position() < in.size() )
{
in.read( token );
final String s = new String( token.array() );
token.flip();
}
What am I doing wrong?
- 10
- JSP Import CSV into databaseI'm looking to implement a feature into a JSP web app which will allow users
to import a CSV file into a database. My thoughts are that the process would
involve the following steps:
1) Transfer the CSV file from client to web server.
2) Have a simple Java application check folder location intermittently for
new files in upload folder on website
3) If a new file has been uploaded then parse the CSV into a collection of
JavaBeans
4) Use JDBC to import each JavaBean into table
My questions are the following:
- Is this the best way to achieve this (bearing in mind each row will need
to be validated)?
- What is the most appropriate method of tranferring a file to a JSP web
server?
- How should I transfer the JavaBean data to the SQL database - import each
bean one-by-one?
Any advice would be appreciated.
- 11
- JavaMail sending problem and solutionI had chronic problems with sending email via smtp. I could sign in
via a mail client and send to a remote user just fine, but JavaMail
refused to send to any but local users, citing a 550 relaying problem.
All of the references I could find on the web told me to talk to my
mail admin, but I'm he and I also knew that if my mail client could do
it, so could I.
This solution requires that you log into the mail server as a normal
email user - you will have to create an (or use an existing) account.
You turn on smtp authorization by setting the a property you pass in
to get a session: the property is mail.smtp.auth and you set it to
"true". Then you create an Authenticator that returns a
PasswordAuthentication with your username and password in it.
Here's an excerpt of working code:
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(FROM, PASSWORD);
}
};
Session mailSession = Session.getInstance(getMailProperties(),
authenticator);
Message email = new MimeMessage(mailSession);
try {
email.setFrom(new InternetAddress(FROM));
email.setSentDate(new Date());
email.setRecipients(Message.RecipientType.TO,
stringsToInternetAddresses(to));
email.setRecipients(Message.RecipientType.CC,
stringsToInternetAddresses(cc));
email.setRecipients(Message.RecipientType.BCC,
stringsToInternetAddresses(bcc));
email.setSubject(subject);
email.setText(body);
Transport.send(email);
retval = true;
} catch (Exception e) {
}
My getMailProperties includes the following:
mail.smtp.host=some.mail.host.com
mail.smtp.auth=true
I just post this here for posterity so maybe someone else doesn't go
through the hell I did to figure this out :)
- 12
- Check for site is up in programHi,
can any body guide me how to check whether the site i am using in my
Java application is up or not. Depending on that i would like to take
appropriate action.
thanks in advance,
atul
- 13
- The beauty of TCP/IPI wrote:
> >I think Roedy's logic is that streams of large amounts of data are most
> >likely to be done via TCP rather than UDP, and therefore there exists
> >some correlation between TCP and more efficient applications
Roedy Green <email***@***.com> wrote:
> I was not trying to make any such statement.
I'm still not convinced. You say you're not making any such statement,
yet you go on to make such a statement.
> I was trying to point
> out that UDP and TCP/IP stream performance depend on different
> characteristics of the connection.
But they don't. Both UDP and TCP have latency and bandwidth. Latency
depends on the sum of the processing at each node and communication
times between hops, and bandwidth depends on the width of the narrowest
communication channel or the speed of the slowest processing node. Some
applications depend mainly on latency, and some on bandwidth; so the two
will perform differently, regardless of the choice of TCP or UDP.
The TCP/UDP choice is almost completely orthogonal to the question of
bandwidth or latency. The ONLY difference is that under TCP,
transmission errors can cause future data to be buffered at the target
node, and buffers have limited size... so in a path with very high
latency and occasional errors, TCP can fail to meet the bandwidth
potential of UDP over a similar path. Of course, the up-side is
reliable messaging, which is not available with UDP.
So...
> Either you have a continuous
> stream of data or you have intermittent packets.
Yes.
> Even if you were to
> use TCP/IP for exchanging intermittent packets, it will behave from a
> performance point of view like UDP.
There is no such thing as performing "like UDP". It can perform like a
continuous stream, or like intermittent packets with frequent round-
trips... but neither is more or less UDP.
As I said before, since many applications of UDP are for streaming large
amounts of data with no round trips (e.g., video streaming, multicast
broadcasting, ) and many applications of TCP are for intermitten
communication with frequent round-trips (e.g., telnet, ssh, ftp control,
most smtp and pop3 and imap, etc.), most people with experience in
network protocols will think that you've got it quite backwards. You
haven't really got it backward; there's really no significant
relationship at all.
> I thought I was stating something almost too obvious to mention, but
> apparently it is not.
I think your talk about TCP and UDP is confusing people. That's all.
Latency and bandwidth is not at issue.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
- 14
- Java 1.4 on a FreeBSD 7Hi,
Did anyone manage to install Java 2 JDK 1.4.2 in a FreeBSD 7?
I really need a payment service form SecureTrading, and it doesn't work on
version 1.5.
Any ideas?
Cheers,
Gabriel Engel
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 15
- valueForPathChanged eventHello all,
In my program I load xml data from file to the DOM, create a custom
model for the tree and display the data in the gui in the form of a
tree. If I want to edit the elements of the tree I have to modify the
valueForPathChanged event in my tree model.
I can't find any description how to do this in the literature.
Everybody seems to omit that part assuming in their examples that the
tree will not be editable.
I will be very grateful for suggestions how to implement the
valueForPathChanged event in my code (which is essentially a little
modified code from the java tutorial) so it is possible to edit the
displayed tree nodes.
My tree model looks like this:
class DomToTreeModelAdapter implements javax.swing.tree.TreeModel
{
private Document document;
public DomToTreeModelAdapter(Document document)
{
this.document=document;
}
public Object getRoot() {
return new AdapterNode(document);
}
public boolean isLeaf(Object aNode) {
AdapterNode node = (AdapterNode) aNode;
if (node.childCount() > 0) return false;
return true;
}
public int getChildCount(Object parent) {
AdapterNode node = (AdapterNode) parent;
return node.childCount();
}
public Object getChild(Object parent, int index) {
AdapterNode node = (AdapterNode) parent;
return node.child(index);
}
public int getIndexOfChild(Object parent, Object child) {
AdapterNode node = (AdapterNode) parent;
return node.index((AdapterNode) child);
}
public void valueForPathChanged(TreePath path, Object newValue) {
//AdapterNode node = (AdapterNode)path.getLastPathComponent();
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)path.getLastPathComponent();
String value = (String)newValue;
if (object != null) {
node.setUserObject(object);
} else {
node.setUserObject(value);
}*/
if (value!=null)
node.setUserObject(value);
}
private Vector listenerList = new Vector();
public void addTreeModelListener(TreeModelListener listener) {
if ( listener != null && ! listenerList.contains( listener ) )
{
listenerList.addElement( listener );
}
}
public void removeTreeModelListener(TreeModelListener listener) {
if ( listener != null ) {
listenerList.removeElement( listener );
}
}
public void fireTreeNodesChanged( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeNodesChanged( e );
}
}
public void fireTreeNodesInserted( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeNodesInserted( e );
}
}
public void fireTreeNodesRemoved( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeNodesRemoved( e );
}
}
public void fireTreeStructureChanged( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeStructureChanged( e );
}
}
}
Regards,
Rob
|
|
|