Tommy Mato

Greenhorn
+ Follow
since Dec 14, 2007
Merit badge: grant badges
Biography
30 years in IT. Programmed in everything from machine code, assembler, Fortran, C, C++, Basic, Visual Basic, Prolog, SML, LotusScript, JavaScript, C#, Java. Finally learning how to design and code properly with OO principles and Design Patterns. Still so much to learn... and that's the fun of it :-)
For More
Waiheke Island, New Zealand
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tommy Mato

Jeff, Thanks for your reply. I will look up Singleton. I've heard of this design pattern. I'm guessing it is a way of obtaining an object instance from a static method? I did consider that but not sure if this is the way to go - I really wanted assurance that there isn't a simpler more obvious way to achieve this.

Also - my form is essentially a GUI version of the operating system console. Just like you would use println() to display various error and status messages on the console, my myForm.writeMessage() is effectively my GUI version of println. I don't really want to pass all messages up the chain of objects created just so they can be written out to the form. That's why I want to be able to call this code from everywhere.

Once again, sincere thanks for your reply. If you have any other comments on my clarifications above then I would be grateful for them. Tom
13 years ago

My application has got a form called 'myForm' with a text box called 'myMessages' that is used to display status and error messages. In my form code I have a method called 'myForm.writeMessage("...blah blah...")'. I want to call this from any part of my application. The trouble is my application has many objects and is deeply nested: object A creates object B which creates object C .... which creates object K.

Do I really need to pass the 'myForm' reference to all objects that I create? This is very inconvenient. I tried redesigning 'myForm.writeMessage()' as a static method but then obviously it cant refer to the form controls.

I guess I'm stuck with passing the form reference around all over the place seeing as so many parts of my application need to write messages to the form. It would be great if some clever person knew how I could achieve a static way to do this.

Many thanks in advance for lending me your awesome brain :-)

Tom
13 years ago

My application has got a form called 'myForm' with a text box called 'Messages' that is used to display status and error messages. I want to write to this control from any part of my code. In my form code I have a method called 'myForm.writeMessage'. The trouble is my application is deeply nested: method a calls method b calls method c .... calls method k.

Do I really need to pass the 'myForm' reference to all objects and all the way down the chain of method calls? This is very inconvenient. I tried redesigning 'writeMessage' as a static method but then it cant refer to the form controls.

I guess I'm stuck with passing the form reference around all over the place seeing as so many parts of my application need to write to the form. It would be great if there was some way of achieving a static way to do this. Hoping someone knows a clever way to do it.

Many thanks in advance for lending me your awesome brain :-)

Tom
13 years ago
I know the basics regarding relational dbs, however I know very little about other database technologies such as Object dbs, xml dbs, etc. I'm really looking for a shove in the right direction and then I can research further.

I'm building a solution whereby a user can enter text (and perhaps rich-text) data. The user can categorise the data any way they want. For example, in a list of quotations, the user could decide to add (on-the-fly) a column called 'Author' and then assign an author to each quote. They could later on decide to add a column called 'Year' and then assign a year to each quote, etc. Eventually, the user will want to sort/categorise the text items according to the previously mentioned attributes such as author or year.

It's a flexible, almost spreadsheet-like, approach to data management, where the data is mostly unstructured text.

My question is, which database technology should I be considering? It doesn't sound particularly suited to relational. Should I be building an XML database and then using node traversal to sort and categorise? An object database?

My apologies if this sounds vague. As I said, I just want a shove in the right direction. I'm prepared to put in the spade work in learning and researching further.

Many thanks to those who respond.
Many thanks Stephan and Campbell. I was mainly checking that if I initialized at declaration that nothing bad would happen or that I would be violating an OO principle or something like that. Now I know that it is not particularly wrong, however there are good reasons to initialize in the constructor as you have shown. Once again, thanks for taking the time to reply. Tom
14 years ago
I've got a class that will contain another object as a component. For example, my 'Shop' class will have a 'Manager' object.

Is there any advantage to initializing the Manager in the constructor rather than in the declaration?

e.g.

public class Shop {

Manager mgr = new Manager(); // initialized at declaration

// more shop stuff...

}

versus

public class Shop {

Manager mgr;

public Shop() {
mgr = new Manager(); // initialized in a constructor
}

// more shop stuff...

}

