qqu0127 commented on a change in pull request #1935:
URL: https://github.com/apache/helix/pull/1935#discussion_r786903019



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/VirtualTopologyGroupStrategy.java
##########
@@ -0,0 +1,80 @@
+package org.apache.helix.controller;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.google.common.collect.ImmutableMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.helix.util.HelixUtil;
+
+public enum VirtualTopologyGroupStrategy {

Review comment:
       Thanks for the comment, it's really good question! I hesitated a lot in 
choosing enum over interface, here are my considerations:
   1. Enum defines constants that could go with predefined behavior (enum 
methods), and strategy falls in the category. Plus enum is naturally static 
final singleton, and it's compile-time constant, method is also resolved at 
compile time, while interface is not.
   2. Afaik, we don't have dependency injection to decouple interface and impl, 
instead we directly construct impl class. I would try to avoid creating 
interface if there is only one known impl.
   3. The key method is static. With interface we could use a static or default 
method, but it's weird to instantiate a class for static method. 
   4. Writing logic in a util class also works, while enum provides a layer of 
encapsulation and is type safe.
   
   This is open discussion, using interface here won't be too bad after all. 
Let me know how you feel about it. Thanks again.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to