473,785 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selectable sort

Ok, the silence is deafening. I posted my selectable
sort application to show that you can use the IComparable
Interface just as effectively as the IComparer Interface
and the feedback has been, well, there hasn't been any
feedback. Does that mean I have silenced my critics?
Are you so overwhelmed by my programming prowess that I
have left you speechless? Or do you think it is so bad,
that it's not worth responding to?
Chris Dunaway, Herfried, Bill McCarthy are you there?

Gary
Nov 20 '05 #1
8 1593
Hello,

"Gary Owsiany" <ga*****@swbell .net> schrieb:
Ok, the silence is deafening. I posted my selectable
sort application to show that you can use the IComparable
Interface just as effectively as the IComparer Interface
and the feedback has been, well, there hasn't been any
feedback. Does that mean I have silenced my critics?
Are you so overwhelmed by my programming prowess that I
have left you speechless? Or do you think it is so bad,
that it's not worth responding to?


I feel sorry, I do not have enough time at the moment to have a look at the
code, but I will repost the link to the code so that the others will find
it:

http://home.swbell.net/gar-car/sourcecode.html

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
Cor
Garry,
I did download it, I will look next week
Cor
Nov 20 '05 #3
Hi Gary,
I lost track of that thread and have only just caught up with it again. So
much beating about the bush - it's no wonder you're feeling frustrated.

Regarding zipping - there's been a discussion of that in the topic:
"Automating Excel from VB .NET". I'm in favour of zipped files that I can
utilise immediately. If it doesn't make it too big to include the whole
project/solution, I'll thank you for making it easier for me.

I'm off clubbing* tonight so I'll be too tired this weekend.. I <will>
check it out, however - I'll go to your site and dowload, and give you my
thoughts. :-)

Another thought - if you translate it into C# and post it to the
languages.cshar p group, you'll be at the bottom of a rugby scrum before you
know it!!

Regards,
Fergus.

* <not> baby seals.
Nov 20 '05 #4
Hi Gary,

Correction:
Just downloaded.

Got it into a new solution (I'm on v2002).

Compiled [Had to comment out TestSort.vb: CompareTo()
- Error: Value of type 'Selectable_Sor t.TestSort'
cannot be converted to 'Selectable_Sor t.Person'.]

Haven't studied the code (see previous post).

But suggestions on the data:
Carol, F and Gary M will sort the same by name or gender.

How about more names fewer numbers. Have some names with both genders,
eg Sam,

How about far, far fewer items. The minimum data set that will
illustrate your point. It's good if it fits in the box such that I don't have
to scroll. I hate playing clicky-clicky - it makes me lose interest.

Later, :-)
Fergus

ps. About that web page .... no comment!! Lol,
Nov 20 '05 #5
Cor
Gary,
I did take a look to it and for me it looks very nice and compact.
Nick (Nak) was longtime active in this newsgroup to collect all information
about Collections and Arrays.
I think he can give a better comment than me.

Some simple things.
I did not see for what where the raising of the events (I deleted them all
and nothing happened)
I (you see I means nothing) would delete replace the m_ and make it all m
To make it readable for myself I did put all the policies classes on one
page.

And I think you live in the US a datingservice starting at 20 :-)
Here in Europe where I live it is not that age, but for the example it is
nicer to start at 5 or something, that shows that it is a real integer sort
too.
(On msdn there is an example from a datesort with Icomparer, maybe you can
implement that too).

But I did learn again a lot from it and will examine it further.
Thanks
Cor
Nov 20 '05 #6

"Cor" <no*@non.com> wrote in message
news:3f******** *************** @reader20.wxs.n l...
Gary,
I did take a look to it and for me it looks very nice and compact.
Nick (Nak) was longtime active in this newsgroup to collect all information about Collections and Arrays.
I think he can give a better comment than me.

Some simple things.
I did not see for what where the raising of the events (I deleted them all
and nothing happened)
I (you see I means nothing) would delete replace the m_ and make it all m
To make it readable for myself I did put all the policies classes on one
page.

And I think you live in the US a datingservice starting at 20 :-)
Here in Europe where I live it is not that age, but for the example it is
nicer to start at 5 or something, that shows that it is a real integer sort too.
(On msdn there is an example from a datesort with Icomparer, maybe you can implement that too).

But I did learn again a lot from it and will examine it further.
Thanks
Cor

Thanks for the feedback. Yes, there were some "unused" events. I am
currently programming in Smalltalk and it is a "normal" practice on
"setters" to include the event. That way, it is available for binding. My
main focus was the use of the IComaparable vs. the IComparer Interface. My
view is to give the object (Person in this case) the behavior of sorting, as
opposed to "funneling" all of the person objects through a "sorter" that is
given the sorting algorithm to use. The analogy is a teacher in a classroom
who wants to sort the students by age. The "IComparabl e" way is that the
students are told to "sort yourself by age" and let the students do it
themselves. The teacher doesn't have any knowledge of the student's ages.
The "IComparer" way is that each student has to come to the teacher who then
asks "what is your age?" and then he places each student in the correct
order.
Nov 20 '05 #7
Hi Gary,

I had a good old study and was horrified!!

Ok, I'm only teasing, I needn't be so alarmist. There were some things
that I didn't like so I changed them. :-). But that then left a cold wind
blowing through a different hole! Swings and roundabouts coming up.

