Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.
public final class Descriptors {    
public static final EnumValueDescriptor TIME_SETTING = new EnumValueDescriptor(
            R.string.pref_label_time_setting, 
            Measures.TIME_SETTING_12, R.string.pref_time_setting_12,
            Measures.TIME_SETTING_24, R.string.pref_time_setting_24);

public static final EnumValueDescriptor MEASURE_BG = new EnumValueDescriptor(
        R.string.pref_label_bg, 
        Measures.BG_MMOL_L, R.string.measure_mmol_l,
        Measures.BG_MG_DL, R.string.measure_mg_dl);

public static final EnumValueDescriptor MEASURE_СH = new EnumValueDescriptor(
        R.string.pref_label_ch, 
        Measures.CH_G, R.string.measure_g,
        Measures.CH_EXCH, R.string.measure_exch);

    // Is there a better way to specify table data?
public static final NumericValueDescriptor TBG_MMOL_L = new NumericValueDescriptor(
        R.string.pref_label_target_blood_glucose,
        ValueFormat.ONE_SIGNIFICANT_DIGIT,
        0.0f,
        40.0f,
        0.1f,
        R.string.measure_mmol_l);

public static final NumericValueDescriptor TBG_MG_DL = new NumericValueDescriptor(
        R.string.pref_label_target_blood_glucose,
        ValueFormat.INT,
        0f,
        300f,
        1f,
        R.string.measure_mg_dl);

public static final NumericValueDescriptor CF_MMOL_L_U = new NumericValueDescriptor(
        R.string.pref_label_correction_factor,
        ValueFormat.ONE_SIGNIFICANT_DIGIT,
        0.1f,
        99.0f,
        0.1f,
        R.string.measure_mmol_l_u);

public static final NumericValueDescriptor CF_MG_DL_U = new NumericValueDescriptor(
        R.string.pref_label_correction_factor,
        ValueFormat.INT,
        1f,
        99f,
        1f,
        R.string.measure_mg_dl_u);

public static final NumericValueDescriptor MF_G_U = new NumericValueDescriptor(
        R.string.pref_label_meal_factor,
        ValueFormat.ONE_SIGNIFICANT_DIGIT,
        0.1f,
        99.0f,
        0.1f,
        R.string.measure_g_u);

public static final NumericValueDescriptor MF_U_EXCH = new NumericValueDescriptor(
        R.string.pref_label_meal_factor,
        ValueFormat.INT,            
        1f,
        99f,
        1f,
        R.string.measure_u_exch);

public static final int TYPE_TBG_MMOL_L = 0;
public static final int TYPE_TBG_MG_DL = 1;
public static final int TYPE_CF_MMOL_L_U = 2;
public static final int TYPE_CF_MG_DL_U = 3;
public static final int TYPE_MF_G_U = 4;
public static final int TYPE_MF_U_EXCH = 5;

    // Actually this is mapping of TYPE_TBG_MMOL_L  to an object, how better link constants above with objects?
public static final NumericValueDescriptor[] NUMERIC_DESCRIPTORS = {
    TBG_MMOL_L,
    TBG_MG_DL,
    CF_MMOL_L_U,
    CF_MG_DL_U,
    MF_G_U,
    MF_U_EXCH
};
 }
share|improve this question
2  
if would make our lives easier if you tell us what is your actual question – bluefoot Apr 13 '11 at 18:34

2 Answers

up vote 0 down vote accepted

This class doesn't have any responsibilities, it just holds a group of static variables. It is unclear what the purpose of these variables are. I am sure there is a better way to achieve your goal as I doubt you actually need to be storing these details here.

share|improve this answer
Exactly, it has no responsibilites... I need to specify such static (table) data, what is better approach to do it in Java? (Android application) – Solvek Apr 17 '11 at 13:06
@Solvek, if this (whatever it is) really needs to be stored in variable, then put it in the class that uses it instead. – jzd Apr 17 '11 at 19:44

First, ask yourself do you really need a table data or can you solve it by applying some OOP principles like polymorphism. Cause, I have read the code and couldn't came to another conclusion, forgives.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.