|
|
Well, since .NET is inconsistent on the matter, why follow them?
Set your own naming standards for your own code, I say.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
It is only a little inconsistent, it is mostly all right, so I choose to go along with their view, which helps readability I'd say.
The most annoying inconsistency IMO is Array.Length versus List.Count (I would applaud them if they would introduce the missing one as a synonym).
|
|
|
|
|
If a polygon has no points, it's not a polygon. If a polygon comprised of four or more points contains no additional points within the boundaries which define it, then it IsEmpty. How you code it makes little difference; it's still going to be a boolean value that you'll test. But I prefer to name boolean properties for the value I expect to find most often. It makes no difference logically, but I find it easier to read and understand what the code is looking for.
Will Rogers never met me.
|
|
|
|
|
If you're just using a property to indicate whether or not it has any points, then I would expect it to be HasPoints . If, however, you need to indicate whether or not it has enough points to be classed as a polygon, I would use IsPolygon .
|
|
|
|
|
The short answer is that both are acceptable and both are used within the Framework, so use whichever you think is better. I typically drop the 'Is'.
I also agree with other posters who've said that you should really be defining a Valid (or IsValid ) property which checks that there are at least 3 points (maybe 3 non-colinear points?). The points array being empty isn't really a relevant concern, I don't think.
|
|
|
|
|
"Empty"; as "IsEmpty" would be question and would indeed imply either a delegate or a method.
"Empty" is a property of the Polygon. "IsEmpty" would be a method that can be called from that property to fetch a value, but a property never begins with "Is".
The color of an apple is "Apple.Color", not "Apple.IsColor". Yes, you might be persuaded to prefix the "Is" because the property returns a bool. It shouldn't matter whether it returns a bool or an enum - if it's a property, then it'll have the name of a property - not the form a question.
Bastard Programmer from Hell
|
|
|
|
|
Thinking about the way structs such as Size , Point and Rectangle deal with this, I haven't checked, but I don't believe they don't provide a property for this. There is a static read only instance available called Empty that you can use for equality comparison to see if the one you have is empty. Overriding Equals(object) , GetHashCode() and providing operator overloads for == and != (and possibly implementing IEquatable<T> ) would be the way to do this.
I don't think I would use a property for this, I would use a method public bool IsEmpty() as you are asking for information about the object as a whole rather than a part of it which is IMO opinion the purpose of a property.
|
|
|
|
|
Hello everyone! I have a School Management Application that shows examination reports for students in a selected class. I used a Panel control to model a sheet of paper on which each student's results are shown. Thus for selected classes, the number of controls (Panels modeled as sheets) added to the tab page depends on the number of students in the class. Class student's are around 50 to 60.
When I first open reports for a class, all controls are created (as sheets) and no problem occurs. However, when I try to open examination reports for another class, I get a 'Win32Exception' with additional error information that 'Error creating window handle'.
Now I tried to open in another way. When I open the examination reports for the first which does not report any error, I close it before opening that of another class but the problem is that the error is still generated even when the first list of reports have been closed and removed from the TabControl. Any solution around this? Thanks in advance.
|
|
|
|
|
Posting some source code would help.
/ravi
|
|
|
|
|
Are you trying to do something in the wrong thread?
|
|
|
|
|
Ran into a weird Bitmap problem that I can't find in Google:
The Bitmap constructor crashes on a file with an alpha channel under Windows 7, but works perfectly under Windows XP.
The code couldn't be simpler:
Bitmap image = new Bitmap (fname);
The error is: "Parameter is not valid", and there's no inner exception.
If it failed in Windows XP too, I'd suspect a simple bug, but since it works there it implies it's something more complex.
Any ideas how a bitmap with an alpha channel can be loaded under Windows 7? Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
|
It's a TIFF file. I've loaded BMP files (without an alpha channel) with this same code with no problem.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
And the same file opens on XP?
|
|
|
|
|
Yes. The TIFF file with an alpha channel works perfectly under XP. Both BMP and TIFF files WITHOUT an alpha channel work under both OSes.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Possibly a problem with the TIFF codec in Windows 7 then I'm afraid. If I were you, I'd raise a report through Microsoft Connect.
|
|
|
|
|
Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
You're welcome. I'm just sorry I couldn't be of more assistance.
|
|
|
|
|
Hi everyone!
I'm looking for a library that allows me to load, save and edit .dxf documents. Preferably, it has to be free. I need to allow the user to define "zones" over the "graphic" through a visual interface.
Thank you in advance!
modified 8-Mar-12 11:57am.
|
|
|
|
|
|
Thank you very much. I will take a look to these libraries!
|
|
|
|
|
The autodesk API is not what I need. I understand that it is more about developing autocad plugins or using autocad functions remotely, but always having the main program installed. I will take a look to your second proposal...
|
|
|
|
|
hi all
i need an component that find all directory that can show in tree viewer.
|
|
|
|
|
It's part of the Framework (means it's already on you machine). You'd use the GetFilesMethod of the Directory[^] class and display it in a TreeView[^].
I'm sure that there are plenty examples on this on the internetz. What have you tried so far?
Bastard Programmer from Hell
|
|
|
|