Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Design question

Status
Not open for further replies.

electroRF

Member
Hi,

I'm trying to solve the following exercise and looking for an approaching idea.

a computer store needs a mechanism to enable identifying each item in its stock.

i.e. a specific computer will have different ID than other computers and also than other printers / keyboards, etc.

i need to create a class UniqueID that provides the above requirement.

then, I'll create a few classes that represent items, and the classes will use the UniqueID mechanism and get a unique ID.

You have an idea how to design the UniqueID mechanism?

Thank you.
---
I thought of:

1. creating a UniqueID class, that has static long long m_id; which will be initialized to 0.

2. every item's class will have a data member long long m_id;

3. the constructor will perform:
- - - this->m_id = UniqueID::m_id;
- - - UniqueID::m_id++;

But i'm not sure if it's a good approach.

long long supports 2^64 items' IDs, which is a reasonable limit, and will never be exceeded.
 
Last edited:

KeepItSimpleStupid

Well-Known Member
Most Helpful Member
That's why they put serial numbers on the outside of the box. It's an inherent unique ID. They bar code them too. So, you have SKU and s/n.
 

electroRF

Member
hi KISS
Thank you.

Could you please elaborate on your approach?

I'm not sure how you suggested the design to be.
 

KeepItSimpleStupid

Well-Known Member
Most Helpful Member
What I am saying is that some things that you buy in the store already come with a unique ID and that ID would be the SKU code combined with the serial number of the unit.

I'm using existing information which is usually encoded on the box.

Well, probably UPC or SKU and/or s/n see: **broken link removed**
 
Status
Not open for further replies.
Top