473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1566
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.csharp 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_Sort.TestSort'
cannot be converted to 'Selectable_Sort.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.nl...
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 "IComparable" 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.BuiltInFooComparer1)

The last, and most common case, is that the user has to implement the
whole thing
alFoo.Sort (UserDefinedFooComparer).
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.BuiltInFooComparer2 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 SortPolicyChanged). 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.SortPolicy=.... [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
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...
2
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... ...
5
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...
3
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: ...
5
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. ...
1
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...
1
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
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 ...
2
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) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.