Results 1 to 3 of 3

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

  1. #1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •