[Gambas-devel] Passing things

Ken Schrock schrockk at ...26...
Wed May 14 23:24:18 CEST 2003


Sorry if I came a little hard on the subject (berserker : -)
But language designers treating programmers like little children
And erecting synthetic hurdles to make programming difficult for us
Is a pet peeve (a curse on Modula and all its demon spawn)

If data wants to be free, variables definitely want to be global : -)

However, I found a simple workaround (make a global, yea)
Which makes it simpler than the examples you gave
(Although it destroys your modularity a bit : -)

Make a module, say MyMod and in it put

  PUBLIC MyString as String

In Form2 OkButton_Click put

  MyMod.MyString = TextBox1.Text
  ME.Close

In Form1 AddButton_Click put

  ... Create Form2
  MyForm2.showmodal
  ListBox1.Add(MyMod.MyString)

This means only 2 extra lines of code are needed
Over the the simplest procedure that I can think of
And since MyString can be used for other things
Doing the same trick from a thing on Form3
Would only require 1 extra line of code

I still would like a property for controls for public or private
Make the property default to private if that is your wish
Even hide it if you want (make us look hard for it)
Just as long as it is there somewhere = good

BTW, I had ask about programmatic app shutdown
And you were a little iffy on such a procedure
ME.Close in the startup class exits cleanly

Ok, I'll go back to user and leave y'all alone : -)


Benoit Minisini wrote:

>Le Lundi 12 Mai 2003 05:23, Ken Schrock a écrit :
>  
>
>>Sorry about posting to the wrong list
>>And thanks for answering my question anyway : -)
>>Particularly since it doesn't look like I will be using it anyway
>>Anal retentive, overbearing, "modular", "tightly scoped", "object oriented"
>>Languages just keep me going back to C
>>
>>Since this is the developers form...
>>Come on guys, seriously, I mean really...
>>
>>Form1.Listbox1.Insert(Textbox1.Text)
>> (or its equivalent in C)
>>
>>Is simple, clean, elegant, intuitive, logical
>>Your two examples are none of those things
>>Think about it, think about the hoops you make people jump through
>>Just to pass a single simple string from a client window to a parent window
>>
>>This may get you an award from an egghead language designer's group
>>But nobody will use it. That is fine if that is what you really want to do
>>However, if you want anybody to use it, you have to rethink this
>>I'm not going to go through all that and nobody else will either
>>
>>It is a shame, as it is an excellent idea, and well executed
>>But it appears crippled by dictatorial design philosophy
>>And really, we don't need any more of that kind
>>The landscape is littered with plenty already
>>
>>    
>>
>
>I don't want to say that VB programmers are "bad", but that they tend to use 
>bad programming practices. I didn't want to hurt you, or anyone else.
>
>I'm going to try to explain why, even if it is difficult for me to do that in 
>English.
>
>Whatever you think about object-oriented programming, encapsulation is the way 
>to write good programs, even if the language you use is not object-oriented.
>
>In a few words, encapsulation is a programming process achieved by:
>
>1) Separating your program into different pieces.
>
>2) Minimizing the links between these pieces to make reusability, debugging 
>and evolution easy.
>
>In concrete terms, I dislike accessing controls outside their forms, because 
>it creates unnecessary links between two pieces of your program: the form, 
>and the code that access it from outside.
>
>You can see forms as a high-level encapsulation unit imposed by the language.
>
>For example, let's suppose you have a form Form1 with a list box ListBox1, and 
>that you directly modify this list box from a Form2.
>
>If you decide to replace later the list box by a list view, you must then 
>modify Form2 to reflect the change. So you have broken the encapsulation 
>provided by the forms.
>
>*Of course*, I am agree with you, it is stupid to replace a single line of 
>code by all the stuff just for "philosophical" reasons. But if you must write 
>and *maintain* a program with hundreds of classes and forms, you will like 
>encapsulation ! :-)
>
>And to show everybody that I am not crippled by dictatorial design philosophy 
>:-), I will add an option to the next version of the Gambas compiler to make 
>form controls public.
>
>I hope this will help VB programmers to port their program more easily, but I 
>reserve the right to claim that encapsulation is a good thing for everyone, 
>even it need a few more, apparently stupid, lines of code.
>
>  
>

-- 
Using Lindows 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20030514/0b09ab8b/attachment.html>


More information about the Devel mailing list