Repository: google/mediapipe
File: mediapipe/tasks/ios/vision/hand_landmarker/sources/MPPHandLandmarksConnections.h (C/C++)

Code before:
// Copyright 2023 The MediaPipe Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>
#import "mediapipe/tasks/ios/components/containers/sources/MPPConnection.h"

NS_ASSUME_NONNULL_BEGIN

NSArray<MPPConnection *> *const kHandPalmConnections = @[
  [[MPPConnection alloc] initWithStart:0 end:1], [[MPPConnection alloc] initWithStart:0 end:5],
  [[MPPConnection alloc] initWithStart:9 end:13], [[MPPConnection alloc] initWithStart:13 end:17],
  [[MPPConnection alloc] initWithStart:5 end:9], [[MPPConnection alloc] initWithStart:0 end:17]
];

NSArray<MPPConnection *> *const kHandThumbConnections = @[
  [[MPPConnection alloc] initWithStart:1 end:2], [[MPPConnection alloc] initWithStart:2 end:3],
  [[MPPConnection alloc] initWithStart:3 end:4]
];

NSArray<MPPConnection *> *const kHandIndexFingerConnections = @[
  [[MPPConnection alloc] initWithStart:5 end:6], [[MPPConnection alloc] initWithStart:6 end:7],
  [[MPPConnection alloc] initWithStart:7 end:8]
];

NSArray<MPPConnection *> *const kHandMiddleFingerConnections = @[
  [[MPPConnection alloc] initWithStart:9 end:10], [[MPPConnection alloc] initWithStart:10 end:11],
  [[MPPConnection alloc] initWithStart:11 end:12]
];

NSArray<MPPConnection *> *const kHandRingFingerConnections = @[
  [[MPPConnection alloc] initWithStart:13 end:14], [[MPPConnection alloc] initWithStart:14 end:15],
  [[MPPConnection alloc] initWithStart:15 end:16]
];


Review comment (suggestion):
"Prefixes are commonly required in Objective-C to avoid naming collisions in a global namespace. Classes, protocols, global functions, and global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers."

vs

"A lowercase k can be used as a standalone prefix for constants of static storage duration declared within implementation files:
NOTE: Previous convention was for public constant names to begin with a lowercase k followed by a project-specific [prefix](https://g3doc.corp.google.com/company/teams/objc-readability/style_guide.md?cl=head#prefixes). This practice is no longer recommended."

These are pretty close to being global constants, so we should probably follow this guideline.



Code after:
// Copyright 2023 The MediaPipe Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>
#import "mediapipe/tasks/ios/components/containers/sources/MPPConnection.h"

NS_ASSUME_NONNULL_BEGIN

NSArray<MPPConnection *> *const MPPHandPalmConnections = @[
  [[MPPConnection alloc] initWithStart:0 end:1], [[MPPConnection alloc] initWithStart:0 end:5],
  [[MPPConnection alloc] initWithStart:9 end:13], [[MPPConnection alloc] initWithStart:13 end:17],
  [[MPPConnection alloc] initWithStart:5 end:9], [[MPPConnection alloc] initWithStart:0 end:17]
];

NSArray<MPPConnection *> *const MPPHandThumbConnections = @[
  [[MPPConnection alloc] initWithStart:1 end:2], [[MPPConnection alloc] initWithStart:2 end:3],
  [[MPPConnection alloc] initWithStart:3 end:4]
];

NSArray<MPPConnection *> *const MPPHandIndexFingerConnections = @[
  [[MPPConnection alloc] initWithStart:5 end:6], [[MPPConnection alloc] initWithStart:6 end:7],
  [[MPPConnection alloc] initWithStart:7 end:8]
];

NSArray<MPPConnection *> *const MPPHandMiddleFingerConnections = @[
  [[MPPConnection alloc] initWithStart:9 end:10], [[MPPConnection alloc] initWithStart:10 end:11],
  [[MPPConnection alloc] initWithStart:11 end:12]
];

NSArray<MPPConnection *> *const MPPHandRingFingerConnections = @[
  [[MPPConnection alloc] initWithStart:13 end:14], [[MPPConnection alloc] initWithStart:14 end:15],
  [[MPPConnection alloc] initWithStart:15 end:16]
];