由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - return type, map or object
相关主题
Java里面有没有可能写个带generic parameter的class对built-in type也适用?如何造Array of Generic Type
synchronized method does lock the object that passed into the method as a parameter?Urgent!
Provide A Interview QuestionRe: strange exception
Java basic concept(4)how do I get parameters passed by text area (form
TIJ上写错了?A design for parameter passing
copy constructor都什么时候be called啊invoke a function dynamically in Java?
为什么我这个参数的内容存不下?发现LinkedHashMap是个好东东
[合集] 问一下这个cast在java里是怎么work的这个闭包怎么写?
相关话题的讨论汇总
话题: object话题: map话题: class话题: return话题: data
进入Java版参与讨论
1 (共1页)
P*P
发帖数: 36
1
在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?
k***r
发帖数: 4260
2
map needs a lot of memory. a simple class is cheap :)

【在 P*P 的大作中提到】
: 在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
: 知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?

P*P
发帖数: 36
3
多谢.
三个参数是string, long and boolean. 或者我把三个参数concatenate成一个string,
用的时候再分解?

【在 k***r 的大作中提到】
: map needs a lot of memory. a simple class is cheap :)
l****u
发帖数: 2166
4
i vot 4 object

【在 P*P 的大作中提到】
: 在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
: 知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?

g*****g
发帖数: 34805
5
Martin Fowler will 2nd that.

【在 l****u 的大作中提到】
: i vot 4 object
S*********t
发帖数: 78
6
who is martin

【在 g*****g 的大作中提到】
: Martin Fowler will 2nd that.
l****u
发帖数: 2166
7
a java highhand, google his name, u will see...

【在 S*********t 的大作中提到】
: who is martin
l****u
发帖数: 2166
8
define an object would be much easier for maintain,
easy to understand.
also easy to unit test.

string,

【在 P*P 的大作中提到】
: 多谢.
: 三个参数是string, long and boolean. 或者我把三个参数concatenate成一个string,
: 用的时候再分解?

k***r
发帖数: 4260
9
No. Just define an inner class. new it, and return it.

string,

【在 P*P 的大作中提到】
: 多谢.
: 三个参数是string, long and boolean. 或者我把三个参数concatenate成一个string,
: 用的时候再分解?

c********g
发帖数: 449
10
store them into a vector and return it.
相关主题
copy constructor都什么时候be called啊如何造Array of Generic Type
为什么我这个参数的内容存不下?Urgent!
[合集] 问一下这个cast在java里是怎么work的Re: strange exception
进入Java版参与讨论
Z****e
发帖数: 2999
11
never liked the idea of storing heterogeneous data in a vector, or
collections alike

【在 c********g 的大作中提到】
: store them into a vector and return it.
S*********t
发帖数: 78
12
agree.
not a good idea using vector.
also not fancy inner class idea.

【在 Z****e 的大作中提到】
: never liked the idea of storing heterogeneous data in a vector, or
: collections alike

g*****g
发帖数: 34805
13
It depends on how the data object is coupled with the function class.
If the data doesn't make sense out of functional class context,
using inner class is a good pattern.

【在 S*********t 的大作中提到】
: agree.
: not a good idea using vector.
: also not fancy inner class idea.

h**j
发帖数: 2033
14
of coz type

【在 P*P 的大作中提到】
: 在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
: 知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?

F****n
发帖数: 3271
15
Using Map is not uncommon. You can use LinkedHashMap for small number of
objects.

【在 Z****e 的大作中提到】
: never liked the idea of storing heterogeneous data in a vector, or
: collections alike

b******y
发帖数: 9224
16
object is better, it is easier to see what's returned.
k***r
发帖数: 4260
17
maps has poorer memory efficiency. java is already bad in terms of memory usage. Don't
make it worse :)
I*******o
发帖数: 53
18
can u describe what does this method (class?????) do?

【在 P*P 的大作中提到】
: 在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
: 知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?

n******8
发帖数: 172
19
sounds a method that return 3 types of parameters. Why do you not use 3
public unique class variables that you can access from anywhere?
t*******e
发帖数: 684
20

Thread safety will be an issue if he follows your suggestion.
The question is about static data typing (a data object) or dynamic data
typing (a Map, or List, or Collection). Static typing is always preferred
unless the data types may evolve in the future upon business requirements.

【在 n******8 的大作中提到】
: sounds a method that return 3 types of parameters. Why do you not use 3
: public unique class variables that you can access from anywhere?

m******t
发帖数: 2416
21

I don't know which part is scarier - "public" or "class".
I do like "unique" though. At least we are not going to
try and pad 3 parameters into one single string.

【在 n******8 的大作中提到】
: sounds a method that return 3 types of parameters. Why do you not use 3
: public unique class variables that you can access from anywhere?

1 (共1页)
进入Java版参与讨论
相关主题
这个闭包怎么写?TIJ上写错了?
请教下LinkedHashMap是怎么实现的?是bucket linked还是record linked?copy constructor都什么时候be called啊
如何实现一个LRU based cache为什么我这个参数的内容存不下?
HashMap 怎样循环用更快?[合集] 问一下这个cast在java里是怎么work的
Java里面有没有可能写个带generic parameter的class对built-in type也适用?如何造Array of Generic Type
synchronized method does lock the object that passed into the method as a parameter?Urgent!
Provide A Interview QuestionRe: strange exception
Java basic concept(4)how do I get parameters passed by text area (form
相关话题的讨论汇总
话题: object话题: map话题: class话题: return话题: data