design-patterns

Mapping inheritance in EntityFramework Core

孤者浪人 提交于 2021-01-27 21:10:22
问题 I'm using EntityFramework Core, Code First and Fluent Api to define model database, and i've follow situation about strategy of map inheritance: public class Person { public int Id { get; set; } public string Name { get; set; } } public class User : Person { public string UserName { get; set; } public string Password { get; set; } } public class Employee : Person { public decimal Salary { get; set; } } public class Customer:Person { public long DiscountPoints { get; set; } } Business logical

Localized entities in database

↘锁芯ラ 提交于 2021-01-27 19:05:52
问题 I'm developing a ASP.NET Core MVC application and need to design Multilanguage values for entities. There is a lot information how to support localization in UI pages using .resx. I'm looking for some common pattern how to support localization for entities (not for static content on web page), that can be edited by user. Let say there is a simple dictionary in database table with Statuses Id Name ---------------------------------------------- 1 Not processed 2 To be cancelled 3 To be

One Test-Class per method?

痴心易碎 提交于 2021-01-27 18:32:01
问题 since today I have used the pattern to create one test class per class. For example the class "Foo" with the methods "DoSomething" and "DoNothing" had one test class called "FooTests". Now I have heard about creating one test class for every method. For the previous example this would mean I create two new classes called "DoSomethingTests" and "DoNothingTests" instead of the class "FooTests". Is this a commonly used pattern and should I switch to this one, or is this furthermore an anti

How would inheritance be used in MySQL?

心已入冬 提交于 2021-01-27 14:06:41
问题 So I'm reading a book on database design principles and came on the chapter about inheritance, but I'm confused on how I could "connect" sub classes with their super class in MySQL ? The table structure would, for example, look like this So how would I relate these two sub classes with their super class so that I could easily do a query similar to " hey, get me a correct contract type for a Person he is assigned to ". A person could have one of each, or even both of them, if, for example, a

Circular dependency in Spring injection - Is this bad design?

房东的猫 提交于 2021-01-27 13:40:39
问题 I am stuck with following issue : I am trying to create beans as follows: @Bean public abc createABC() { return new ABC(--, def(),--); } ` @Bean public DEF def() { return new DEF(--, createABC(),-- } Any suggestions to get around this problem without chaging to setter based injection. Is it the indicative of bad design? In my situation this dependency is must. Please provide your viewpoints on this 回答1: it the indicative of bad design? Absolutely. If ABC depends on DEF and DEF depends on ABC

Circular dependency in Spring injection - Is this bad design?

淺唱寂寞╮ 提交于 2021-01-27 13:25:56
问题 I am stuck with following issue : I am trying to create beans as follows: @Bean public abc createABC() { return new ABC(--, def(),--); } ` @Bean public DEF def() { return new DEF(--, createABC(),-- } Any suggestions to get around this problem without chaging to setter based injection. Is it the indicative of bad design? In my situation this dependency is must. Please provide your viewpoints on this 回答1: it the indicative of bad design? Absolutely. If ABC depends on DEF and DEF depends on ABC

Giving database context to object Factory

旧时模样 提交于 2021-01-27 13:21:50
问题 There is a question I always ask myself when I'm using a Factory pattern inside my code (C#, but it applies to any language I suppose). I have a "Service" that takes care of interacting with my database, do stuff with objects and interacts with my object model. This Service uses a Factory sometimes to delegate the instanciation of an object. But this factory obviously needs to interact by itself with the database to instanciate my object properly. Is it a good/bad practice to pass the

structure a large project software with MVC [closed]

一曲冷凌霜 提交于 2021-01-27 10:31:20
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I'm building a big project with MVC, the best way division of its structure, including Backend and customers. I can make a sample

structure a large project software with MVC [closed]

允我心安 提交于 2021-01-27 10:30:42
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I'm building a big project with MVC, the best way division of its structure, including Backend and customers. I can make a sample

Design pattern to check if a JavaScript object has changed

送分小仙女□ 提交于 2021-01-21 06:43:11
问题 I get from the server a list of objects [{name:'test01', age:10},{name:'test02', age:20},{name:'test03', age:30}] I load them into html controls for the user to edit. Then there is a button to bulk save the entire list back to the database. Instead of sending the whole list I only want to send the subset of objects that were changed. It can be any number of items in the array. I want to do something similar to frameworks like Angular that mark an object property like "pristine" when no change