theory

diffrence between running query with Func and Expression Func [duplicate]

旧城冷巷雨未停 提交于 2021-02-04 08:24:05
问题 This question already has answers here : Why would you use Expression<Func<T>> rather than Func<T>? (10 answers) What is the difference between IQueryable<T> and IEnumerable<T>? (12 answers) Closed 2 years ago . I have been searching on internet to find out the difference between Func and Expression Func, somehow i got the point,the first one is just a function gets the data and then apply the function in memory but the second,translate it to sql and run it in the database,after i run this

How to think about polymorphism with subtyping

我们两清 提交于 2021-01-27 12:09:40
问题 The Liskov Substitution Principle states: Invariants of the supertype must be preserved in a subtype. I'm particularly interested with the intersection of this principle and polymorphism. In particular subtype-polymorphism though, in fact, this seems to be the case with parametric polymorphism and Haskell type classes. So, I know that functions are subtypes when their arguments are contravariant and their return types covariant. We can assume that methods are just functions with an implicit

How to think about polymorphism with subtyping

╄→尐↘猪︶ㄣ 提交于 2021-01-27 12:05:50
问题 The Liskov Substitution Principle states: Invariants of the supertype must be preserved in a subtype. I'm particularly interested with the intersection of this principle and polymorphism. In particular subtype-polymorphism though, in fact, this seems to be the case with parametric polymorphism and Haskell type classes. So, I know that functions are subtypes when their arguments are contravariant and their return types covariant. We can assume that methods are just functions with an implicit

“Flat is better than nested” - for data as well as code?

元气小坏坏 提交于 2020-07-04 06:11:42
问题 This question got me thinking: should we apply the principle that "flat is better than nested" to data as well as to code? Even when there is a "logical tree structure" to the data? In this case, I suppose it would mean representing children as a list of IDs, rather than an actual list of children, with all the nodes in a single list: [ {'id': 4, 'children': ()}, {'id': 2, 'children': (1, 7)}, {'id': 1, 'children': (6, 5)}, {'id': 6, 'children': ()}, {'id': 5, 'children': ()}, {'id': 7,

“Flat is better than nested” - for data as well as code?

一世执手 提交于 2020-07-04 06:09:46
问题 This question got me thinking: should we apply the principle that "flat is better than nested" to data as well as to code? Even when there is a "logical tree structure" to the data? In this case, I suppose it would mean representing children as a list of IDs, rather than an actual list of children, with all the nodes in a single list: [ {'id': 4, 'children': ()}, {'id': 2, 'children': (1, 7)}, {'id': 1, 'children': (6, 5)}, {'id': 6, 'children': ()}, {'id': 5, 'children': ()}, {'id': 7,

Why unit tests should not use database?

本小妞迷上赌 提交于 2020-07-03 01:36:57
问题 Reading an article Evil Unit testing, I am not exactly sure WHY the unit tests should never use DB, network or file systems. What if it an network app? 回答1: Unit tests are used to test the functionality of the smallest unit of your code. They should not have any dependency on any external resource that might change in future. To take an example, let's say today you write a unit test that test a method that performs addition of two numbers. public void AddNumberTest() { int a = 4; // Assume 4

Why unit tests should not use database?

我只是一个虾纸丫 提交于 2020-07-03 01:36:32
问题 Reading an article Evil Unit testing, I am not exactly sure WHY the unit tests should never use DB, network or file systems. What if it an network app? 回答1: Unit tests are used to test the functionality of the smallest unit of your code. They should not have any dependency on any external resource that might change in future. To take an example, let's say today you write a unit test that test a method that performs addition of two numbers. public void AddNumberTest() { int a = 4; // Assume 4

What is the use of reflection in Java/C# etc [duplicate]

天大地大妈咪最大 提交于 2020-06-25 07:33:28
问题 This question already has answers here : What is reflection and why is it useful? (21 answers) Closed 3 years ago . I was just curious, why should we use reflection in the first place? // Without reflection Foo foo = new Foo(); foo.hello(); // With reflection Class cls = Class.forName("Foo"); Object foo = cls.newInstance(); Method method = cls.getMethod("hello", null); method.invoke(foo, null); We can simply create an object and call the class's method, but why do the same using forName,

Can you please explain Reed Solomon encoding part's Identity matrix?

一个人想着一个人 提交于 2020-05-17 07:27:04
问题 I am working on a object storage project where I need to understand Reed Solomon error correction algorithm, I have gone through this Doc as a starter and also some thesis paper. 1. content.sakai.rutgers.edu 2. theseus.fi but I can't seem to understand the lower part of the identity matrix (red box), where it is coming from. How this calculation is done? Can anyone please explain this. 回答1: The encoding matrix is a 6 x 4 Vandermonde matrix using the evaluation points {0 1 2 3 4 5} modified so