DCSIMG
C# - Smallfish

Smallfish

Tips, Tricks, Shticks & Anything That Can Help You Be better Developer

Browse by Tags

All Tags » C# (RSS)
Quality Code Short Tip #3 – Use Nested Class for Constants
One of the ‘best-practice’ and code styling guidelines say that you need to use constants instead of literals for more readability and ease of maintenance. Among the usages there are time that you want to specify database field names, xml attribute / element names and etc. In such cases the code easily get messed with dozens of constants around the code and make it harder to find the constant you need. A little trick can aid here: Instead of: 1: class TheClassUsingTheConstants 2: { 3: public const...
Session Manager (post on post on post)
Today I read the Ran Wahle ’s "Session manager" that was (kind of) response to Shlomo Goldberg ’s post about a way to use the session state in type-safe way. Because I tried out both approaches but was only satisfied with another (slightly sharper approach to Ran’s) and I will be glad to share it too (as in all other fields, pick the best that works for you project in hand). After several projects I have got to conclusion that there is no need for more than one object graph in the session...
WPF vs. Windows Forms
This argument exists since the first version of WPF (Windows Presentation Framework), so what should one select, WPF or Windows Forms? I will start with my conclusion / disclaimer: Any new windows client should use WPF! Now, for the explanation: The biggest "flaw" of WPF is its learning curve, it is slightly hard to understand the "rhythmic" of it. Thus, many companies / developers prefer the comfort zone of windows forms as it seems more easy and "fast" to develop....
Quality Code Short Tip #1 – Say “Defects” not “Bugs”
I wanted to start a short tips series for improving code and application quality, each post will be 1 to few sentences with a tip. First tip: Say “Defects”, not “Bugs” For me, the word “bug” sounds as “something not so important that is in the nature of the application”, which at least it isn’t true! when the application doesn’t do what it should (or do it wrong, or crash etc) it is a Defect in our application. It is hard because we are so naturally says it, but we should start to change our terminology...
Posted: Sep 25 2009, 09:24 AM by Yair Cohen | with no comments
תגים:, ,
How To Create XAML Markup Extension in WPF – Creating the Now markup extension
What? Display a label and analog clock on screen, they should be updated “live” with the time. How? I use XAML Markup Extension for several reasons: It makes it easy to use it on XAML, especially to bind to it. Learn the framework extension points. Reuse – easy to use it everywhere with half line of XAML. Show me the money!     /// <summary>     /// XAML Markup Extension to bind dependency property (DateTime or String)     /// to the current date...
Posted: Apr 19 2009, 08:46 AM by Yair Cohen | with 1 comment(s)
תגים:, , ,
LINQ to SQL Performance loading Hierarchical data
Last week I have trying to load hierarchical data from the same table (Parent/Child). Although I have made it in the past, I was searching the way to accomplish it with LINQ to SQL without SP or at least with the minimum required (in any case, I had a "fallback"). After 4 hours of searching the net without success (there are plenty of articles, nothing met my requirements see here and here ). Then I thought to give LINQ a chance, and I just used it querying the association created by the...
Testing WCF Service using Visual Studio 2008 Unit Tests
Technorati Tags: Unit Tests , Test , WCF , C# , Visual Studio 2008 Testing Windows Communication Foundation (WCF) service should be handled in a slightly different way than other "regular" .net types. We should test the service logic (as always) but we also need to test it in few more manners to assure our service quality: Test the service within WCF runtime environment - which can raise several issues that would not be in regular CLR environment. Test for your default binding and for all...