ID -ing system

I read some articles about decoupling and found that ID -ing is the best way to prevent coupling

so it's something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

namespace system_one {
	struct ID {
		int unique_id;
		int inner_index;
	};
	
	namespace {
		struct item {
			// some stuff
		};

		map< ID, item > items; // where the real data stored
		
		ID get_new_id(){
			// some code generating a blank new id and a blank item
		}
		
	}
	
	ID add_item( const Property& property ){
		ID new_id = get_new_id();
		
		// initilizing the the new data
		
		return new_id;
	}
	
	void apply_some_change( Id id ){
		// apply some change to the target id
	}
	
}


and I think about this second code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

namespace system_one {
	
	namespace {
		struct item {
			// some stuff
		};

		map< ID, item > items; // where the real data stored
		
		ID get_new_id(){
			// some code generating a blank new id and a blank item
		}
		
	}

	struct ID {
		int unique_id;
		int inner_index;

		void apply_some_change(){
			// do something changes
			// by accessing the unnamed namespace from here
		}
	};
	
	ID add_item( const Property& property ){
		ID new_id = get_new_id();
		
		// initilizing the the new data
		
		return new_id;
	}
	
	
}


I think both work,
Just want to know which is better ??
Or maybe both are wrong ?

Sorry if my pseudocode is hard to read,
Topic archived. No new replies allowed.