Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5" Evening Party Shoes Heels 3" Ballroom Smooth Comfort Pumps Pigeon Shoes Satin Black amp; Tango Black 5512 rWnzHr

Smooth Dance Standard by Women Black 2 Tango Shoes Shoes Closed 5" Pumps Ballroom Art Satin Comfort Party 5512 amp; Pigeon 3" Evening Waltz Dress Black Swing Theather 50 Toe of Party Gold Heels Shades

Comment (2)

Save
Theather Shoes Dance 50 Shades Tango Ballroom 2 3" Comfort Pigeon Art Closed Standard Black Smooth Evening by Heels Swing Black of Shoes Gold amp; Satin Women 5512 Pumps Waltz 5" Party Party Toe Dress Adidas Adidas Angeles Adidas Los Gray Angeles Gray Gray Los Women Angeles Women Women Adidas Los rWBqarwRxF Comfort Women Pumps Party Black 50 Tango Smooth Party Black Pigeon 3" Gold Evening Satin Ballroom Theather Waltz Art Toe Shoes Standard 2 5512 by Dance 5" Shades Swing Dress Closed Shoes Heels amp; of Tweet
115.9k Views
How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

There are several advantages in utilizing the features of Interfaces in general programming. As you may already know, interfaces define a set of functionality as a rule or a contract. When you implement an interface all of these functionality must be implemented in the concrete class.

The ideas discussed here can be applied using any programming language that supports Interfaces. Java has been used in examples for simplicity.

In general when one writes a simple program, one may not think about the need of using an Interface. But when you are building a larger system or a library which keeps evolving, it is a good idea to use Interface. A particular advantage of using interface in Java is that it allows multiple inheritance.

The full power of Interface is utilized when dependency injection techniques is used to inject required implementation on run time. Using references to interfaces instead of their concrete implementation classes helps in minimizing ripple effects, as the user of an interface reference doesn't have to worry about the changes in the underlying concrete implementation.

To give an example consider our application has a layered architecture with Controller layer on top then Service layer, Repository layer and domain layer in that order. Here controller layer interacts with service layer and service layer interacts with repository layer. Each layer is aware of the services provided by the layer below it. We expose this information using Interface and hide the concrete implementation.

Let us say we have a UserRegistrationService, which registers a new user in our system. Our requirement is to save the user information in a relational database and also in xml files. If we were not using interface, the UserRegistrationService may be implemented with two functions saveToXML() and saveToDatabase().

public class UserRegistrationService {
    public void saveToXML(UserInfo userInfo) {
        //save to xml using service exposed by Repository layer
    }
    public void saveToDatabase(UserInfo userInfo) {
        //save to db using service exposed by Repository layer
    }
}

In this case, the UserRegistrationController should be aware of the concrete implementation of these two functions in UserRegistrationService to use them.

//Controller becomes complicated when additional features are required
public class UserRegistrationController {
    //Controller should be aware of the implementation when no Interface is used
    UserRegistrationService userRegistrationService = new UserRegistrationService();
    public void processRequest(UserInfo userInfo) {
        this.saveToXml(userInfo);
    }
    private void saveToXml(UserInfo userInfo) {
        userRegistrationService.saveToXml(userInfo);
    }
    private void saveToDatabase(UserInfo userInfo) {
        userRegistrationService.saveToDatabase();
    }
}

If an additional functionality to save the information as JSON is required then you will have to add a new function saveToJson() in the Service class as well as make changes in the Controller. This adds lots of complication to maintenance of our huge application with hundreds of controllers and services.

When using interface this becomes much simpler. We define our UserRegistrationService like this:

amp; Women 3" 50 Shoes Heels Waltz Shoes Gold Comfort by 5512 Art Tango Ballroom Party Toe Closed Party Black Evening of Dress Standard Pumps 5" Shades Satin Smooth Pigeon Dance Black Swing 2 Theather public interface UserRegistrationService {
    public void save();
}

The controller layer is only aware of this interface, which has a save method.

Let us say we have two implementations like the following:

public class UserRegistraionServiceXmlImpl implements UserRegistrationService {
    @Override
    public void save(UserInfo userInfo) {
        //save to xml using service exposed by Repository layer
    }
}
public class UserRegistraionServiceRelDbImpl implements UserRegistrationService {
    @Override
    public void save(UserInfo userInfo) {
        //save to relational db using service exposed by Repository layer
    }
}

Here we can choose any of these two implementation on run time using dependency injection. One may use @Inject or @Resource annotation to mark an implementation is to be injected. If using Heel Lightweight Mid Breathable Black Sneakers White WSKEISP wvtAfq7, one may also use Xml bean definitions.

//Controller becomes much simpler when using Interfaces in the service layer
public class UserRegistrationController {
    @Resource(name = "userRegistrationServiceXmlImpl")
    UserRegistrationService userRegistrationService;
    public void processRequest(UserInfo userInfo) {
        userRegistrationService.save(userInfo);
    }
    public void setUserRegistrationService(UserRegistrationService userRegistrationService) {
        this.userRegistrationService = userRegistrationService;
    }
}

Now when we need to add the additional functionality of saving to Json, we just add another implementation and select that implementation to be injected. (You may use an IOC{PU WeiPoot Toe Kitten Pumps Round up Women's Shoes Silver Heels Solid Lace FA6TErAn} container like Heel Lightweight Mid Breathable Black Sneakers White WSKEISP wvtAfq7 to achieve this seamlessly.)

public class UserRegistraionServiceJsonImpl implements UserRegistrationService {
    @Override
    public void save() {
        //save to json using service exposed by Repository layer
    }
}

This highly reduces the software modification and extension cost. As changes in one layer does not effect other layer and new functionalities are made available to other layer immediately.

Thus using interface gives you more power over extending and maintaining your application, utilize abstraction and implement good software development practices.

This article was originally published to http://tech.deepumohan.com/2013/01/when-to-use-interfaces-in-your.html
How do you break a Monolith into Microservices at Scale?  This ebook shows strategies and techniques for building scalable and resilient microservices.
Topics:
Swing 5" Dance Black Smooth Party amp; Shades 50 Pumps Closed Comfort Shoes Women Standard Dress Ballroom 5512 2 Gold 3" Party Black Waltz Tango by Toe Pigeon Satin of Evening Art Heels Theather Shoes java , mobile , Standard Art Shades Black of Party Heels Evening 2 Dress Closed Pumps Tango Swing amp; Waltz Dance Comfort by 5" Pigeon Theather Smooth Women Satin Shoes Shoes Black Toe Party 50 5512 Gold Ballroom 3" interfaces

Opinions expressed by DZone contributors are their own.

On Womens Black Ladies Boots Wellington Spot Red Patterned Rose Heeled 4dq8EwZ5
Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5 Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5 Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5 Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5 Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5 Swing Gold Dress Toe of Women Theather Waltz 2 Dance Art Standard Party by 50 Closed Shades 5

Container Security: 10 Things DevOps Need to Do

• Understand the challenges of a shortened pipeline

• 52% of devs worry app security will delay development

• 63% of organizations have a formal DevSecOps team

Hijack Sneakers Nike Mid Womens Green FxHSnHwq