Firstly I agree with you that "sort yourselves out" has a better feel to
it than "line up over there while Mr Sorter deals with you". I think it's
better for a user if they don't have to worry about having to specify a
comparer.

Saying alFoo.Sort() is nice and simple. The list of Foos gets sorted
without user interaction. As it should be - who knows more about a Foo than
clsFoo?

Another alternative is that clsFoo defines the comparer and the user
specifies it
alFoo.Sort (clsFoo.BuiltIn FooComparer1)

The last, and most common case, is that the user has to implement the
whole thing
alFoo.Sort (UserDefinedFoo Comparer).
Which is not hard but it's always a pause in the flow. And an odd scrap of
code that has to be stuck somewhere.

The first and second alternatives get a bit not-much-difference-there-ish
when using the non-default comparer. Because while in the second you just use
clsFoo.BuiltInF ooComparer2 instead of 1, in the first you need an extra line
to tell the Foos which comparer to use. clsFoo.SortBy (ComparerId).

I had a look at what Help had to say about IComparable. There aren't many
Types that implement it - just the basic ones - Numbers, Enums, Strings (and
Versions).

Here's the bit that had me worried: In the central class, Person, each
Person has their own instance of SortPolicy (and SortPolicyChang ed). That's
not good for three reasons. The first is that it's a lot of overhead for what
is probably a minor part of a Person's function. Secondly every change of
SortPolicy requires a change to every Person in the array to be sorted.
Finally it's possible to assign different policies to different Persons.
Sorting an array of such would be highly unpredictable.

In finding out what implements IComparable, I had to consider - Strings
and Numbers don't carry around a SortPolicy. Programmers would be up in arms!
So it must be that the <class> impements the interface. So that was the first
change I made to the code. I specified the SortPolicy field, Property and
Changed event as Shared.

This made it easier in the DatingService, too. The loop went straight out,
to be replaced by ArrayList.Clone () and Person.SortPoli cy=.... [ps. Why did
you use an enumerator rather than For Each - Is that SmallTalk talking?].

Having the class determine the SortPolicy fixes the efficiency and
security issues but that cold wind blows. What if I have two arrays of Persons
and want them sorted in different ways?

Over to you Gary. Your turn in this discussion. :-)

Regards,
Fergus
Nov 20 '05 #8
It's the same URL as before:
http://home.swbell.net/gar-car/sourcecode.html

Gary
P.S. Please no comments about the web page. ;-)
-----Original Message-----
Hi Gary
When you have done that, will you then place the Url in this thread?We love to make long threads
Cor
.

Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1841
by: Oz Mortimer | last post by:
Hi, Is there any way that I can create a selectable image? I have tried using List and ChoiceGroup but this doesnt seem to give the results I require!. I want to create a menu list using images within a grid - similat to the VodaPhone Live service. Any advice examples?
2
3330
by: Rachel Suddeth | last post by:
Is there a way to have the non-selectable dates (those before MinDate and after MaxDate) draw differently so my users can see right away what dates aren't allowed? I'm not seeing it... Otherwise, anyone know of a cheap 3rd party calendar control I could use that would provide that ability? Thanks, Rachel
5
5044
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the CurrentUICulture to what's specified in the querystring. Since I want to allow UICulture auto detecting, I add UICulture = "auto" to page directive on each page.
3
1332
by: Peter | last post by:
Hello, One thing I am looking to do is to create a couple of different custom Web Controls that can give me added options when specifying them in an ASP.NET page. For example: <asp:RadioButtonList id=RadioButtonList1 runat="server"> <asp:ListItem myvalue1="x" myvalue2="y">Item 1</asp:ListItem> <asp:ListItem myvalue1="a" myvalue2="b">Item 2</asp:ListItem> <asp:ListItem myvalue1="g" myvalue2="h">Item 3</asp:ListItem>
5
3021
by: Lee | last post by:
Hi, Using the propertygrid, is it possible to have a user selectable 'unit of measure' for a field. For example, I am looking at using a propertygrid for defining inputs into a calculation. Some of the inputs can be either monetary or percantage. The ideal scenario is where the user enters the value and immediately to the right of the value field is a drop down, defaulted to %,which allows a currency to be selected.
1
2771
by: Homer | last post by:
Hi, I used a template for my first Web application. I made a few changes to the layer thru its css file. The problem that has been vexing me is the vertical spacing for each navigation menu item. If I do not set the verticalpadding property, the items are rendered too close to one another. However, when I set the verticalpadding property, I get the spacing that I want but the selectable area within each item is the exact height of...
1
1881
by: dbphoto | last post by:
I've created a selectable layer and inputted the action script into the button but the layer appears on the main layer and is not selectable. Any ideas?
2
3256
by: DMVC | last post by:
Hi all. I've built a class based on "Control" and I want this object of mine to be selectable. I believe that, by default, Control is non-selectable so I used this.SetStyle(ControlStyles.Selectable, true); And it works fine when I use TAB key, but when I click on my object, the focus remains on the current object. What am I doing wrong?
2
3328
Dormilich
by: Dormilich | last post by:
well, I need some help for designing a table that's showing some DB results and it should be able to sort/select some of the values. (there's no problem in getting the data once I know which ones) so, the (html) table structure is like (the columns to be sortable marked in bold) ID | Status | seller | price | category | description | date where "status", "seller" and "category" are a distinct set of values. and by sorting I want to show...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.