strong-typing

Strongly typed datasets vs. weakly typed datasets

柔情痞子 提交于 2019-12-01 03:49:14
What is meant by strongly typed datasets in .Net? Can anybody explain with a clear and brief example? And also, what is the difference between strongly typed and weakly typed datasets? Strongly Typed Datasets are generated on the basis of a Db Schema. They consists of classes derived form DataSet, DataTable and DataRow. Db Columns become correctly typed properties of the TableRow derived class. An Untyped Dataset simply means the direct use of Dataset, not of a descendant. All column access has to be type-cast. There is no such thing as a Weakly Typed Dataset . Typed Versus Untyped Datasets A

Is there a way to make Strongly Typed Resource files public (as opposed to internal)?

吃可爱长大的小学妹 提交于 2019-12-01 02:12:44
Here's what I'd like to do: I want to create a library project that contains my Resource files (ie, UI Labels and whatnot). I'd like to then use the resource library both in my UI and in my Tests. (Ie, basically have a common place for my resources that I reference from multiple projects.) Unfortunately, because the StronglyTypedResourceBuilder (the .Net class which generates the code for Resources) makes resource files internal by default, I can't reference my strongly typed resources in the library from another project (ie, my UI or tests), without jumping through hoops (ie, something

Static/strong typing and refactoring

久未见 提交于 2019-11-30 20:39:56
It seems to me that the most invaluable thing about a static/strongly-typed programming language is that it helps refactoring: if/when you change any API, then the compiler will tell you what that change has broken. I can imagine writing code in a runtime/weakly-typed language ... but I can't imagine refactoring without the compiler's help, and I can't imagine writing tens of thousands of lines of code without refactoring. Is this true? I think you're conflating when types are checked with how they're checked. Runtime typing isn't necessarily weak. The main advantage of static types is exactly

Type hinting / annotation (PEP 484) for numpy.ndarray

旧城冷巷雨未停 提交于 2019-11-30 07:49:53
Has anyone implemented type hinting for the specific numpy.ndarray class? Right now, I'm using typing.Any , but it would be nice to have something more specific. For instance if the numpy people added a type alias for their array_like object class. Better yet, implement support at the dtype level, so that other objects would be supported, as well as ufunc . It looks like typing module was developed at: https://github.com/python/typing The main numpy repository is at https://github.com/numpy/numpy Python bugs and commits can be tracked at http://bugs.python.org/ The usual way of adding a

Passing strongly typed property name as argument

心已入冬 提交于 2019-11-30 07:41:37
I have a collection of IEnumerable<School> that is being passed to an extension method that populates a DropDownList . I would also like to pass the DataValueField and DataTextField as an argument but I wanted them to be strongly typed. Basically, I don't want to pass a string for the DataValueField and DataTextField arguments, it's error prone. public static void populateDropDownList<T>(this DropDownList source, IEnumerable<T> dataSource, Func<T, string> dataValueField, Func<T, string> dataTextField) { source.DataValueField = dataValueField; //<-- this is wrong source.DataTextField =

Type hinting / annotation (PEP 484) for numpy.ndarray

半世苍凉 提交于 2019-11-30 07:02:59
问题 Has anyone implemented type hinting for the specific numpy.ndarray class? Right now, I'm using typing.Any, but it would be nice to have something more specific. For instance if the numpy people added a type alias for their array_like object class. Better yet, implement support at the dtype level, so that other objects would be supported, as well as ufunc. 回答1: It looks like typing module was developed at: https://github.com/python/typing The main numpy repository is at https://github.com

Static/strong typing and refactoring

独自空忆成欢 提交于 2019-11-30 04:56:39
问题 It seems to me that the most invaluable thing about a static/strongly-typed programming language is that it helps refactoring: if/when you change any API, then the compiler will tell you what that change has broken. I can imagine writing code in a runtime/weakly-typed language ... but I can't imagine refactoring without the compiler's help, and I can't imagine writing tens of thousands of lines of code without refactoring. Is this true? 回答1: I think you're conflating when types are checked

Strongly typed access to csv in scala?

柔情痞子 提交于 2019-11-30 04:15:24
I would like to access csv files in scala in a strongly typed manner. For example, as I read each line of the csv, it is automatically parsed and represented as a tuple with the appropriate types. I could specify the types beforehand in some sort of schema that is passed to the parser. Are there any libraries that exist for doing this? If not, how could I go about implementing this functionality on my own? product-collections appears to be a good fit for your requirements: scala> val data = CsvParser[String,Int,Double].parseFile("sample.csv") data: com.github.marklister.collections.immutable

template argument deduction with strongly-typed enumerations

天涯浪子 提交于 2019-11-30 00:07:22
If I have a normal (weak) enumeration, I can use its enumerated values as non-type template parameters, like so: enum { Cat, Dog, Horse }; template <int Val, typename T> bool magic(T &t) { return magical_traits<Val>::invoke(t); } and call it as: magic<Cat>(t) as far as I can see, if I have a strongly-typed enumeration and don't want to hard-code the enumeration type, I end up with: enum class Animal { Cat, Dog, Horse }; template <typename EnumClass, EnumClass EnumVal, typename T> bool magic(T &t) { return magical_traits<EnumVal>::invoke(t); } and now I have to write: magic<Animal, Animal::Cat>

Better way of doing strongly-typed ASP.NET MVC sessions

风格不统一 提交于 2019-11-29 22:24:37
I am developing an ASP.NET MVC project and want to use strongly-typed session objects. I have implemented the following Controller-derived class to expose this object: public class StrongController<_T> : Controller where _T : new() { public _T SessionObject { get { if (Session[typeof(_T).FullName] == null) { _T newsession = new _T(); Session[typeof(_T).FullName] = newsession; return newsession; } else return (_T)Session[typeof(_T).FullName]; } } } This allows me to define a session object for each controller, which is in line with the concept of controller isolation. Is there a better/more