Java: Extending a class instead of performing same logic in too many classes. Pros and Cons?
<p>There is a logic and properties used to create certain object. That logic is going to repeated in several classes. Like some template logic. <em>e.g.</em> suppose I am creating a template to create enums like objects, which basically requires setting an int in constructor and getting value through method.</p>

<p>There are two ways to do this</p>

<ol>
<li><p>Create a template superclass which has both of these logics, and extending it whenever we need to create an enum like object.</p></li>
<li><p>Create and re write both the logics every where.</p></li>
</ol>

<p>Keeping memory and performance of code in mind which option is preferable. What are the pros and cons for it?</p>
