Minor code cleanups

Change-Id: I2b67216754ba30563a65a2697e6801e363986da1
diff --git a/examples/consumer.cpp b/examples/consumer.cpp
index b63bc83..f787c97 100644
--- a/examples/consumer.cpp
+++ b/examples/consumer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  The University of Memphis
+ * Copyright (c) 2014-2022,  The University of Memphis
  *
  * This file is part of PSync.
  * See AUTHORS.md for complete list of PSync authors and contributors.
@@ -19,7 +19,7 @@
 
 #include <PSync/consumer.hpp>
 
-#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/face.hpp>
 #include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/random.hpp>
 
@@ -44,7 +44,6 @@
                  std::bind(&PSyncConsumer::afterReceiveHelloData, this, _1),
                  std::bind(&PSyncConsumer::processSyncUpdate, this, _1),
                  m_nSub, 0.001)
-    , m_rng(ndn::random::getRandomNumberEngine())
   {
     // This starts the consumer side by sending a hello interest to the producer
     // When the producer responds with hello data, afterReceiveHelloData is called
@@ -96,18 +95,18 @@
 
 private:
   ndn::Face m_face;
-  int m_nSub;
 
+  int m_nSub;
   psync::Consumer m_consumer;
-  ndn::random::RandomNumberEngine& m_rng;
+
+  ndn::random::RandomNumberEngine& m_rng{ndn::random::getRandomNumberEngine()};
 };
 
 int
 main(int argc, char* argv[])
 {
   if (argc != 3) {
-    std::cout << "usage: " << argv[0] << " "
-              << "<sync-prefix> <number-of-subscriptions>" << std::endl;
+    std::cerr << "Usage: " << argv[0] << " <sync-prefix> <number-of-subscriptions>\n";
     return 1;
   }
 
diff --git a/examples/full-sync.cpp b/examples/full-sync.cpp
index 3ed9814..29d5311 100644
--- a/examples/full-sync.cpp
+++ b/examples/full-sync.cpp
@@ -43,18 +43,16 @@
    */
   Producer(const ndn::Name& syncPrefix, const std::string& userPrefix,
            int numDataStreams, int maxNumPublish)
-    : m_fullProducer(m_face, m_keyChain, 80, syncPrefix, userPrefix,
-                     std::bind(&Producer::processSyncUpdate, this, _1),
-                     1600_ms, 1600_ms)
+    : m_producer(m_face, m_keyChain, 80, syncPrefix, userPrefix,
+                 std::bind(&Producer::processSyncUpdate, this, _1),
+                 1600_ms, 1600_ms)
     , m_maxNumPublish(maxNumPublish)
-    , m_rng(ndn::random::getRandomNumberEngine())
-    , m_rangeUniformRandom(0, 60000)
   {
     // Add user prefixes and schedule updates for them in specified interval
     for (int i = 0; i < numDataStreams; i++) {
       ndn::Name prefix(userPrefix + "-" + std::to_string(i));
-      m_fullProducer.addUserNode(prefix);
-      m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+      m_producer.addUserNode(prefix);
+      m_scheduler.schedule(ndn::time::milliseconds(m_uniformRand(m_rng)),
                            [this, prefix] { doUpdate(prefix); });
     }
   }
@@ -69,13 +67,13 @@
   void
   doUpdate(const ndn::Name& prefix)
   {
-    m_fullProducer.publishName(prefix);
+    m_producer.publishName(prefix);
 
-    uint64_t seqNo = m_fullProducer.getSeqNo(prefix).value();
+    uint64_t seqNo = m_producer.getSeqNo(prefix).value();
     NDN_LOG_INFO("Publish: " << prefix << "/" << seqNo);
 
     if (seqNo < m_maxNumPublish) {
-      m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+      m_scheduler.schedule(ndn::time::milliseconds(m_uniformRand(m_rng)),
                            [this, prefix] { doUpdate(prefix); });
     }
   }
@@ -95,20 +93,19 @@
   ndn::KeyChain m_keyChain;
   ndn::Scheduler m_scheduler{m_face.getIoService()};
 
-  psync::FullProducer m_fullProducer;
+  psync::FullProducer m_producer;
   uint64_t m_maxNumPublish;
 
-  ndn::random::RandomNumberEngine& m_rng;
-  std::uniform_int_distribution<> m_rangeUniformRandom;
+  ndn::random::RandomNumberEngine& m_rng{ndn::random::getRandomNumberEngine()};
+  std::uniform_int_distribution<> m_uniformRand{0, 60000};
 };
 
 int
 main(int argc, char* argv[])
 {
   if (argc != 5) {
-    std::cout << "usage: " << argv[0] << " <syncPrefix> <user-prefix> "
-              << "<number-of-user-prefixes> <max-number-of-updates-per-user-prefix>"
-              << std::endl;
+    std::cerr << "Usage: " << argv[0] << " <sync-prefix> <user-prefix> "
+              << "<number-of-user-prefixes> <max-number-of-updates-per-user-prefix>\n";
     return 1;
   }
 
diff --git a/examples/producer.cpp b/examples/producer.cpp
index 4e4c77a..05ca842 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -41,8 +41,6 @@
                        int numDataStreams, int maxNumPublish)
     : m_producer(m_face, m_keyChain, 40, syncPrefix, userPrefix + "-0")
     , m_maxNumPublish(maxNumPublish)
-    , m_rng(ndn::random::getRandomNumberEngine())
-    , m_rangeUniformRandom(0, 60000)
   {
     // Add user prefixes and schedule updates for them
     for (int i = 0; i < numDataStreams; i++) {
@@ -52,8 +50,8 @@
       // Note that this does not add the already added userPrefix-0 in the constructor
       m_producer.addUserNode(updateName);
 
-      // Each user prefix is updated at random interval between 0 and 60 second
-      m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+      // Each user prefix is updated at a random interval between 0 and 60 seconds
+      m_scheduler.schedule(ndn::time::milliseconds(m_uniformRand(m_rng)),
                            [this, updateName] { doUpdate(updateName); });
     }
   }
@@ -75,8 +73,8 @@
     NDN_LOG_INFO("Publish: " << updateName << "/" << seqNo);
 
     if (seqNo < m_maxNumPublish) {
-      // Schedule the next update for this user prefix b/w 0 and 60 seconds
-      m_scheduler.schedule(ndn::time::milliseconds(m_rangeUniformRandom(m_rng)),
+      // Schedule the next update for this user prefix between 0 and 60 seconds
+      m_scheduler.schedule(ndn::time::milliseconds(m_uniformRand(m_rng)),
                            [this, updateName] { doUpdate(updateName); });
     }
   }
@@ -89,17 +87,16 @@
   psync::PartialProducer m_producer;
   uint64_t m_maxNumPublish;
 
-  ndn::random::RandomNumberEngine& m_rng;
-  std::uniform_int_distribution<int> m_rangeUniformRandom;
+  ndn::random::RandomNumberEngine& m_rng{ndn::random::getRandomNumberEngine()};
+  std::uniform_int_distribution<> m_uniformRand{0, 60000};
 };
 
 int
 main(int argc, char* argv[])
 {
   if (argc != 5) {
-    std::cout << "usage: " << argv[0] << " <sync-prefix> <user-prefix> "
-              << "<number-of-user-prefixes> <max-number-of-updates-per-user-prefix>"
-              << std::endl;
+    std::cerr << "Usage: " << argv[0] << " <sync-prefix> <user-prefix> "
+              << "<number-of-user-prefixes> <max-number-of-updates-per-user-prefix>\n";
     return 1;
   }