0

I have a class which will contain list of two dependent classes inside it.

example

Class ActivityHolder{
    private ArrayList activityList;
    private ArrayList promiseList;
}

My question is how do i name the ActivityHolder class. [Edit]

I have a class structure as above.And not the wallet and coin scenario.

Archan Mishra
  • 887
  • 7
  • 18
  • 1
    Probably a question better suited to the Programmers Stack Exchange... –  Jun 17 '11 at 07:02
  • imo , you name a class based on what it represents , not what it contains . On the same , I find prefixing or suffixing the datatype to variable names annoying and redundant , like coinList . If its a collection , just have the name as plural . And also , by convention , variable names are supposed to start with lowercase. And yea , use generics . – amal Jun 17 '11 at 07:05
  • @Richard well the ting is i dont have a corresponding class as wallet .. :( – Archan Mishra Jun 17 '11 at 07:41
  • @amal thanks for ur insight, however making a variable plural as in coins wont make it explicitly cler that it is a list .. i mean a small s at the end of a long variable name is easy to loose. – Archan Mishra Jun 17 '11 at 07:43
  • @Archan Do you follow the same with all datatypes ? Like iInteger , dDouble ?.Of course the variable name doesnt make clear it's a list , when i want to know the datatype , that's when I hover the mouse over the variable name in my IDE . So say you named it coinList , and one day your requirement changed and you need a set instead , will you refactor your code . And say , if you still prefer the current naming , maybe you should name it coinsArrayList . – amal Jun 17 '11 at 07:53
  • @amal interesting point amal .. so any suggestions for my actual question , i will think about it .. BTW refactoring is also a 2 click thing in my IDE .. ?.. :) – Archan Mishra Jun 17 '11 at 07:55
  • @Archan , Wallet's fine if the class is supposed to represent a Wallet. You dont have to name it say WalletContainingCoinsandNotes . – amal Jun 17 '11 at 07:57

1 Answers1

2

Like Richard and amal pointed, the class name must be something related to its function. If it represents a bunch of activities, so it is okay to name it Activities.

Class Activities {
    private List activities;  // backlog, planned, other better name (more specific) 
    private List promises;
}
darlinton
  • 2,131
  • 16
  • 21