Tag Info

Hot answers tagged

4

This is sort of problems intended to be dealt with using Template method pattern: ...behavioral design pattern that defines the program skeleton of an algorithm in a method, called template method, which defers some steps to subclasses. It lets one redefine certain steps of an algorithm without changing the algorithm's structure... Applied to your ...


3

The problem I am trying to solve is, given two types, how can I determine whether one can be converted to the other. In your language design, you have a well defined set of rules for your type system. A is a subtype of B if and only if these conditions hold. C can be assigned to a variable of type D if and only if these other conditions hold. And you ...


3

Delegation in code is the same thing as it is in real life; you're handing a task off to someone or something else to execute. In user interfaces that have event handling, this is a good thing, as the code behind the UI is already complex enough, and delegation helps avoid a big ball of mud. As a matter of general practice, I push as much logic as I can to ...


2

Sticking to option 1 will allow you to change the least amount of things when you switch from one database to another, thus the change should have the least impact on your application since only the files concerned with the database will need to be changed. The business layer and any other layer which does not deal with the database should not care, nor ...


2

If you have too many dependencies being passed around, the general technique is to eliminate those dependencies higher up in the call stack, by changing the order decisions are made. This is easiest to explain with an example: getPath(config, user) { if (config.isB2B()) return b2bpath(config, user); else return b2cpath(config, user); } ...


1

The second design is almost certainly better than the first, unless SomeMoreInformation is both very expensive and entirely optional.


1

The main reason you would have the interfaces for your repositories in your BLL is to avoid having hard references to the separate DAL but instead have your changing DAL reference the stable BLL. To be able to swap out implementations without changing the stable BLL On the internet this might not be the main reason in general, but this would be a ...


1

I would create a table to represent the room, perhaps: Room ------------ RoomId (PK) RoomNumber Then a table to represent a reservation: Reservation ------------------ ReservationId (PK) RoomId (FK) StartTime EndTime For any given period, you just need to search for all reservations that are valid for that period, e.g to find how many reservations ...


1

I would put the parsing code in a factory class that knows how to create both a single instance of the Model class from the JSON as well as how to create a sequence of Model class instances from the JSON. This is based on the assumption that you already know what objects are being represented by the JSON. If you don't know exactly what objects the JSON ...


1

My understanding of MVVM is that the term model doesn't refer to a specific model, but to the entire domain model. I think the confusion comes from the fact that many View Models (in my experience) exist to enable CRUD operations on an Entity. That makes it seem like model refers only to a single entity model. But a View Model doesn't need to be confined ...



Only top voted, non community-wiki answers of a minimum length are eligible