New answers tagged

1

You could make a generic DbEntity type that has an id, and keep your domain types free of database specific stuff. Like so: type DbEntity<T> = T & { id: number }; class Person { constructor(public name: string) {} } interface PersonRepository { getPersonById(id: number): DbEntity<Person>; saveNewPerson(person: Person): ...


4

We solved this issue by separating actual business data from the database related things. Let's take the example of a person. export interface Person { name: string; age: number; favoriteColor: string; } Now we can wrap that interface (or class) with a more generic one, which holds all database related things. export interface ModifiableEntity&...


2

No it doesn't. A social media page, maybe, but even there that's not true. How often do users change their friends/following lists? Much less often I'd wager. What about the list of credit card types, VISA, MC, AmEx, which an online store (like Amazon) accepts? Do you think the cards accepted are changing daily? And its not just the card type, b/c each ...


0

First of all, I must agree @gnasher729. Internet is NOT cheap and available everywhere. Especially in non first world countries. What if user want to check chat log in offline mode? I will assume your answer is it is immutable. So before discussing anything, You have to define why you NEED the truth? An game validates dlc purchase? If a user wants to ...


4

You need a single source of truth. Having a single source of truth that is always available is very handy. It really makes life easier if you use an always available database as single source of truth and use the server to update the database. The network is not always available. A fast network is not always available. And lots of people do not have ...


2

You can't "ditch the repository pattern" if all your classes are repositories despite the naming. Here it looks like both your datamapper and service are simply repositories. Flatten them out and call it a repository. Or lose the service layer. If it has no logic you don't have a service. The purpose of a layered design is to separate out parts of your ...


Top 50 recent answers are included