Archive for the ‘Development’ Category
Posted by jpluimers on 2013/11/12
You can pass anonymous types to a method, if that method has a generic parameter type. I regularly use this to Resolving a parameter name at runtime using the Generic Type Cache technique described by Rinat Abdullin.
The other way around however is impossible, as return types cannot, as Alexander M. Batishchev writes in his StackOverflow answer:
You can’t.
You can only return object, or container of objects, e.g. IEnumerable
Jared Par does a bit more elaboration:
You cannot type any method in C# to be the explicit type of an anonymous types. They cannot be “named” so to speak and hence cannot appear in metadata signatures.
If you really want to return a value which is an anonymous type there are 2 options
- Have the return type of the method be System.Object. You can then do evil casting hacks to get a typed value in another method. This is very fragile and I don’t recommend it.
- Use a generic method and a type inference trick to get the return type correct. This would require a very interesting signature definition for your approach.
Anonymous types were not really meant to be passed around in this fashion. At the point you need to pass them around between your functions in this manner, you’re better off explicitly defining a type.
Bummer (:
–jeroen
via:
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2013/11/07
Wow, I’ve been living under a stone (:
Just discovered the online Cyber-Dojo by Jon Jagger. It is an online manifestation of a Coding Dojo. Both have been there for years, and I think both are brilliant.
They take the concept of a Dojo as being a place to practice sports like martial arts in a pair or group setting with a series of Katas or practices.
Katas in a Dojo are a means for performing deliberate practice in order to learn new things. For instance, acquire new movement techniques, learn about your balance, gain strength, all in both a physical and mental way.
The aim of both is do more deliberate practice.
When performing Coding and Cyber Dojo, you should use Test Driven Development using pair programming and BabySteps. Those help you to slow down, as one of the Dojo Principles is for Katas to slow down. It reminds me of the “if you are in a hurry, sit down” mantra and is a key part of the Coding/Cyber Dojo Principles too.
The aim is to learn, and part of that is to first un-learn and open you to new thoughts. That’s why it is so cool that the Cyber-Dojo provides you with:
- a bunch of pre configured programming languages*,
- preformulated practices** (including a few cyber-dojo refactorings),
- a small boilter plate to get started.
You’d think they speed you up, but that is not their aim. Like a regular Dojo it gives you an pre-set environment and gives you piece of mind to get started.
The Cyber Dojo does without a Sensei, whose purpose in a Coding Dojo is to ask questions in order to guide the participants.
That’s why it is good to use the Cyber Dojo as part of a Coding Dojo: basically the Cyber Dojo provides a standardizes set of tools to quickly setup a Coding Dojo.
Cyber Dojo languages
(a prime number, so the table is a bit distorted)
| C |
Go |
PHP |
| C# |
Haskell |
Perl |
| C++ |
Java-Approval |
Python |
| Clojure |
Java-Cucumber |
Ruby |
| CoffeeScript |
Java-JUnit |
Ruby-Rspec |
| Erlang |
Javascript |
Cyber Dojo practices
Many of the practices come from rosettacode.org.
| 100 doors |
Harry Potter |
Print Diamond |
| Anagrams |
LCD Digits |
Recently Used List |
| Bowling Game |
Leap Years |
Reversi |
| Calc Stats |
Mine Field |
Roman Numerals |
| Count Coins |
Monty Hall |
Tennis |
| Diversion |
Number Names |
Unsplice |
| Fizz Buzz |
Phone Numbers |
Verbal |
| Game of Life |
Poker Hands |
Yahtzee |
| Gray Code |
Prime Factors |
Zeckendorf Number |
–jeroen
via:
Posted in .NET, Agile, C, C#, C++, Development, Java, JavaScript/ECMAScript, Perl, PHP, Scripting, Software Development, Unit Testing | 3 Comments »
Posted by jpluimers on 2013/11/06
A while ago, I came across this blog: Levis’s Little Blog about Reverse Code Engineering (RCE) | All about Reverse Code Engineering.
It is of a beginning reverse engineering guy, doing reverse engineering of parts of application code, and being part of a REPT scene publishing key generators and crackers of software.
I think the interesting part is not so much his skill level, but has these aspects:
- his choice of tools and how he develops skills tells you much about the scene and how they work
- examining the keygens, cracks, etc, tells you a lot about how well the software is that we write
- the abundance of people like him and the available tools basically void every copy protection scheme you can imagine
Part of his toolset are come from a few video tutorials he posted about, where this is in the context menu of a .EXE file: Read the rest of this entry »
Posted in Development, Software Development | Leave a Comment »
Posted by jpluimers on 2013/11/05
For my link archive, thanks Alek Davis:
Just keep in mind that ID of the CPU is not always available.
By the way, what are you trying to accomplish? If you want to generate a unique key for a computer instance, check the Generating Unique Key (Finger Print) for a Computer for Licensing Purposes post by Sowkot Osman at Codeproject; it can give you some hints (also read comments).
–jeroen
via: .net – APIs in C# for grabbing CPU IDs and drive/volume serial – Stack Overflow.
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2013/10/31
The question datetime – Delphi Now() function returns a wrong value – Stack Overflow is similar to my article Delphi – Michael Justin had strange floating point results when his 8087 FPU Control Word got hosed.
Good that stackoverflow user Anton Zhuchkov found out the cause himself: his answer indicates the Precision Control (and rounding) part of the FPU state got hosed by wrongly initializing the Direct3D device.
I edited his answer with some extra links to documentation.
Finally I’ve found the solution. I needed to specify the D3DCREATE_FPU_PRESERVE flag when creating a D3D device by D3D.CreateDevice.
Otherwise, without that flag, all floating point operations are performed with single precision. As the TDateTime is a simple Double, and Now() functions is consist of simple addition of date value to time value, it all get messed up by DirectX “smart” override.
Problem solved. It was a tricky one indeed. :)
–jeroen
via: datetime – Delphi Now() function returns a wrong value – Stack Overflow.
Posted in 8087, Algorithms, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Floating point handling, Software Development | 2 Comments »
Posted by jpluimers on 2013/10/30
I need to do some research to automate the backups and restore sequences of some SQL Servers.
Here are some links and notes to get started:
Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | Leave a Comment »
Posted by jpluimers on 2013/10/29
Toon Krijthe posted an interesting question to SO.
Though 5 years old, I think it stilll is very valid one:
At my work, we have decided to stay with the ANSI characters for identifiers. Is there anybody out there using unicode identifiers and what are the experiences?
For all projects I work on (in various Languages like English, German, Dutch or other), I stick to ASCII characters (not even ANSI) for:
I also try to abstract the non-ASCII strings into places where I am sure that the encoding is preserved (for text files, I prefer UTF-8), or where these characters are properly escaped.
What is your take on this?
–jeroen
via: uniqueidentifier – What are the experiences with using unicode in identifiers – Stack Overflow.
Posted in .NET, Agile, AS/400 / iSeries / System i, C, C#, C++, COBOL, Continuous Integration, Delphi, Development, F#, Prism, Scripting, Software Development, VB.NET, Visual Studio and tools | 4 Comments »
Posted by jpluimers on 2013/10/24
“there’s nothing so permanent as temporary” can apply to many things, for instance Kitchen and software development (there technical debt is very applicable), the financial top gap measures (which are real debt) of fanfiction. You can apply it to SQL Server as well. The TempDBhas been there since before SQL Server 7, which means it has established a permanent feature for quite some time now.
Your DBA (which might be you) needs to watch the temdb size or space on the separate volume where temdb is stored, or someday the TemDB access patterns will cause havoc.
The most used feature (there are more) in TempDB is temporary tables (often abbreviated to “temp tables”), which – since TemDB got there – has come in three flavours:
The table variables are created and released implicitly. The temporary tables (one of the Special Table Types) can be created either explicitly using a CREATE TABLE, or implicitly using SELECT … INTO. You’d think that temporary tables are indeed temporary. But they are not:
Temporary tables are semi-temporary. Not actually permanent, but not fully temporary either.
All flavours of temporary tables are not being fully deleted when they go out of scope. When they go out ot scope, they will get an implicit/automatic truncate to empty them (so there is no manual TRUNCATE TABLE or DROP TABLE needed). But the table itself lives on including any cached plan information. They can, and often will be reused. And that’s where you should start reading these links:
One more thing: as of SQL Server 2012, the OBJECT_ID associated with temporary tables is negative.
–jeroen
via:
Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | 2 Comments »
Posted by jpluimers on 2013/10/23
Thanks StackOverflow users George Stocker for asking, Örjan Jämte and Sir Crispalot for answering.
Below is the SQL Server 2012 table, in which I added links to the various data types.
I also added two columns with linked references to the types from the C# data types, C# Keywords, Reference Tables for Types (C# Reference) and Data Type Summary (Visual Basic).
One of the things I need to check is against the LINQ SQL-CLR Type Mapping.
It is very important to keep in mind that in SQL, each combination of precision and digits gets you a different decimal type, and all of them are different from the .NET decimal type. See for instance the answers on these questions:
Read the rest of this entry »
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Algorithms, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Database Development, Development, Floating point handling, Software Development, SQL Server, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »
Posted by jpluimers on 2013/10/22
Every once in a while, you will have to do is checks using reflection.
Basically there are two methods:
Thanks to Ani and Werner Beroux for explaining the difference in more detail on StackOverflow, I added some extra links:
To check for assignability, you can use the Type.IsAssignableFrom method:
typeof(SomeType).IsAssignableFrom(typeof(Derived))
This will work as you expect for
but not when you are looking for ‘assignability’ across explicit / implicit conversion operators.
To check for strict inheritance, you can use Type.IsSubclassOf:
typeof(Derived).IsSubclassOf(typeof(SomeType))
–jeroen
via: c# – How to check if a class inherits another class without instantiating it? – Stack Overflow.
Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »