473,320 Members | 1,867 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,320 software developers and data experts.

Bad form to access a *private variable* like _foo?

Bad form to access a *private variable* like _foo?

The reason I'm asking is that TurboGears/SQLObject mobel objects have
an attribute called "_connection" that must be used to manually commit
database stuff....

e.g. MyObject._connection.commit()

It bugs me. I don't know if it is a stylistic faux pas or not.

Is it?

Chris
Jun 27 '08 #1
3 928
se******@spawar.navy.mil a écrit :
Bad form to access a *private variable* like _foo?
In this case, this would be spelled "protected" - or even better
"implementation". And the contract is: nothing prevent you to access
implementation attributes, but then you're on your own if anything breaks.
The reason I'm asking is that TurboGears/SQLObject mobel objects have
an attribute called "_connection" that must be used to manually commit
database stuff....

e.g. MyObject._connection.commit()

It bugs me. I don't know if it is a stylistic faux pas or not.

Is it?
The way you wrote it here, yes. If there's no official way to do the
same operation and you have a real use case for it - in which case you
may want to add a commit() method to SQLObject's model base class and
submit the patch to SQLObject's maintainer. But I strongly suspect
there's a better way to handle this case in SQLObject's API.
Jun 27 '08 #2
The way you wrote it here, yes. If there's no official way to do the
same operation and you have a real use case for it - in which case you
may want to add a commit() method to SQLObject's model base class and
submit the patch to SQLObject's maintainer. But I strongly suspect
there's a better way to handle this case in SQLObject's API.
There are other ways. For example,

sqlobject.sqlhub.threadingLocal.connection

if your system is using multiple threads correctly. Generally speaking,
sqlhub could/should be used.
Diez
Jun 27 '08 #3
On May 6, 3:27 am, "Diez B. Roggisch" <de...@nospam.web.dewrote:
There are other ways. For example,

sqlobject.sqlhub.threadingLocal.connection

if your system is using multiple threads correctly. Generally speaking,
sqlhub could/should be used.
That's actually quite involved. You must first get a reference to a
PackageHub object, then invoke connectionToURI, etc. lots of steps!

cs
Jun 27 '08 #4

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

Similar topics

4
by: Yasutaka Ito | last post by:
Hi, As you know, all the non-ui components (like Timer control, etc.) that sit on the form are contained in its private variable 'components'. How can I enumerate such components from any form...
7
by: rickcheney | last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I had a form where the user entered a value into a text box and when a command button on the form was clicked a Report was...
1
by: Michel | last post by:
Yes, there is a way of forbidding a form being closed if you create a boolean variable (blnCanClose = False) in the form's Unload event. I didn't read all the responses, but I have just such a form...
19
by: hamil | last post by:
I have a form with one button, Button1, and a Textbox, Textbox1 I have a class, class1 as follows. Public Class Class1 Public DeForm As Object Sub doit() DeForm.Textbox1.text = "It works"...
3
by: Truong Hong Thi | last post by:
Anyone know a free vs.net 2003 plugin that is capable of generating properties from private fields for C#? Thanks ahead.
6
by: ahmad.humyn | last post by:
I want to call a hidden form. My code goes something like in which the main calls form1. form1 has a button which creates & calls form2 and hides itself. Now I have a button in form2 which if...
7
by: pooba53 | last post by:
I am working with VB .NET 2003. Let's say my main form is called Form1. I have to launch a new form (Form2) that gathers input from the user. How can I pass variable information back to Form1...
12
by: Rob | last post by:
Let's say you open Form1 that contains TabControl1 There are several tabs on TabControl1 Now you open a new Form2 that contains a User Control How can you determine the Selected tab in Form1...
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.