Repository: Qiskit/qiskit

Issue:
why do we both as_dict and to_dict in the base model?
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?

https://github.com/Qiskit/qiskit-terra/blob/459a6f3192fb5e1d29dde23e44edda58ac5c8bc0/qiskit/validation/base.py#L356




Discussion:
The short answer is a combination of backwards compatibility and (probably) inability to agree on the preferred one at the point of time it was introduced. Going back in time, the first version of the `Qobj` ([~ 0.6](https://github.com/Qiskit/qiskit-terra/blob/0.6.0/qiskit/qobj/_qobj.py#L32)) concept included `as_dict`, and if memory serves, shortly after some other constructs that preferred `to_foo` instead where introduced - and when the models were generalised, we went with providing both for compatibility.

It would be nice indeed to settle on one and deprecate the other - I don't really have a strong preference over the name as long as we are consistent (might be worth doing a round of similar purpose methods and use them as a decision point).
I agree lets choose one. I prefer to_dict as well.  @ajavadia what about you. 
Yes `to_dict()` is fine, and it seems it has already superseded `as_dict()` for the most part.
ok cool lets deprecate the as_dict 

Resolving patch:
diff --git a/qiskit/qobj/utils.py b/qiskit/qobj/utils.py
--- a/qiskit/qobj/utils.py
+++ b/qiskit/qobj/utils.py
@@ -38,6 +38,6 @@ def validate_qobj_against_schema(qobj):
         qobj (Qobj): Qobj to be validated.
     """
     validate_json_against_schema(
-        qobj.as_dict(), 'qobj',
+        qobj.to_dict(), 'qobj',
         err_msg='Qobj failed validation. Set Qiskit log level to DEBUG '
                 'for further information.')
diff --git a/qiskit/validation/base.py b/qiskit/validation/base.py
--- a/qiskit/validation/base.py
+++ b/qiskit/validation/base.py
@@ -29,6 +29,7 @@ class PersonSchema(BaseSchema):
     class Person(BaseModel):
         pass
 """
+import warnings
 
 from functools import wraps
 from types import SimpleNamespace, MethodType
@@ -355,6 +356,8 @@ def from_dict(cls, dict_):
 
     def as_dict(self):
         """Serialize the model into a Python dict of simple types."""
+        warnings.warn('The as_dict() method is deprecated, use to_dict().',
+                      DeprecationWarning)
         return self.to_dict()
 
 
diff --git a/qiskit/validation/fields/custom.py b/qiskit/validation/fields/custom.py
--- a/qiskit/validation/fields/custom.py
+++ b/qiskit/validation/fields/custom.py
@@ -103,8 +103,8 @@ def _serialize(self, value, attr, obj):
                 return float(value.evalf())
 
         # Fallback for attempting serialization.
-        if hasattr(value, 'as_dict'):
-            return value.as_dict()
+        if hasattr(value, 'to_dict'):
+            return value.to_dict()
 
         return self.fail('format', input=value)
 


Test patch:
diff --git a/test/python/circuit/test_unitary.py b/test/python/circuit/test_unitary.py
--- a/test/python/circuit/test_unitary.py
+++ b/test/python/circuit/test_unitary.py
@@ -169,7 +169,7 @@ def test_qobj_with_unitary_matrix(self):
             numpy.array(instr.params).astype(numpy.complex64),
             matrix))
         # check conversion to dict
-        qobj_dict = qobj.as_dict()
+        qobj_dict = qobj.to_dict()
         # check json serialization
         self.assertTrue(isinstance(json.dumps(qobj_dict), str))
 
diff --git a/test/python/qobj/test_qobj.py b/test/python/qobj/test_qobj.py
--- a/test/python/qobj/test_qobj.py
+++ b/test/python/qobj/test_qobj.py
@@ -69,7 +69,7 @@ def setUp(self):
         self.bad_qobj = copy.deepcopy(self.valid_qobj)
         self.bad_qobj.experiments = None  # set experiments to None to cause the qobj to be invalid
 
-    def test_as_dict_against_schema(self):
+    def test_to_dict_against_schema(self):
         """Test dictionary representation of Qobj against its schema."""
         try:
             validate_qobj_against_schema(self.valid_qobj)
@@ -208,7 +208,7 @@ def setUp(self):
             ]
         }
 
-    def test_as_dict_against_schema(self):
+    def test_to_dict_against_schema(self):
         """Test dictionary representation of Qobj against its schema."""
         try:
             validate_qobj_against_schema(self.valid_qobj)
@@ -258,7 +258,7 @@ def test_from_dict_per_class(self):
             with self.subTest(msg=str(qobj_class)):
                 self.assertEqual(qobj_item, qobj_class.from_dict(expected_dict))
 
-    def test_as_dict_per_class(self):
+    def test_to_dict_per_class(self):
         """Test converting from Qobj and its subclass representations given a dictionary."""
         test_parameters = {
             PulseQobj: (
@@ -299,7 +299,7 @@ def test_as_dict_per_class(self):
 
         for qobj_class, (qobj_item, expected_dict) in test_parameters.items():
             with self.subTest(msg=str(qobj_class)):
-                self.assertEqual(qobj_item.as_dict(), expected_dict)
+                self.assertEqual(qobj_item.to_dict(), expected_dict)
 
 
 def _nop():