Author Topic: Read-Only Property or Method?  (Read 6525 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Read-Only Property or Method?
« Reply #15 on: January 14, 2009, 03:21:58 PM »
Dan,

Please refer to the Microsoft guidelines :D

Seriously, you're right - it depends on what you're designing at the end of the day doesn't it? <cheeky grin>

Cheers,
Glenn.

Ken Alexander

  • Newt
  • Posts: 61
Re: Read-Only Property or Method?
« Reply #16 on: January 14, 2009, 07:33:01 PM »
Quote
Perhaps to someone that's not familiar with data binding or
how to exploit it, it may be 'rare'.

No, I have used data binding quite often; still after all your kind suggestions, I will not base form validation on data binding.  Isn’t that the real topic here?  I’ve never once stated that data binding wasn’t useful and powerful.  I have pulled binding out of a form more times than I have decided to change from the manual approach to data binding though.

Quote
If you ventured into the world of WPF, you would quickly
discover that data binding is ubiquitous, to the point where
just about anything you do with WPF is dependent on it.

While data binding may be rare from your perspective (which
seems to be the case based on your suggested approach to
validation), I can assure you that data binding is nothing but
rare to most experienced. .NET developers.

I did venture; and as quickly as I discovered that data binding is ‘everywhere’ in respect to WPF, I also discovered the abstract class ValidationRule. I was amazed at how similar my useless and absurd approach is compared to WPFs approach to Form validation.
« Last Edit: January 14, 2009, 08:31:08 PM by Ken Alexander »
Ken Alexander

Ken Alexander

  • Newt
  • Posts: 61
Re: Read-Only Property or Method?
« Reply #17 on: January 14, 2009, 07:40:16 PM »
Quote

I did venture; and as quickly as I discovered that data binding is ‘everywhere’ in respect to WPF, I also discovered the abstract class ValidationRule. I was amazed at how similar my useless and absurd approach is compared to WPFs approach to Form validation.


Here is a link to an example:

http://blog.falafel.com/2008/07/29/ValidatingInputOfDataboundControlsInWPFWithValidationRules.aspx

« Last Edit: January 14, 2009, 08:30:53 PM by Ken Alexander »
Ken Alexander

TonyT

  • Guest
Re: Read-Only Property or Method?
« Reply #18 on: January 15, 2009, 12:33:16 AM »
if the size of the struct is relatively small, then I don't see why not.

I've just never been keen to the idea of passing around large
structs (which are copied, since they're value types).

In some of these cases, wouldn’t it be better to use a struct instead of a class?
Isn’t DateTime a struct and not a class?  :mrgreen:

« Last Edit: January 15, 2009, 12:46:04 AM by TonyT »

TonyT

  • Guest
Re: Read-Only Property or Method?
« Reply #19 on: January 15, 2009, 12:48:17 AM »
In some of these cases, wouldn’t it be better to use a struct instead of a class?
Isn’t DateTime a struct and not a class?  :mrgreen:



Yea, it's a struct.

Does that make a difference in terms of property verses method?