Next level of Don’t Repeat Yourself(DRY) principle

We are building the software applications using various languages for several years. Over the time new frameworks, new tools, new methodologies have came up. Especially in Java platform, now we have plenty of choices in each area following various design patterns and principles like MVC, FrontController etc. We have many development principles like KISS(Keep It Simple Stupid), DRY(Don’t Repeat Yourself) which encourages to write better code which is maintainable. Especially DRY principle is a very good one which every developer should understand and follow. The DRY principle is stated as “Every piece of knowledge must have a single, unambiguous, authoritative

Continue reading »

What is Inversion Of Control (IOC)?

Inversion Of Control is a design pattern which suggests the creation of collaborating objects and injecting them should not be done by the dependent object itself. For example, Suppose WhetherController(Servlet) is depend on WhetherService which is depend WhetherDAO. WhetherController .javaclass WhetherController extends HttpServlet{ protected doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { WhetherService service = new WhetherService(); service.doSomething(params);….…. }} WhetherService.javaclass WhetherService{ public void doSomething(Map params) { WhetherDAO dao = new WhetherDAO();dao.getWhetherReport(); }} WhetherDAO.javaclass WhetherDAO{ // code to interact with Database} If you code as said above and if it is a big project you may use WhetherService/WhetherDAO in several classes.

Continue reading »