156 reputation
28
bio website
location United Kingdom
age
visits member for 2 years, 5 months
seen Sep 9 at 22:04

A computer science student with an interest in Android, games and security.


Sep
8
awarded  Notable Question
Sep
3
awarded  Popular Question
Jul
19
awarded  Informed
Jun
26
comment Should we persist with an employee still writing bad code after many years?
Could someone explain why Foo::Foo() : m_bar(*(new Bar)) {} is a leak? I'm not a C++ programmer. I understand why "Foo allocates memory from the heap for 2 other objects, but he didn't write a destructor or copy constructor" is bad but not the first bit.
Mar
5
awarded  Caucus
Mar
5
awarded  Constituent
Oct
25
comment Ways to ensure unique instances of a class?
You've repeated what I said in the 3rd paragraph of the question. I was after alternative ways.
Oct
25
comment Ways to ensure unique instances of a class?
I'm doing a student project and the questions scope was a general Java question, as @AndresF. says, using a framework purely for something so simple is a nonsensical/silly/stupid idea.
Oct
25
awarded  Citizen Patrol
Oct
25
awarded  Critic
Oct
23
awarded  Nice Question
Oct
22
comment Ways to ensure unique instances of a class?
+1 for Effective Java, I do have the book, sitting in my bag now actually :) However I was just curious as to other ways of achieving the uniqueness apart from the static factory/static method and the exception in the constructor. If there aren't any then I'll accept this.
Oct
22
comment Ways to ensure unique instances of a class?
Sorry, massive facepalm, I don't actually need a NameFactory (or my equivalent) since there would one be one sub-class, the static method alone in Name would work fine. I was also just curious if there were other ways of ensuring uniqueness apart from the method(s) I mentioned. edit: Sorry hadn't seen your post!
Oct
22
comment Ways to ensure unique instances of a class?
@RobertHarvey The actual class I'll be using it on is almost as simple as the Name class I use in the example, it just seems a waste to have a NameFactory and a Name class to get uniqueness for something so small, I was wondering if there was a more succinct way.
Oct
22
awarded  Student
Oct
22
comment Ways to ensure unique instances of a class?
@MarcB I'm aware of the singleton pattern but I thought that ensures only one instance of a class is possible? I want multiple instances, different values. Sorry if the question isn't making that clear. edit: Only saw first comment before posting.
Oct
22
asked Ways to ensure unique instances of a class?
Apr
29
awarded  Supporter