02-03-2017
Personally, when passing values to a constructor, I would expect it to be to pass values that probably won't be changed until the object's end of life. When thinking of setters and getters, it's usually to be expected to change values that change a certain number of times. So in this case I wouldn't bother to create a constructor just to do something that the getter and setter do fine. Would create one just to pass value that I expect won't change until the object reaches the end of his life.
But there is nothing wrong with what you did, it's fine if you want to use it.
This User Gave Thanks to colt For This Post:
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello everybody,
I have a problem about running a java class with a cron :
I have Cron.txt file which has :
0,5,10,15,20,25,30,35,40,45,50,55 * * * * CronJava.txt
I have CronJava.txt wihich has :
cd ias/j2ee/SapAktarim/applications/SapAktarim/SapAktarim/WEB-INF/classes/;java -classpath... (3 Replies)
Discussion started by: UBGandalf
3 Replies
2. Shell Programming and Scripting
Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ...
thanks in advance.. (1 Reply)
Discussion started by: mpsc_sela
1 Replies
3. Shell Programming and Scripting
Hi,
Is it possible to call the constructur of a java class in a shell script?
I know you can call static methods, but can you also call the constructor?
tnx. (1 Reply)
Discussion started by: thebladerunner
1 Replies
4. Fedora
Hi, everyone:
I'm trying to connect to DB using JDBC on fedora. I have successfully installed jdk and it's ok to run common java program.
The environment variables:
JAVA_HOME=/installed/mycoy/jdk1.6.0
PATH=$JAVA_HOME/bin:$PATH... (3 Replies)
Discussion started by: mycoy
3 Replies
5. Programming
hello all,
i want to know if there is any difference in working and syntax declaration of abstract class in Java and C++. (1 Reply)
Discussion started by: haravivar
1 Replies
6. Programming
Is anyone know how to write a class in separate file? While method does it needs to be contained in a printwriter class? Can I have the format of the printwriter class as a reference? Thanks a lot. (1 Reply)
Discussion started by: eel
1 Replies
7. Programming
Hi, I need help to Link array from one class to another class
Firstly CSVParser Class what it did is load csv file and store into array
Secondly WarehouseItem where each record is store
How can I get a list of array that I load to CSVParser Class and store them to WarehouseItem and... (0 Replies)
Discussion started by: guidely
0 Replies
8. Shell Programming and Scripting
Hi,
I would really appreciate some help, I couldn't nail my problem:
I would like to create some setter and getter functions to make my life easier.
my sample file contains:
keyword - some tabs - value - semicolon
number 12.1;
float .3;
double 12;
real 12.2324;
stuff .234;
decimal... (5 Replies)
Discussion started by: Toorop
5 Replies
9. Programming
I am looking at a website to learn Java and this is one of the exercises.
Write a program that will show different time and date information based on what number you send it. The codes are:
0 - number of milliseconds since January 1, 1970
1 - number of seconds since January 1, 1970
2 -... (6 Replies)
Discussion started by: totoro125
6 Replies
LEARN ABOUT DEBIAN
class::inner
Class::Inner(3pm) User Contributed Perl Documentation Class::Inner(3pm)
NAME
Class::Inner - A perlish implementation of Java like inner classes
SYNOPSIS
use Class::Inner;
my $object = Class::Inner->new(
parent => 'ParentClass',
methods => { method => sub { ... } }, },
constructor => 'new',
args => [@constructor_args],
);
DESCRIPTION
Yet another implementation of an anonymous class with per object overrideable methods, but with the added attraction of sort of working
dispatch to the parent class's method.
METHODS
new HASH
Takes a hash like argument list with the following keys.
parent
The name of the parent class. Note that you can only get single inheritance with this or SUPER won't work.
methods
A hash, keys are method names, values are CODEREFs.
constructor
The name of the constructor method. Defaults to 'new'.
args
An anonymous array of arguments to pass to the constructor. Defaults to an empty list.
Returns an object in an 'anonymous' class which inherits from the parent class. This anonymous class has a couple of 'extra' methods:
SUPER
If you were to pass something like
$obj = Class::Inner->new(
parent => 'Parent',
methods => { method => sub { ...; $self->SUPER::method(@_) } },
);
then "$self-"gt"SUPER::method" almost certainly wouldn't do what you expect, so we provide the "SUPER" method which dispatches to
the parent implementation of the current method. There seems to be no good way of getting the full "SUPER::" functionality, but I'm
working on it.
DESTROY
Because Class::Inner works by creating a whole new class name for your object, it could potentially leak memory if you create a lot
of them. So we add a "DESTROY" method that removes the class from the symbol table once it's finished with.
If you need to override a parent's DESTROY method, adding a call to "Class::Inner::clean_symbol_table(ref $self)" to it. Do it at
the end of the method or your other method calls won't work.
clean_symbol_table
The helper subroutine that DESTROY uses to remove the class from the symbol table.
new_classname
Returns a name for the next anonymous class.
AUTHOR
Maintained by Arun Prasaad "<arunbear@cpan.org>"
Copyright (c) 2001 by Piers Cawley <pdcawley@iterative-software.com>.
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.
Thanks to the Iterative Software people: Leon Brocard, Natalie Ford and Dave Cross. Also, this module was written initially for use in the
PerlUnit project, AKA Test::Unit. Kudos to Christian Lemburg and the rest of that team.
SEE ALSO
There are a million and one differen Class constructors available on CPAN, none of them does quite what I want, so I wrote this one to add
to that population where hopefully it will live and thrive.
BUGS
Bound to be some. Actually the "SUPER" method is a workaround for what I consider to be a bug in perl.
perl v5.10.1 2009-11-21 Class::Inner(3pm)