Re: Is this good use of Properties?



On Thu, 12 May 2005 21:38:02 +0100, Jon Skeet [C# MVP]
<skeet@xxxxxxxxx> wrote:

>Rick Elbers <rick.elbers@xxxxxxxxx> wrote:
>> I challenge: And it would be nice if you came up with the best
>> practice Pattern example to use Properties instead of telling the
>> world that ensapsulation might be a good idea after all..lol
>
>Sorry, I'm not entirely sure what you're after here. I maintain that:
>
>a) Properties are better than exposing variables directly
>b) Properties are useful in many situations
>
>That doesn't mean they're universally applicable, of course, but then
>no-one said they were.
>
>Out of interest, if you don't think accessors should be used, how would
>you expose the length of a string? Or wouldn't you? What would you use
>instead?

Very good example (of my point). Never expose the length of the string
would be the instantiation of my global advice here. Give me one
reason why you would want to and I show you two why doing it is less
design then not doing it.

Rick

.



Relevant Pages

  • Re: Is this good use of Properties?
    ... >>> is a property bag which is not a valid class. ... String has no application domain, ... >>No-one has suggested that all classes should expose everything about ... I still don't see your points Rick. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is this good use of Properties?
    ... The idea that a class should be able to draw itself just in case ... >> is a property bag which is not a valid class. ... String has no application domain, ... >No-one has suggested that all classes should expose everything about ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Theming custom created WebParts in ASP.NET 2.0
    ... One thing though, say you expose ... webpart to the zone using a catalog, ... > However, IMO, I'd prefer expose a single string property on my custom web ... > simple type properteis, I think just exposing a ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Overloading in ooRexx
    ... working on getting my mind around the simplicity of Rick's suggested class, and trying to figure out "how it understands" to do so much with so little code. ... like the string method for example. ... expose value use arg value ...
    (comp.lang.rexx)
  • Re: OOP question - multiple value properties
    ... With 2.0, you could create a generic type, which you would use to expose ... >> string Description; ... >>> public class Person { ... >>> public DateTime Date ...
    (microsoft.public.dotnet.languages.csharp)

Quantcast