BewareMyPower commented on code in PR #17125:
URL: https://github.com/apache/pulsar/pull/17125#discussion_r953697482


##########
pulsar-client-cpp/lib/KeyValue.cc:
##########
@@ -0,0 +1,89 @@
+/**
+ * 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.
+ */
+#include <pulsar/KeyValue.h>
+#include <pulsar/Schema.h>
+#include "SharedBuffer.h"
+
+using namespace pulsar;
+
+namespace pulsar {
+
+class PULSAR_PUBLIC KeyValueImpl {
+   public:
+    std::string keyContent_;
+    std::string valueContent_;
+    KeyValueEncodingType keyValueEncodingType;
+
+    KeyValueImpl(){};
+    KeyValueImpl(std::string key, std::string value, KeyValueEncodingType 
keyValueEncodingType)
+        : keyContent_(key), valueContent_(value), 
keyValueEncodingType(keyValueEncodingType){};
+};

Review Comment:
   It violates the OOP rule. I see similar code in `Message` class as well. You 
access `keyContent_` and `valueContent_` everywhere in methods from `KeyValue`.
   
   Instead, you should move all actual implementations from `XXX` to `XXXImpl`, 
and just call the method with the same name in `XXX`.  You can take `Client` 
and `ClientImpl` for example. Or you can see a typical PImpl example 
[here](https://en.cppreference.com/w/cpp/language/pimpl).
   
   P.S. Currently the design in `Message` also violates the OOP rule. But for 
new code, we should follow it.



-- 
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]

Reply via email to