New answers tagged

-1

Can anyone help in deciding how do I uniform these two through a single interface having two implementation? Or are they not meant to be uniformed via a single interface and deserve a separate way of implementation? In short, Interface Segregation principle is important because if a certain class becomes the new hotness then one would want to use it ...


1

You can look to the W3C specifications as an example. They describe a small syntax of their own which means you can implement the HTML5 spec in any language: https://www.w3.org/TR/html5/ Another good example to look at are descriptions of algorithms and data structures which have a small syntax of only necessary components and leave the implementation ...


2

I would decouple the three responsibilities for a repository (load book from XML, load book from a database, cache book) into three different implementations: public interface BookRepository { Book getBookFromId(string id); } public sealed class XmlBookRepository : BookRepository { private readonly string path; public XmlBookRepository(string ...


2

I think what you are looking for is a Business Rules Engine. It provides a nice neat reusable way of decoupling your "custom logic" from the "core logic". There are a number of lightweight FOSS BREs out there, hopefully in a language you're comfortable with, as well as some exceedingly expensive ones that are sold to organisations who want to be able to ...


1

OK I think some of the other answers touch on this, but I will spell it out. Constructors are not part of the Interface so you can have different ones for each repo. public BookRepoXml(string xmlStringContainingAllBookData) //or a filename to the bookxml? { this.cachedChapters = this.ParseXmlIntoChapterDictionary(xmlStringContainingAllBookData); } ...


0

If I understand correctly, your Book is basically a list of chapters with additional metadata and you want to add it two ways of loading through a unified interface. But depending of the persistance, the get/load operation changes. if I add GetNextChapter method in the interface, Database implementation needs only the chapterID as parameter, whereas Xml ...



Top 50 recent answers are included