I realise that some initializations are complex (like populating an ArrayList), and some initializations can throw exceptions/errors. That is probably good reason to put these initializations in a constructor. However, for simple declaration/initializations like the one shown above, I can't see the advantage of a constructor over the easier declaration approach.

Thanks in advance to those who answer.

Tom
14 years ago
I am writing a VERY processor-intensive standalone application in Java (web server not required). I plan to wring every bit of performance out of my multiprocessor system.

Naturally, I don't want all that processing power being robbed by a Windows operating system checking every millisecond to see if msn messages have come in, whether it is time to upgrade, whether my license is valid, whether it is time to change my underwear, etc, etc, etc.

I want a 'bare bones' unix system, possibly command-line only, that supports JVM multi-threading to multiple processors. I'd be ever so grateful if the experienced members here could point me in the right direction of which version I should install, and whether it is easy to turn off the GUI environment. Being a unix virgin I could do with a version that is easy to install and is reasonably well supported device-driver wise.

Thanks in advance. I bow to your knowledge and experience. Regards,

Tommy
14 years ago
Many thanks guys. I decided to create a separate file for each enum and put them in the com.ubm package as suggested. Works a treat.
14 years ago
My problem is that I want to share enum constants throughout my program. All of the articles I've read on enums talk about HOW to write them from a syntax point of view, but not WHERE to write them. For example, should I include the enum definition in a class file? In their own file? What if I want the enum constants to be shared by source files in different packages? How to do that? Using these packages and source files as an example:

package / file:
com.ubm.stats / statistics.java
com.ubm.price / priceManagement.java

I want to declare some constants to be used by the 2 files above. Where should the enums be declared, and how to refer to them?

Thanks in advance for your help.

Tom
14 years ago
Thanks for your prompt responses. I had an idea I was on the right lines but was not sure. I'm half-way to getting it working now. Thanks again!
15 years ago
I've got a program that needs to keep scores for each player in a game. I want to record these in a collection, but I'm not sure which collection would be best.

The number of players can vary and new players can join the game at any time. I want to keep a cumulative total for each player e.g.

If the scores occur in this order:
Tom 3
Susan 4
Joe 5
Susan 6
Tom 1


At the end of the game, I would like a list of the players and their total scores: e.g.
Tom = 4
Susan = 10
Joe = 5

I know I could build a HashMap and manage the accumulations myself, but I can't help worry that I might be missing a trick. If you know something better than HashMap for this problem then I'd be very grateful for your help.

Tom
15 years ago
I am writing a processor-bound program that makes good use of multi-threading and runs on multi-core processors. It is essential that I wring every ounce of power out of the machine.

The program will read data from a RAM disk, will save statistics to the RAM disk. No graphics are involved, no internet access (for now), disk access required to load the programs and data into RAM disk, but not required during program running (it runs for a week at a time).

This cunning plan is somewhat spoiled by the fact that the operating system is overoccupied with virus scanning, checking for updates, indexing disks, etc, etc, in multiple unnecessary services.

I'd be interested to hear ideas on what makes a good 'bare-bones' OS. Would I be better with Linux? If so, which one? Is there an easy way to shut down all background tasks and services so that my program can get on and do its job.


Thanks in advance for your help.
15 years ago
OK, lets get the apology out of the way first. To my shame, I've spent most of my life in the MS/Dos and Windows environments. I know next to nothing about Linux.

I want to get a Linux desktop for performance reasons. I'm writing a very processor-bound piece of software. I will be multi-threading so that I can make wring every ounce of processing power from a quad-core chip (possibly 2 x quad cores). Having gone to great lengths to keep my database completely in RAM and the code multi-threaded, I don't want to spoil it by having Windows running wasteful and idiotic services all over the place. I've been told that it is possible in Linux to create a 'dedicated' environment that gives all of the processor over to the program. Please comment if my understanding is valid or flawed.

Also, without wanting to start a religious OS war, could someone advise whether SUSE or Ubuntu would be better for a Linux noob like me? Is there any difference when it comes to using Java tools?

I bow down in respect to your experience and wisdom. Thanks in advance.

Tom
15 years ago
Ernest,I re-read your code and understand now. I've already got my code working with mark and reset, but I will use your approach next time. Thanks for the tip!
16 years ago
Thank you Joe Ess. mark() and reset() worked great.

Ernest Friedman-Hill. Thanks for your help, but the pushback method is not refenced anywhere in your code, so I didn't know what the code was supposed to do.
16 years ago