Announcement Announcement Module
Collapse
No announcement yet.
Inheritance/class Abstraction/interfaces - xml vs old and known Pojo's OOP. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inheritance/class Abstraction/interfaces - xml vs old and known Pojo's OOP.

    Hi All,

    I am doing my current project on Spring and I have debate.

    Right now I am in the stage of writing the interfaces and the abstraction level.

    I am used to write those classes in the old fasion as we all know( declase java class as abstract/interface):

    Code:
    public abstract class Superclass implements SuperInterface
    { ...}
    I saw in Spring that you can also declare an abstraction via xml.


    Code:
    <bean id="Superclass " abstract="true">
    		... />
    	</bean>
    and then initiate it this way:

    Code:
    <bean id="MyClass " parent="Superclass " 
    	    class="com.spring">
    		..
    	</bean>
    Same goes for overriding methods.

    I find it little confusing.

    what would be the cons and pros of doing it the xml way or the old an fasion way or mybe I should mix them? but when it will be good/effective to do so?


    Thanks,
    ray.

  • #2
    An abstract bean declaration has NOTHING to do with an abstract base class. The abstract bean declaration can even be without a class attribute (I suggest you read the reference guide chapter 3), an abstract bean definition is just a placeholder for common properties which can be attached to other beans (like a sessionfactory on daos but they don't have to share the same parent class).

    Also if you should or shouldn't use interfaces ask 10 developers and get 12 answers. I like interfaces for services, for repositories/daos I generally leave them (sometimes I just use the sessionofactory/entitymanager in my service layer why create an additional layer which only does a pass through to save/delete, for complex queries I tend to use the repositories).


    In short abstract bean declaration and abstract classes have no relation and one should not seek a relation between them.

    Comment


    • #3
      Gotcha, thanks. hope you could reply to my other post as well
      thanks again.

      Comment

      Working...
      X