Posts

Showing posts from July, 2021

Object Oriented Design Basic Concepts

Image
Reference from:  Clean Architecture: A Craftsman’s Guide to Software Structure and Design  Robert C. Martin   You can see this clearly in   Figure 17.1 . The   BusinessRules   use the   DatabaseInterface   to load and save data. The   DatabaseAccess   implements the interface and directs the operation of the actual   Database . Figure 17.1  The database behind an interface The classes and interfaces in this diagram are symbolic. In a real application, there would be many business rule classes, many database interface classes, and many database access implementations. All of them, though, would follow roughly the same pattern. Where is the boundary line? The boundary is drawn across the inheritance relationship, just below the  DatabaseInterface  ( Figure 17.2 ). Figure 17.2  The boundary line Note the two arrows leaving the  DatabaseAccess  class. Those two arrows point away from the  DatabaseAcces...

Events get fired multiple times even if event is triggered only once

 Sometimes, it is observed that even if event is triggered only once then event handlers gets invoked multiple times. Root causes: Events are registered multiple times during page load or function is loaded. This causes the triggering of event multiple times. Solutions: 1. One better way to avoid this is to first off the event and then on the event during page load for e.g.    id.off('click').on('click', somefunction) So, with when page loads again it will first deregister and then register the event for the same instance. This will cause the function to deregister first and then reregister. works like toggle  2. Other idea is to use stopimmediatepropagation under handler function