Tag | generics Posts

A couple of days ago I was asked if there was any way by which I could overload a method to "return" more than one type. If I was in a class room, or I was teaching a programming class (I've done that for some part of my life :)) my instant answer would have been "No." And then I would have proceeded to explain why the whole idea was not valid in the Object Orientation world. However, this question was not coming from a high school student. In all probabilities it was coming based on a practical ...
This is the kind of post that would usually go on my "other Blog" since that's where most of my technology posts go. Also, that is where I like to play it safe with what I write :). But since I've been blogging about the Open source thingy that I've started working on (I still can't believe I've already started wasting my weekends behind coding for a self commitment :)) I am going to go ahead and post all related material to that initiative here. Code-Smith (this is a Paid Product with 30 day trial) ...
A new NHIbernate release (alpha) supports generics and nullable types. The previews have been good. Even though i love NHibernate, this email by the development lead of the project underscored the need to avoid having Persistence mechanism details invading Domain logic ...
Ok, so we all use NDoc and love it. You do use NDoc, don’t you? Well, you may have stopped using it if you’re doing .NET 2.0 development, because NDoc’s support for .NET 2.0 is, well, not very satisfying. Microsoft has recognized an un-fulfilled need here and started work on a project called SandCastle. Sandcastle produces accurate, MSDN style, comprehensive documentation by reflecting over the source assemblies and optionally integrating XML Documentation Comments. Sandcastle has ...
Selecting a Collection Class The System.Collections.Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections. FIFO · Queue class · Queue generic class · where the element is typically discarded after its value is retrieved LIFO Stack class Stack generic class sequential access LinkedList generic class random access ...
September 10-13, 2006 Add the Most Anticipated VSLive! Sessions to Your New York Agenda Check out the top ten sessions at VSLive! New York. See which sessions your peers visited most on our conference Web site. Then, add these interesting topics to your “Must See” list for New York. The Early Bird Deadline of August 9 is right around the corner – lock in savings of $200 by using Priority Code TOP10. Register today to attend these top ten sessions and our full conference lineup September ...
The most important functionality of generics is to generate errors at compile time for typecasting exceptions that without generics could occur at runtime. Generics are also available in VB.NET. But VB.NET as a language has a history of being very forgiven when it comes to typecasting. How the VB compiler reacts to possible typecasting errors is configurable trough the OPTION STRICT flag for the project. By default (even in VS2005) it's OFF by default. With OPTION STRICT OFF the compiler ignores ...
Recently Castle has added support for Generics in their MicroKernel. This has lead to some wicked awesome code, thanks to some great ideas from Ayende. Ok, so I am going to try and explain a simple example using NHibernate public interface Repository<T> { T Find(Guid id); } and a NHibernate Implementation (here is the Find(Guid id) method) public class NHibernateRepository<T> : Repository<T> { //ctor to set up NHibernate stuff public T Find(Guid id) { ISession sess = GetSession(); ...
I was working with a customer a couple of months ago where they were repeating code again and again, for every business entity, so that each business entity had the same base set of persistance methods: RetrieveById Save CreateNew Before you ask, there lots of reasons why it had to be done this way and was done this way, none of which I'm really supposed to talk about, but suffice it to say that we all occasionally run into a situation where we want a bunch of classes to have the same static methods ...
I’ve been looking into MSIL mostly comparing the generated code from both vb and c# as I’m about to start an app where execution speed is going to be important, I’ll need to keep boxing down to a minimum, c++ is not an option because of time constraints. I’ve found a few handy tools along the way. Excellent tool this, version 3 of ILIDE can be downloaded from here http://nida.se/ilide/ unfortunately it appears to be tied to version 1.1 of the framework and therefore knows ...
Nice job this weekend. I moved forward a lot, implemented major features, tested most of them pretty extensively, thought about the future, and learned new things. So far, the features implemented are: Date, Title, Text, Frame, List. Features not implemented yet are: Images, Thumbnails. That should follow soon. Another important feature implemented: Each entry has an attribute "archive-older". If this attribute is set to "true", no older entries will be displayed after the current one. However, if ...
When Visual Studio 2005 was still in Beta, Visual C++ had a concept of STL .NET (now called STL/CLR), which in short is a porting of the STL to the CLR. One may ask, so why STL/CLR? As you may or may not have noticed, C++ will not accept managed types inside of an STL container. Nikola Dudar explains more about the differences in his post "What is STL/CLR". Stan Lippman had a great introduction of this great library in an article on MSDN called STL .NET Primer. Nick Weinholt also had a good introduction ...
A few days ago, I posted some links for study guides and links for the 70-536 exam. Well, it worked nicely for me as I passed with a 982! I know I missed one question on COM Interop because the way they were talking about returning an HRESULT to a COM caller is not the way I would do it. I chose the C# version since I've done most of my work in C# so far with Visual Studio 2005, although I could have done the C++ version just as easily. I already have the MCSD and the MCDBA, but I thought I'd try ...
Date:Thursday, June 22, 2006 Topic:Refactoring with Generics Speaker:Kathleen Dollard, Northern Colorado .NET SIG Generics open up new opportunities to increase the robustness of your code, improve its performance, and significantly reduce the total amount of code you write. After a brief introduction to generic syntax, this talk dives into using generics to improve the quality of your code. You'll see how easy it is to shift your current collections to generic collections and learn about new features ...
I apologize for the code not being indented , I am using word 2007 and no matter what I do it does not seem to want to indent properly (I have tried copy/pasting to notepad, you name it), if you know how to get this working please contact me. See picture of word version http://gwb.blob.core.window... update I manually indented all of it but I am still wanting to know how to avoid this Everyone seems to enjoy performance posts so …. I saw this question in the advanced ...
As some of you may have realized, I am in the process of re-implementing my AOP framework to fully support generics right now (figured I might as well as I am white boarding it for open source deployment anyways). I have come across numerous issues in dealing with generics. Today I sent an email to the castle project group (who are going through a similar task in supporting generics in Dynamic Proxy). I figured I would post that email here as well in case others have thoughts on some of the issues ...
In the first look I posted last week, I asked the question why the var keyword for implicit types were so powerful and more than just syntactic sugar. After a response, I then realized I overlooked something pretty obvious with regards to LINQ queries. I found this post from Cyrus' Blather to be quite helpful: http://blogs.msdn.com/cyrus... Let's just go over the details for my own piece of mind. Let's compare how we would do each query in .NET 1.1, 2.0 and now 3.0. First, ...
[Crosspost from Managed World] I have now ported over most of the Console functionality from Boom!. I still haven't ported over the ConsoleRenderer yet, so I'll just tackle that tomorrow hopefully. As a little background, Boom! was originally written in 1.1, so I've been pleasantly surprised with how much code I've been able to remove simply because I can use Generics now. The downside? We're not using 2.0 at work yet so it's torture everytime I need a strongly-typed dictionary or list during my ...
Jeff gave a good talk last night at the Kansas City .NET User group about the Provider Model. Material available here. It's something EnGraph could benefit from, but probably not something we are going to do right away. I need to get a better handle on generics first, that would make our products better. Jeff also set up a Google Group for the user group...check it out ...
We want a good performing application but it is hard to get it right. We all know how to format strings in a fast and efficient way don't we? Let me challenge you if anybody can beat my lightning fast fixed string formatting function. The rules are easy: We want to format the content of DateTime structure into a string of the form: "08:44:45.423" The performance measured is the time needed to return the formatted string when the DateTime structure is as input given. .NET 2.0 and C# only. For starters ...
This is cheap for right under $100. Wrox is releasing their “WROX BOX” on Amazon starting May 9th and it includes the following books and chapters: Professional ASP.NET 2.0 Professional C# 2005 Professional .NET Framework 2.0 Professional .NET 2.0 Generics CD-ROM with more than 700 pages of bonus chapters from 10 other .NET 2.0 and SQL Server™ 2005 Wrox books DVD with 180-day trial version of Microsoft® Visual Studio® 2005 Professional Edition This is a top of the line ...
I must have fallen asleep at the wheel. Didn't even notice it but Rotor 2.0 has been released!!! http://www.microsoft.com/do... New in this Release Full support for Generics. New C# 2.0 features like Anonymous Methods, Anonymous Delegates and Generics BCL additions. Lightweight Code Generation (LCG). Stub-based dispatch. Numerous bug fixes ...
Dave Donaldson prodded me this morning to get off my butt and post an update to my previous multi-sorting comparer, and I'm going to do that now. Man, Dave, get off my back!Ok. He didn't prod. He asked if I'd updated it to support Generics, which I had. If you look at the previous one, not a lot has changed, so let's just highlight the changes. First, instead of using an ArrayList to store the internal sorting classes, I'm using a Generics (it really wouldn't be a good upgrade if I didn't use generics ...
There is something I've been wanting to post about for a while, but just didn’t have enough info to make it worth my, or anyone who reads this, while. We all know that .Net 2.0 came out with something wonderful called Generics. I've been profiling a lot of my 1.1 code, comparing it to my 2.0 code that utilizes Generics, and the one change that has given me the greatest, most dramatic performance benefits is to switch from IComparer to IComparer. I use IComparer a LOT. But there is a problem ...
The VISUG has started it's events. Some more info on the VISUG : "The overall goal of the VISUG is to provide the Visual Studio .NET community in Belgium with the necessary infrastructure and organization to enable a community meeting point for everybody who is interested in Microsoft’s Visual Studio .NET related technologies. A lot of community activities are happening already in Belgium in the context of blogs, informal meetings, events organized by Microsoft or partners. VISUG wants to formalize ...
Last post I promised that I would post the final code that I was working on, in regards to Generics and DynamicMethods. The basic idea of the code is a class that generates DynamicMethod delegates that have been casted as a certain type of delegate, using Generics. Here's what I was thinking the calling code would look like TestDelegate del = generator.SomeMethod<Tes... Surprisingly, this was a lot hard than it first seems. It seems that there are some restrictions with Generics and ...
Now this is neat -- it is only 22MB download and 154MB uncompressed! The ultimate .NET Framework programming toy. New features in the SSCLI/Rotor 2.0 release include: Generics Lightweight Code Generation (LCG) Open static and closed instance Delegates Relaxed Delegates Loader and System.Reflection re-writes [\sscli20\clr\src\bcl\syste... Metadata format updates New C# features like Anonymous Methods, Anonymous Delegates and Generics support [\sscli20\clr\src\bcl\syste... ...
test Recently I had one of those aggrivating, head pounding, pick up the monitor and throw it through the window, wall, co-worker, whatever is closest. The issue involved using DynamicMethods, CreateDelegate method, and binding the DynamicMethod to an object. I was working on an experiment with DynamicMethods and Generics (thats for another post), when I encountered the problem. Thinking it was some issue to do with the Generics (which there are a lot), I worked on a test code that had nothing to ...

Today I explored generics properly and I must admit that I'm very sorry i did not take the time earlier

Bottom line : GENERICS ARE GREAT

Objects! objects! objects! it's so convenient to work with programming entities that you can ask to do something and they just do it. The shift that we developers have made from procedural style to OO style allows us to express ideas in much richer ways than were possible using procedural methods. Knowing how to identify areas where a new object can be introduced to simplify the code in your application is a talent that many spend years improving (I can't say perfect, because software development ...
4/28/06 Update: The NHibernate codeproject.com article wins ASP.NET article of the month. Woohoo!3/14/06 Update: See how this is used in a sample application at http://www.codeproject.com/... Hibernate.org has a great article on creating a generic DAO for Hibernate in Java. Below is what I use for the C# port. The interface for common CRUD functionality... public interface GenericDAO { T GetById(IdDataType id, bool shouldLock); List GetAll(); List GetByExample(T ...
Good use of generics in creating a Tree Class in C#.

Jeff and John are talking about Generics tonight (6:00 PM) at the Kansas City .NET User Group. I'm excited, I need to learn more about this. Map to location

Remember the good old go to statement? Go To Statement Considered Harmful (the original paper by Dijkstra) Ok, ok, we will do it object oriented from now on: Inheritance considered harmfulObject-Oriented Considered Harmful And with design patterns? Design Patterns Considered HarmfulSingleton Considered Stupid How about separation of concerns and aspect oriented programming? AOP Considered Harmful You thought generics were cool?Generics Considered Harmful What about web services?Web RPCs Considered ...
I am sure that everyone has heard of the new generation of certifications that Microsoft is coming out with, so I will not go in to much detail about them. But I was able to get in on a beta test for one of them. 071-536: TS: Microsoft® .NET Framework 2.0 - Application Development FoundationEnglish I found it to be quite interesting. This was the first time I have taken a beta test and didn't know what to expect. Nevertheless, it turned out to be 84 questions long and very extensive on many ...
This content has moved - click here. With the advent of .NET 2.0, Generics is undoubtedly the single most important language enhancement. However, to use generics to the full potential, developers should understand both the capabilities and limitations of generics as they relate specifically to polymorphism. In short, while generics do support some polymorphic behavior, the use of Interfaces should still be the preferred polymorphic mechanism in many cases. First, an example of polymorphic capabilities, ...
MSDN has published four FAQs about Generics in .net and they are a must read in my opinion to anyone who is interested in template based programming constructs! Fundamentals.Net Framework & GenericsTool Support for GenericsBest Practices ...
Yesterday I had some problems with sleeping, so, I thought I should do something useful. I opened my browser and favourites and my Gmail box and started typing to my MCAD course group and my close friends. I think I should put that here - after removing some parts of course! ;-) Lets start... Remember all the hussel online about AJAX stuff ? Maybe some of you have already got a book written about it. Some might have got into the whole ATLAS ? thing. Now I come to give you some more stuff I think ...
Crossposted from my Apress blog... I’m learning C#. As someone who has been using VB since version 3.0 (around 1993) and vb.net since the first beta, I’ve been on the fringes of learning C# for a few years now. Oh sure, I could read it pretty easy. Drop the semicolons and add a few keywords here and there… piece of cake. The problem was, I always tried to relate it back to VB. I never just absorbed it as C#. At some point, I decided to actually LEARN the language. Learn it, use ...
I'm frustrated with the lack of answers I'm getting from my company's IT department on our MSDN universal subscriptions. With the release of Visual Studio 2005 the subscriptions changed. And the administrator needs to change the subscription and select the appropriate one. Well ours apparently has not done that, because all I see is the trial edition of the Team Suite as well as the professional and standard versions. I've been too busy to work with VS 2005 yet, but now that it's released I want ...
Generics are pretty cool. You can think of Generics as a basket which can hold different datatypes without the process of casting. Here are few examples of Generics in action: Custom Collection: You can make use of the Generics to create a custom collection. System.Collections.Generic.... users = new List<Users>(); for (int i = 0; i <= 9; i++) { Users user = new Users(); user.FirstName = "Mohammad" + i; user.LastName = "Azam" + i; users.Add(user); } // print the users from ...
In computer science, generics is a technique that allows one value to take different datatypes (so-called polymorphism) as long as certain contracts such as subtypes and signature are kept. The programming style emphasizing use of this technique is called generic programming. For those of you, who want to get in to generics in NET 2.0, there is a very nice article here ...
I've started playing with Generics some lately (as if I needed something else to keep me busy) and they really aren't that hard to figure out with the right examples. (Start simple...) A lot of folks have been using the Swap example, which is simple enough to be fairly obvious when you look at it. (If you haven't seen it, I'm not going to pilfer it, just go look here and come back... I'll wait.) So anyway, that got me thinking about more complex implementations, such as in Game Development. Specifically, ...
Wow, what a great presentation!! I was fortunate enough be meet and attend Kathleen's presentation this evening on Code Generation, XSLT, & VS 2005 Generics at the monthly TRINUG user group meeting. She did a fantastic job explaining some involved and difficult topics all the while making it VERY understandable and applicable to daily coding cores. I walked away having learned something and glad I attended. I really enjoyed her presentation style as well, lively, energetic, and engaging. I look forward ...
So I was reading this long and enlightening article, written by someone waaay smarter than myself, about variance for generics and I encountered a cool new feature in C# 2.0. Simply put, when you define a Generic method, you can apply restrictions (constraints) to the kinds of types that client code can use when it calls your method. For example, you run into a problem if you want to copy a List<int> into a List<object>. This seems like a reasonable thing to do because an int is an object, ...
I feel like a lot of progess has been made this week. Thanks to Chris Williams making the code for HA's dungeon mapper availalbe, I can now display real dungeon maps instead of just random tiles (see snapshot below). Integrating Chris' VB.NET code into my C# application took less than an hour...don't you just LOVE .NET! I fleshed out more of the Character and Tile classes as well as adding a handful of new classes for Features. Features will manage things like openings, doors, stairs, traps, etc. ...
I wonder how long it'll take Microsoft to update the common libraries that really need Generics (SqlClient comes to mind)... If Microsoft would release those base class libraries into open source, you could have an army of people working in parallel on the issue, and the best would get included... Since .Net is basically given away free with the OS, why not throw that code right out there into the open source community? I know about Mono, and to a degree I don't really see the future of Mono ... ...
Designing Connected Systems with the .NET Framework and an Eye on the Future This session covered architecture, patterns, and philosophy to keep in mind when developing connected apps. It brought up some comples issues (at least from my level). Will have to ponder. Stuff like service oriented architecure, data contracts, Indigo...They're more than just words, and this presentation helped bring it all together. Heh, but not well enough for me to blog it yet. Developing High Performance Applications ...
What a busy day... Started off with What's new in the framework for version 2.0 which was a terrific presentation. Joel did an excellent job showing off some of the cooler aspects of what's new with 2.0. Among my favorites were the improved console class (for obvious HA! reasons) and the support for encrypted XML and of course generics. Edit and continue is back w/ 2.0 (and new to C#) but not without some limitations. Another cool thing he highlighted was Debugger Display Attributes. Cool stuff indeed. ...
During my consultancy engagements I have come across numerous time when you need to sort the value displayed in the drop down box or in the the other Data bound control. It can be very frustrating to do that if you don't have much experience with .Net and you have to repeat similar code again and again. Well .Net 2.0 will ease it quite a bit with Generics ... For now here is a class that works exactly like sorted list but sorts the List by Value instead of Key ... This is meant for reasonable size ...