![]() Who knows, maybe for read-only clients you can issue a better optimized query or use a memory cache, but if not - you can just pass them the instance of your default data storage implementing this interface. By separating this interface you can later on make a separate implementation of it. For example, if some classes will only need to Read from the data storage it makes total sense to extract an interface with just the Read method and request that interface as an argument to such methods. With regards to 4 interfaces, that is closer to another SOLID principle, the ISP, and the need here is determined by the patterns of usage of your data storage. That is if your CRUD implementation is hard-coded to only work with a specific instance of an MS SQL 6.0 database, then you violate SRP and the class will not be easily reusable or extandable. The single-responsibility principle ( SRP) is a computer programming principle that states that 'A module should be responsible to one, and only one, actor.' 1 The term actor refers to a group (consisting of one or more stakeholders or users) that requires a change in the module. Now your underlying storage technology itself IS a reason for your class to change. The same with CRUD, it is a simple, established, well-known set of operations over a data storage. These are two standard operations people do with a stack. If I have a Stack class, are Push and Pop reasons for the class to change? In my view Create, Read, Update, and Delete are four reasons for a java oop design-patterns solid-principles single-responsibility-principle Share Improve this question Follow asked at 11:07 Manikandan Kbk DIP 463 3 13 The difference is to use another class which aggregate all (some) operation for email.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |